Commit graph

700 commits

Author SHA1 Message Date
bors f1a8854f9b Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #97720 (Always create elided lifetime parameters for functions)
 - #98315 (Stabilize `core::ffi:c_*` and rexport in `std::ffi`)
 - #98705 (Implement `for<>` lifetime binder for closures)
 - #99126 (remove allow(rustc::potential_query_instability) in rustc_span)
 - #99139 (Give a better error when `x dist` fails for an optional tool)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-14 11:00:30 +00:00
Dylan DPC e5a86d7358
Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot
Implement `for<>` lifetime binder for closures

This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following:

```rust
let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) };
//       ^^^^^^^^^^^--- new!
```

cc ``@Aaron1011`` ``@cjgillot``
2022-07-14 14:14:21 +05:30
bors 0ed9c64c3e Auto merge of #98975 - jyn514:unstable_opts, r=wesleywiser
Rename `debugging_opts` to `unstable_opts`

This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.

cc https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Codegen.20options.20.2F.20debugging.20options

r? `@Amanieu` cc `@nikic` `@joshtriplett`
2022-07-14 08:14:31 +00:00
Joshua Nelson 3c9765cff1 Rename debugging_opts to unstable_opts
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.
2022-07-13 17:47:06 -05:00
Ralf Jung e4593ef0f2 assigning to a union field can never drop now 2022-07-13 18:27:28 -04:00
Maybe Waffle df4fee9841 Add an indirection for closures in hir::ExprKind
This helps bring `hir::Expr` size down, `Closure` was the biggest
variant, especially after `for<>` additions.
2022-07-12 21:00:13 +04:00
Ding Xiang Fei 5374688e1d
add tests for async await 2022-07-11 23:20:39 +02:00
Ding Xiang Fei 1cd30e7b32
move else block into the Local struct 2022-07-11 23:20:37 +02:00
Ding Xiang Fei 6c529ded86
lower let-else in MIR instead 2022-07-11 23:20:36 +02:00
Dylan DPC 9fc297a2ae
Rollup merge of #99140 - TaKO8Ki:implement-is-accessible-span, r=fee1-dead
Implement `SourceMap::is_span_accessible`

This patch adds `SourceMap::is_span_accessible` and replaces `span_to_snippet(span).is_ok()` and `span_to_snippet(span).is_err()` with it. This removes a `&str` to `String` conversion.
2022-07-11 15:19:32 +05:30
Takayuki Maeda 018155c3a2 rename a method 2022-07-11 16:51:19 +09:00
Takayuki Maeda 12d11e9a35 implement is_accessible_span 2022-07-11 11:36:15 +09:00
Michael Goulet a1634642e0 Deny floats even when adt_const_params is enabled 2022-07-11 00:04:00 +00:00
Ralf Jung 4e7aaf1f44 tweak names and output and bless 2022-07-09 07:43:56 -04:00
Ralf Jung ac265cdc19 review feedback 2022-07-09 07:27:29 -04:00
Ralf Jung a422b42159 don't allow ZST in ScalarInt
There are several indications that we should not ZST as a ScalarInt:
- We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it.
  `ValTree::zst()` used the former, but the latter could possibly arise as well.
- Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`.
- LLVM codegen already had to special-case ZST ScalarInt.

So instead add new ZST variants to those types that did not have other variants
which could be used for this purpose.
2022-07-09 07:27:29 -04:00
Tomasz Miąsko c9dd1d9983 Make MIR basic blocks field public
This makes it possible to mutably borrow different fields of the MIR
body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`.

To preserve validity of control flow graph caches in the presence of
modifications, a new struct `BasicBlocks` wraps together basic blocks
and control flow graph caches.

The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`.
On the other hand a mutable access requires explicit `as_mut()` call.
2022-07-07 08:11:49 +02:00
Alan Egerton 4f0a64736b
Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
bors 54f79babae Auto merge of #98925 - Dylan-DPC:rollup-9185c9y, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #97712 (ptr::copy and ptr::swap are doing untyped copies)
 - #98624 (lints: mostly translatable diagnostics)
 - #98776 (rustdoc: improve click behavior of the source code mobile full-screen "sidebar")
 - #98856 (Remove FIXME from rustdoc intra-doc test)
 - #98913 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-05 12:17:26 +00:00
Dylan DPC 291df97fae
Rollup merge of #98624 - davidtwco:translation-on-lints, r=compiler-errors
lints: mostly translatable diagnostics

As lints are created slightly differently than other diagnostics, intended to try make them translatable first and then look into the applicability of diagnostic structs but ended up just making most of the diagnostics in the crate translatable (which will still be useful if I do make a lot of them structs later anyway).

r? ``@compiler-errors``
2022-07-05 16:04:32 +05:30
bors 53792b9c5c Auto merge of #96862 - oli-obk:enum_cast_mir, r=RalfJung
Change enum->int casts to not go through MIR casts.

follow-up to https://github.com/rust-lang/rust/pull/96814

this simplifies all backends and even gives LLVM more information about the return value of `Rvalue::Discriminant`, enabling optimizations in more cases.
2022-07-05 09:36:29 +00:00
Oli Scherer 82c73af4a6 Prefer trace level instrumentation for the new noisy instrument attributes 2022-07-05 09:27:06 +00:00
Dylan DPC d287726aa0
Rollup merge of #98639 - camsteffen:no-node-binding, r=compiler-errors
Factor out `hir::Node::Binding`
2022-07-02 12:23:38 +05:30
Cameron Steffen ec82bc1996 Factor out hir::Node::Binding 2022-07-01 10:04:19 -05:00
bors 5b9775fe17 Auto merge of #98402 - cjgillot:undead, r=michaelwoerister
Rewrite dead-code pass to avoid fetching HIR.

This allows to get a more uniform handling of spans, and to simplify the grouping of diagnostics for variants and fields.
2022-07-01 14:43:15 +00:00
David Wood 7d2eba6311 middle: translation in LintDiagnosticBuilder
Accept `DiagnosticMessage` in `LintDiagnosticBuilder::build` so that
lints can be built with translatable diagnostic messages.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:58:41 +01:00
Oli Scherer 7839cb963f Change enum->int casts to not go through MIR casts.
Instead we generate a discriminant rvalue and cast the result of that.
2022-06-30 07:47:07 +00:00
Matthias Krüger d34c4ca9be
Rollup merge of #98668 - TaKO8Ki:avoid-many-&str-to-string-conversions, r=Dylan-DPC
Avoid some `&str` to `String` conversions with `MultiSpan::push_span_label`

This patch removes some`&str` to `String` conversions with `MultiSpan::push_span_label`.
2022-06-29 20:35:07 +02:00
Takayuki Maeda 6212e6b339 avoid many &str to String conversions with MultiSpan::push_span_label 2022-06-29 21:16:43 +09:00
Oli Scherer 0e674b3ec5 Some tracing cleanups 2022-06-29 09:56:30 +00:00
bors 66c83ffca1 Auto merge of #98558 - nnethercote:smallvec-1.8.1, r=lqd
Update `smallvec` to 1.8.1.

This pulls in https://github.com/servo/rust-smallvec/pull/282, which
gives some small wins for rustc.

r? `@lqd`
2022-06-29 09:11:29 +00:00
Michael Goulet 8fd73560b3 Do not use a suggestion to change a binding's name to a type 2022-06-28 22:34:13 +00:00
Nicholas Nethercote 7c40661ddb Update smallvec to 1.8.1.
This pulls in https://github.com/servo/rust-smallvec/pull/282, which
gives some small wins for rustc.
2022-06-27 08:48:55 +10:00
Matthias Krüger ea07b969ea
Rollup merge of #98429 - b-naber:use-correct-substs-discriminant-cast, r=lcnr
Use correct substs in enum discriminant cast

Fixes https://github.com/rust-lang/rust/issues/97634

r? ```@lcnr```
2022-06-25 15:14:13 +02:00
b-naber bf48b622a5 fmt 2022-06-24 16:43:38 +02:00
b-naber f39c0d6b0a address review 2022-06-24 13:43:56 +02:00
b-naber 38814fc039 small refactor 2022-06-24 13:19:23 +02:00
b-naber 2e3221a927 use correct substs in enum discriminant hack 2022-06-24 11:11:40 +02:00
Camille GILLOT 2d82234331 Remove dead code. 2022-06-23 22:16:50 +02:00
Matthias Krüger 3e5800b8d3
Rollup merge of #98267 - compiler-errors:suggest-wildcard-arm, r=oli-obk
Don't omit comma when suggesting wildcard arm after macro expr

* Also adds `Span::eq_ctxt` to consolidate the various usages of `span.ctxt() == other.ctxt()`
* Also fixes an unhygenic usage of spans which caused the suggestion to render weirdly when we had one arm match in a macro
* Also always suggests a comma (i.e. even after a block) if we're rendering a wildcard arm in a single-line match (looks prettier 🌹)

Fixes #94866
2022-06-20 20:13:10 +02:00
bors 9a0b774966 Auto merge of #97931 - xldenis:fix-if-let-source-scopes, r=nagisa
Fix `SourceScope` for `if let` bindings.

Fixes #97799.

I'm not sure how to test this properly, is there any way to observe the difference in behavior apart from `ui` tests? I'm worried that they would be overlooked in the case of a regression.
2022-06-20 03:08:52 +00:00
Michael Goulet 3d16c22864 Be more hygenic with spans 2022-06-19 16:47:21 -07:00
Michael Goulet 52c9906c4b Use Span::eq_ctxt method instead of .ctxt() == .ctxt() 2022-06-19 16:46:59 -07:00
Michael Goulet 2c3bb42ebd Only omit trailing comma if block doesn't come from macro expansion 2022-06-19 16:46:37 -07:00
Nicholas Nethercote bdbf9b297b compare_const_vals: add a special case for certain ranges.
This commit removes the `a == b` early return, which isn't useful in
practice, and replaces it with one that helps matches with many ranges,
including char ranges.
2022-06-16 11:25:34 +10:00
Nicholas Nethercote 73c52b724a compare_const_vals: Use infallible evaluation.
Because these evaluations can never fail.
2022-06-16 10:52:58 +10:00
Nicholas Nethercote 246a5e08bf Remove ty arg from compare_const_vals.
It's now only used in no-longer-interesting assertion.
2022-06-16 10:52:58 +10:00
Nicholas Nethercote 3ab6ef1938 Remove from_bool closure.
The code is clearer and simpler without it. Note that the `a == b` early
return at the top of the function means the `a == b` test at the end of
the function could never succeed.
2022-06-16 10:52:58 +10:00
Nicholas Nethercote fab85ddbeb Inline and remove fallback closure. 2022-06-16 10:52:58 +10:00
Nicholas Nethercote b67635fdfd Remove one use of compare_const_vals.
A direct comparison has the same effect. This also avoids the need for a
type test within `compare_const_vals`.
2022-06-16 10:52:58 +10:00