Commit Graph

162488 Commits

Author SHA1 Message Date
Matthias Krüger
7e212c1ca9
Rollup merge of #93542 - GuillaumeGomez:lifetime-elision, r=oli-obk
Prevent lifetime elision in type alias

Fixes #93401.

Apparently, the problem has been fixed in the compiler.

r? `@oli-obk`
2022-02-02 19:34:03 +01:00
Matthias Krüger
b622552e10
Rollup merge of #93221 - alyssaverkade:fix-93093, r=wesleywiser
[borrowck] Fix help on mutating &self in async fns

Previously, when rustc was provided an async function that tried to
mutate through a shared reference to an implicit self (as shown in the
ui test), rustc would suggest modifying the parameter signature
to `&mut` + the fully qualified name of the ty (in the case of the repro
`S`). If a user modified their code to match the suggestion, the
compiler would not accept it.

This commit modifies the suggestion so that when rustc is provided the
ui test that is also attached in this commit, it suggests (correctly)
`&mut self`. We try to be careful about distinguishing between implicit
and explicit self annotations, since the latter seem to be handled
correctly already.

This is my first PR here so I'm pretty sure I probably missed something/could use better terminology. I also didn't try to make the match exhaustive since implicit self is the only real special case that I need to handle (that I'm aware of), and I'm pretty sure there's a cleaner way to do this so any advice would be greatly appreciated! (I'm also not terribly confident about how I wrote the ui tests)

here is your cc as requested `@compiler-errors`

This is an attempt to fix #93093
2022-02-02 19:34:02 +01:00
Matthias Krüger
21ffe45631
Rollup merge of #92528 - tmiasko:combine-commutative, r=michaelwoerister
Make `Fingerprint::combine_commutative` associative

The previous implementation swapped lower and upper 64-bits of a result
of modular addition, so the function was non-associative.

r? `@Aaron1011`
2022-02-02 19:34:01 +01:00
Oli Scherer
d9bb93f3a4 Fix some doctests where the main function returns an opaque type 2022-02-02 17:15:18 +00:00
est31
3cb7618f58 Remove unused dep from rustc_arena 2022-02-02 17:37:14 +01:00
est31
670f5c6ef3 More let_else adoptions 2022-02-02 17:11:01 +01:00
Oli Scherer
be153f0976 Only prevent TAITs from defining each other, RPIT and async are fine, they only ever have one defining site, and it is ordered correctly around expected and actual type in type comparisons 2022-02-02 15:40:12 +00:00
Oli Scherer
7f608eb9ed Prevent two opaque types in their defining scopes from being defined via the other 2022-02-02 15:40:12 +00:00
Oli Scherer
bae04fb3de Ensure we error in case of non-higher-kinded lifetimes 2022-02-02 15:40:12 +00:00
Oli Scherer
7a1ccf9a03 Avoid an ICE in the presence of HKL 2022-02-02 15:40:12 +00:00
Oli Scherer
ebf2772c58 Add regression test 2022-02-02 15:40:12 +00:00
Oli Scherer
ee2158f1ee run rustfmt 2022-02-02 15:40:12 +00:00
Oli Scherer
59d0bff0e6 Reduce follow-up errors that are not helpful 2022-02-02 15:40:12 +00:00
Oli Scherer
6560d77a53 Bail out early if there already were errors 2022-02-02 15:40:12 +00:00
Oli Scherer
29c8732436 Make the error for opaque types that have no hidden types a bit informative 2022-02-02 15:40:12 +00:00
Oli Scherer
4d2e965106 Make a span more useful 2022-02-02 15:40:12 +00:00
Oli Scherer
5518d1931d Guess head span of async blocks 2022-02-02 15:40:12 +00:00
Oli Scherer
7fd9c7e6de undo a useless change 2022-02-02 15:40:12 +00:00
Oli Scherer
b6d57ecc0b Hide further opaque type errors if items that could constrain the opaque type have errors 2022-02-02 15:40:12 +00:00
Oli Scherer
e4794d9d1b Undo a change that is now unnecessary 2022-02-02 15:40:12 +00:00
Oli Scherer
c564898110 Remove a now-useless field 2022-02-02 15:40:12 +00:00
Oli Scherer
3d4b9b8b8b Remove some unused arguments and update a comment 2022-02-02 15:40:12 +00:00
Oli Scherer
dc36b38526 Make a comment more obvious 2022-02-02 15:40:12 +00:00
Oli Scherer
d3b534b6b5 manual formatting 2022-02-02 15:40:12 +00:00
Oli Scherer
d8c29b3e28 Simplify diff 2022-02-02 15:40:11 +00:00
Oli Scherer
dbda675419 Undo a diff 2022-02-02 15:40:11 +00:00
Oli Scherer
b45fabddfd Inline a function that is only used once 2022-02-02 15:40:11 +00:00
Oli Scherer
d35d1ef4f5 Remove unnecessary field 2022-02-02 15:40:11 +00:00
Oli Scherer
5b49b8e2d5 Remove unnecessary closure in favour of just passing the argument directly 2022-02-02 15:40:11 +00:00
Oli Scherer
fcba8d31c4 Remove the Instantiator now that we don't recurse within it anymore 2022-02-02 15:40:11 +00:00
Oli Scherer
e03edd287e Inline a function that is only ever used in one place 2022-02-02 15:40:11 +00:00
Oli Scherer
22477784a7 Fixup changes that aren't neccessary anymore 2022-02-02 15:40:11 +00:00
Oli Scherer
94d6a9acc9 This can't happen anymore. An opaque type can't end up with itself as its hidden type 2022-02-02 15:40:11 +00:00
Oli Scherer
3146c961fe We're equating hidden types eagerly now 2022-02-02 15:40:11 +00:00
Oli Scherer
5a374dc813 Add some tests to show what happens when you compare two opaque types that are both within the defining scope 2022-02-02 15:40:11 +00:00
Oli Scherer
cbfd736292 Update an outdated test explanation 2022-02-02 15:40:11 +00:00
Oli Scherer
77aacc1768 Test recursive TAIT declarations 2022-02-02 15:40:11 +00:00
Oli Scherer
7795f6233c Add explanation for early abort in TAIT hidden type computation 2022-02-02 15:40:11 +00:00
Oli Scherer
64c5b9a3d6 Add backcompat hack to support
```rust
fn foo() -> impl MyTrait {
    panic!();
    MyStruct
}

struct MyStruct;
trait MyTrait {}

impl MyTrait for MyStruct {}
```
2022-02-02 15:40:11 +00:00
Oli Scherer
edaf9625fb Clean up leftovers from eager hidden type merging 2022-02-02 15:40:11 +00:00
Oli Scherer
38f50d1ecb Eagerly merge hidden types. 2022-02-02 15:40:11 +00:00
Oli Scherer
a745797142 Stop generating inference vars for nested impl trait and let type equality handle it.
This means we stop supporting the case where a locally defined trait has only a single impl so we can always use that impl (see nested-tait-inference.rs).
2022-02-02 15:40:11 +00:00
Oli Scherer
7bce50c01a Register member constraints on the final merged hidden type
Previously we did this per hidden type candiate, which didn't always have all the information available.
2022-02-02 15:40:11 +00:00
Oli Scherer
9110911353 bless 2022-02-02 15:40:11 +00:00
Oli Scherer
0f6e06b7c0 Lazily resolve type-alias-impl-trait defining uses
by using an opaque type obligation to bubble up comparisons between opaque types and other types

Also uses proper obligation causes so that the body id works, because out of some reason nll uses body ids for logic instead of just diagnostics.
2022-02-02 15:40:11 +00:00
Oli Scherer
8d2b598459 More sanity checks 2022-02-02 15:40:10 +00:00
Oli Scherer
f7abc1b6f8 Expose current span to type equality checking in nll 2022-02-02 15:40:10 +00:00
Oli Scherer
47a6a24d51 Add a convenient way to inject rustc flags somewhere late in the bootstrap pipeline without causing rebuilds
Useful for -Ztreat-err-as-bug
2022-02-02 15:40:10 +00:00
Oli Scherer
4e1a5968f1 Found suspicious comparison of constants 2022-02-02 15:40:10 +00:00
Oli Scherer
bbbdcb327f Update some comments 2022-02-02 15:40:10 +00:00