forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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=e…
…stebank 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#99665
- Loading branch information
Showing
6 changed files
with
138 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
52 changes: 52 additions & 0 deletions
52
src/test/ui/nll/closure-malformed-projection-input-issue-99665.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,52 @@ | ||
// Regression test for #99665 | ||
// | ||
// Here we are generating region constraints | ||
// when normalizing input types of the closure. | ||
|
||
// check-fail | ||
|
||
pub trait MyComponent { | ||
type Properties; | ||
} | ||
|
||
struct Ty1<T>(T); | ||
struct Ty2<T>(T); | ||
|
||
impl<M> MyComponent for Ty1<M> | ||
where | ||
M: 'static, | ||
{ | ||
type Properties = (); | ||
} | ||
|
||
impl<M> MyComponent for Ty2<M> | ||
where | ||
M: 'static, | ||
{ | ||
type Properties = &'static M; | ||
} | ||
|
||
fn fail() { | ||
// This should fail because `Ty1<&u8>` is inferred to be higher-ranked. | ||
// So effectively we're trying to prove `for<'a> Ty1<&'a u8>: MyComponent`. | ||
|_: <Ty1<&u8> as MyComponent>::Properties| {}; | ||
//~^ ERROR lifetime may not live long enough | ||
//~| ERROR higher-ranked subtype error | ||
//~| ERROR higher-ranked lifetime error | ||
//~| ERROR higher-ranked lifetime error | ||
//~| ERROR higher-ranked lifetime error | ||
|
||
|_: <Ty2<&u8> as MyComponent>::Properties| {}; | ||
//~^ ERROR higher-ranked subtype error | ||
//~| ERROR higher-ranked lifetime error | ||
//~| ERROR higher-ranked lifetime error | ||
//~| ERROR higher-ranked lifetime error | ||
} | ||
|
||
fn pass() { | ||
// Here both are not higher-ranked, so they sould pass. | ||
|| -> <Ty1<&u8> as MyComponent>::Properties { panic!() }; | ||
|| -> <Ty2<&u8> as MyComponent>::Properties { panic!() }; | ||
} | ||
|
||
fn main() {} |
71 changes: 71 additions & 0 deletions
71
src/test/ui/nll/closure-malformed-projection-input-issue-99665.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,71 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/closure-malformed-projection-input-issue-99665.rs:32:5 | ||
| | ||
LL | |_: <Ty1<&u8> as MyComponent>::Properties| {}; | ||
| ^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| || | ||
| |has type `<Ty1<&'1 u8> as MyComponent>::Properties` | ||
| requires that `'1` must outlive `'static` | ||
|
||
error: higher-ranked subtype error | ||
--> $DIR/closure-malformed-projection-input-issue-99665.rs:32:5 | ||
| | ||
LL | |_: <Ty1<&u8> as MyComponent>::Properties| {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: higher-ranked lifetime error | ||
--> $DIR/closure-malformed-projection-input-issue-99665.rs:32:5 | ||
| | ||
LL | |_: <Ty1<&u8> as MyComponent>::Properties| {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: could not normalize `&[closure@$DIR/closure-malformed-projection-input-issue-99665.rs:32:5: 32:47]` | ||
|
||
error: higher-ranked subtype error | ||
--> $DIR/closure-malformed-projection-input-issue-99665.rs:39:5 | ||
| | ||
LL | |_: <Ty2<&u8> as MyComponent>::Properties| {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: higher-ranked lifetime error | ||
--> $DIR/closure-malformed-projection-input-issue-99665.rs:39:5 | ||
| | ||
LL | |_: <Ty2<&u8> as MyComponent>::Properties| {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: could not normalize `&[closure@$DIR/closure-malformed-projection-input-issue-99665.rs:39:5: 39:47]` | ||
|
||
error: higher-ranked lifetime error | ||
--> $DIR/closure-malformed-projection-input-issue-99665.rs:32:5 | ||
| | ||
LL | |_: <Ty1<&u8> as MyComponent>::Properties| {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: could not normalize `[closure@$DIR/closure-malformed-projection-input-issue-99665.rs:32:5: 32:47]` | ||
|
||
error: higher-ranked lifetime error | ||
--> $DIR/closure-malformed-projection-input-issue-99665.rs:32:5 | ||
| | ||
LL | |_: <Ty1<&u8> as MyComponent>::Properties| {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: could not normalize `[closure@$DIR/closure-malformed-projection-input-issue-99665.rs:32:5: 32:47]` | ||
|
||
error: higher-ranked lifetime error | ||
--> $DIR/closure-malformed-projection-input-issue-99665.rs:39:5 | ||
| | ||
LL | |_: <Ty2<&u8> as MyComponent>::Properties| {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: could not normalize `[closure@$DIR/closure-malformed-projection-input-issue-99665.rs:39:5: 39:47]` | ||
|
||
error: higher-ranked lifetime error | ||
--> $DIR/closure-malformed-projection-input-issue-99665.rs:39:5 | ||
| | ||
LL | |_: <Ty2<&u8> as MyComponent>::Properties| {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: could not normalize `[closure@$DIR/closure-malformed-projection-input-issue-99665.rs:39:5: 39:47]` | ||
|
||
error: aborting due to 9 previous errors | ||
|