forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#99818 - aliemjay:fix-closure-normalize, r=j…
…ackh726 don't ICE when normalizing closure input tys We were ICEing while rendering diagnostics because `universe_causes` is expected to track every universe created in the typeck's infcx. `normalize_and_add_constraints` doesn't update `universe_causes` when creating new universes, causing an ICE. Remove it! Add spans to better track normalization constraints. Fix couple places where `universe_causes` is not updated correctly to track newly added universes. Fixes rust-lang#102800 ~Fixess rust-lang#99665~ (UPDATE: no longer true; the issue has a different failure path than when this PR was created and should be fixed by rust-lang#101708, but the changes in this PR are still correct and should prevent potential future ICEs)
- Loading branch information
Showing
6 changed files
with
150 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/test/ui/nll/closure-malformed-projection-input-issue-102800.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Regression test for #102800 | ||
// | ||
// Here we are generating higher-ranked region constraints when normalizing and relating closure | ||
// input types. Previously this was an ICE in the error path because we didn't register enough | ||
// diagnostic information to render the higher-ranked subtyping error. | ||
|
||
// check-fail | ||
|
||
trait Trait { | ||
type Ty; | ||
} | ||
|
||
impl Trait for &'static () { | ||
type Ty = (); | ||
} | ||
|
||
fn main() { | ||
let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; | ||
//~^ ERROR lifetime may not live long enough | ||
//~| ERROR higher-ranked subtype error | ||
//~| ERROR higher-ranked subtype error | ||
//~| ERROR implementation of `Trait` is not general enough | ||
//~| ERROR implementation of `Trait` is not general enough | ||
//~| ERROR implementation of `Trait` is not general enough | ||
//~| ERROR implementation of `Trait` is not general enough | ||
//~| ERROR implementation of `Trait` is not general enough | ||
//~| ERROR implementation of `Trait` is not general enough | ||
//~| ERROR implementation of `Trait` is not general enough | ||
//~| ERROR implementation of `Trait` is not general enough | ||
//~| ERROR implementation of `Trait` is not general enough | ||
} |
104 changes: 104 additions & 0 deletions
104
src/test/ui/nll/closure-malformed-projection-input-issue-102800.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 | ||
| | ||
LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; | ||
| ^-^ | ||
| || | ||
| |has type `<&'1 () as Trait>::Ty` | ||
| requires that `'1` must outlive `'static` | ||
|
||
error: higher-ranked subtype error | ||
--> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 | ||
| | ||
LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; | ||
| ^^^ | ||
|
||
error: higher-ranked subtype error | ||
--> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 | ||
| | ||
LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; | ||
| ^^^ | ||
|
||
error: implementation of `Trait` is not general enough | ||
--> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 | ||
| | ||
LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; | ||
| ^^^^^^ implementation of `Trait` is not general enough | ||
| | ||
= note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... | ||
= note: ...but `Trait` is actually implemented for the type `&'static ()` | ||
|
||
error: implementation of `Trait` is not general enough | ||
--> $DIR/closure-malformed-projection-input-issue-102800.rs:18:12 | ||
| | ||
LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Trait` is not general enough | ||
| | ||
= note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... | ||
= note: ...but `Trait` is actually implemented for the type `&'static ()` | ||
|
||
error: implementation of `Trait` is not general enough | ||
--> $DIR/closure-malformed-projection-input-issue-102800.rs:18:12 | ||
| | ||
LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Trait` is not general enough | ||
| | ||
= note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... | ||
= note: ...but `Trait` is actually implemented for the type `&'static ()` | ||
|
||
error: implementation of `Trait` is not general enough | ||
--> $DIR/closure-malformed-projection-input-issue-102800.rs:18:12 | ||
| | ||
LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Trait` is not general enough | ||
| | ||
= note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... | ||
= note: ...but `Trait` is actually implemented for the type `&'static ()` | ||
|
||
error: implementation of `Trait` is not general enough | ||
--> $DIR/closure-malformed-projection-input-issue-102800.rs:18:12 | ||
| | ||
LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Trait` is not general enough | ||
| | ||
= note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... | ||
= note: ...but `Trait` is actually implemented for the type `&'static ()` | ||
|
||
error: implementation of `Trait` is not general enough | ||
--> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 | ||
| | ||
LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; | ||
| ^^^^^^ implementation of `Trait` is not general enough | ||
| | ||
= note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... | ||
= note: ...but `Trait` is actually implemented for the type `&'static ()` | ||
|
||
error: implementation of `Trait` is not general enough | ||
--> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 | ||
| | ||
LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; | ||
| ^^^^^^ implementation of `Trait` is not general enough | ||
| | ||
= note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... | ||
= note: ...but `Trait` is actually implemented for the type `&'static ()` | ||
|
||
error: implementation of `Trait` is not general enough | ||
--> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 | ||
| | ||
LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; | ||
| ^^^^^^ implementation of `Trait` is not general enough | ||
| | ||
= note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... | ||
= note: ...but `Trait` is actually implemented for the type `&'static ()` | ||
|
||
error: implementation of `Trait` is not general enough | ||
--> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 | ||
| | ||
LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; | ||
| ^^^^^^ implementation of `Trait` is not general enough | ||
| | ||
= note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... | ||
= note: ...but `Trait` is actually implemented for the type `&'static ()` | ||
|
||
error: aborting due to 12 previous errors | ||
|