Commit Graph

393 Commits

Author SHA1 Message Date
bors
880416180b Auto merge of #99181 - lcnr:arenaGTrc, r=wesleywiser
`arena > Rc` for query results

The `Rc`s have to live for the whole duration as their count cannot go below 1 while stored as part of the query results.

By storing them in an arena we should save a bit of memory because we don't have as many independent allocations and also don't have to clone the `Rc` anymore.
2022-07-18 05:50:54 +00:00
Caio
3266460749 Stabilize let_chains 2022-07-16 20:17:58 -03:00
Matthias Krüger
6277ac2fb8
Rollup merge of #99342 - TaKO8Ki:avoid-symbol-to-string-conversions, r=compiler-errors
Avoid some `Symbol` to `String` conversions

This patch removes some Symbol to String conversions.
2022-07-16 22:30:56 +02:00
Matthias Krüger
984ef421fd
Rollup merge of #99258 - estebank:suggest-let, r=wesleywiser
Provide structured suggestion for dropped temp value
2022-07-16 22:30:49 +02:00
Matthias Krüger
6f8fb911ad
Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank
Allow destructuring opaque types in their defining scopes

fixes #96572

Before this PR, the following code snippet failed with an incomprehensible error, and similar code just ICEd in mir borrowck.

```rust
    type T = impl Copy;
    let foo: T = (1u32, 2u32);
    let (a, b) = foo;
```

The problem was that the last line created MIR projections of the form `foo.0` and `foo.1`, but `foo`'s type is `T`, which doesn't have fields (only its hidden type does). But the pattern supplies enough type information (a tuple of two different inference types) to bind a hidden type.
2022-07-16 22:30:47 +02:00
Takayuki Maeda
c54d4ada26 avoid some Symbol to String conversions 2022-07-17 04:09:20 +09:00
Esteban Küber
3ee4e5f704 Fix rebase 2022-07-15 11:14:06 -07:00
Esteban Küber
635c38187b Avoid incorrect suggestion
We check that there's a single level of block nesting to ensure always
correct suggestions. If we don't, then we only provide a free-form
message to avoid misleading users in cases like
`src/test/ui/nll/borrowed-temporary-error.rs`.

We could expand the analysis to suggest hoising all of the relevant
parts of the users' code to make the code compile, but that could be
too much.
2022-07-15 11:04:45 -07:00
Esteban Küber
20b5aaf111 Provide structured suggestion for dropped temp value 2022-07-15 11:04:45 -07:00
Oli Scherer
6b33d5bfa9 Make destructuring a defining use 2022-07-15 15:56:17 +00:00
Oli Scherer
84a444a1f4 Introduce opaque type to hidden type projection 2022-07-15 15:49:22 +00:00
lcnr
5bd8c960f5 provide generic_param_scope for region errors 2022-07-15 16:53:20 +02:00
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
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
bors
c80dde43f9 Auto merge of #99210 - Dylan-DPC:rollup-879cp1t, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #98574 (Lower let-else in MIR)
 - #99011 (`UnsafeCell` blocks niches inside its nested type from being available outside)
 - #99030 (diagnostics: error messages when struct literals fail to parse)
 - #99155 (Keep unstable target features for asm feature checking)
 - #99199 (Refactor: remove an unnecessary `span_to_snippet`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-13 17:13:27 +00:00
Takayuki Maeda
5188bdbccd remove an unnecessary span_to_snippet 2022-07-13 13:24:06 +09: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
lcnr
baefd42861 arena > Rc for query results 2022-07-12 15:27:24 +02:00
ouz-a
cb0017f2f8 add new rval, pull deref early 2022-07-12 14:26:41 +03: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
Matthias Krüger
2cb7d1c933
Rollup merge of #98713 - nikomatsakis:issue-98693, r=jackh726
promote placeholder bounds to 'static obligations

In NLL, when we are promoting a bound out from a closure, if we have a requirement that `T: 'a` where `'a` is in a higher universe, we were previously ignoring that, which is totally wrong. We should be promoting those constraints to `'static`, since universes are not expressible across closure boundaries.

Fixes #98693

~~(Marking as WIP because I'm still running tests, haven't add the new test, etc)~~

r? ``@jackh726``
2022-07-11 00:33:47 +02:00
Matthias Krüger
86af7135ae
Rollup merge of #99103 - TaKO8Ki:avoid-&str-to-string-conversions, r=oli-obk
Avoid some `&str` to `String` conversions

This patch removes some `&str` to `String` conversions.
2022-07-10 11:52:17 +02:00
Takayuki Maeda
bda83e6543 avoid some &str to String conversions 2022-07-10 03:18:56 +09:00
Matthias Krüger
5dcd28cd19
Rollup merge of #98795 - jackh726:lexical_region_resolve_cleanup, r=compiler-errors
A few cleanups

Each commit is (mostly) self-explanatory. These changes have come as I try to remove `ReEmpty` (#98559).
2022-07-08 08:00:38 +02:00
bors
eba361ae36 Auto merge of #98482 - cjgillot:short-struct-span-closure, r=estebank
Shorten def_span of closures to just their header

Continuation of https://github.com/rust-lang/rust/pull/93967.
2022-07-08 03:05:15 +00:00
Jack Huey
31e1a777e7 Move code from rustc_trait_selection/opaque_types to better places 2022-07-07 21:45:40 -04:00
Jack Huey
2471431017 Move is_free and is_free_or_static to Region, change resolve_var to resolve_region, and remove RootEmptyRegion 2022-07-07 20:48:51 -04:00
Esteban Küber
d09851cfba Wording tweak 2022-07-07 12:25:56 -07:00
Esteban Küber
5f91614d12 Fix label on uninit binding field assignment 2022-07-07 12:25:56 -07:00
Esteban Küber
a86fa4fa38 Avoid misleading message/label in match-cfg-fake-edges.rs test 2022-07-07 12:25:56 -07:00
Esteban Küber
95923d1676 Review comments: wording 2022-07-07 12:25:56 -07:00
Esteban Küber
9cb1874cd6 Tweak wording and spans 2022-07-07 12:25:56 -07:00
Esteban Küber
29e2aa12ff On partial uninit error point at where we need init
When a binding is declared without a value, borrowck verifies that all
codepaths have *one* assignment to them to initialize them fully. If
there are any cases where a condition can be met that leaves the binding
uninitialized or we attempt to initialize a field of an unitialized
binding, we emit E0381.

We now look at all the statements that initialize the binding, and use
them to explore branching code paths that *don't* and point at them. If
we find *no* potential places where an assignment to the binding might
be missing, we display the spans of all the existing initializers to
provide some context.
2022-07-07 12:25:55 -07:00
Camille GILLOT
5edc55f99f Fix borrowck closure span. 2022-07-07 09:27:44 +02:00
Camille GILLOT
8cc87250ef Shorten span for closures. 2022-07-07 09:27:42 +02:00
Tomasz Miąsko
17adfeb2b4 Move dominators from Body to BasicBlocks 2022-07-07 08:11:49 +02:00
Tomasz Miąsko
39d9c1cb1f Move predecessors from Body to BasicBlocks 2022-07-07 08:11:49 +02:00
Takayuki Maeda
83dea35384 replace guess_head_span with def_span 2022-07-06 19:09:47 +09:00
Alan Egerton
4f0a64736b
Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
Alan Egerton
e9e5d0685b
Relax constrained generics to TypeVisitable 2022-07-05 22:25:43 +01:00
Matthias Krüger
cb2d3bb198
Rollup merge of #98878 - lcnr:more-rustc_pass_by_value, r=oli-obk
add more `rustc_pass_by_value`

r? ```@oli-obk``` cc #98766
2022-07-04 23:11:12 +02:00
lcnr
8deadfa271 fully move dropck to mir 2022-07-04 10:26:23 +02:00
lcnr
658b7f3652 more rustc_pass_by_value 2022-07-04 09:40:58 +02:00
bors
ada8c80bed Auto merge of #98673 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum
Bump bootstrap compiler

r? `@Mark-Simulacrum`
2022-07-03 06:55:50 +00:00
Dylan DPC
05aebf8f69
Rollup merge of #98766 - lcnr:mir-visit-pass_by_value, r=oli-obk
cleanup mir visitor for `rustc::pass_by_value`

by changing `& $($mutability)?` to `$(& $mutability)?`

I also did some formatting changes because I started doing them for the visit methods I changed and then couldn't get myself to stop xx, I hope that's still fairly easy to review.
2022-07-02 12:23:41 +05:30
Cameron Steffen
ec82bc1996 Factor out hir::Node::Binding 2022-07-01 10:04:19 -05:00
lcnr
cf9c0a5935 cleanup mir visitor for rustc::pass_by_value 2022-07-01 16:21:21 +02:00