-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat weak alias types more like ADTs when computing implied bounds
- Loading branch information
Showing
8 changed files
with
55 additions
and
61 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
11 changes: 11 additions & 0 deletions
11
tests/ui/lazy-type-alias/implied-outlives-bounds-1.print.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,11 @@ | ||
error: rustc_outlives | ||
--> $DIR/implied-outlives-bounds-1.rs:16:1 | ||
| | ||
LL | struct Type<'a, K, V>(&'a mut Alias<K, V>); | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: K: 'a | ||
= note: V: 'a | ||
|
||
error: aborting due to 1 previous error | ||
|
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,20 @@ | ||
// Check that we infer the outlives-predicates `K: 'a`, `V: 'a` for `Type` | ||
// from the weak alias `Alias`. | ||
// This mirrors the behavior of ADTs instead of other kinds of alias types | ||
// like projections and opaque types. | ||
// If we were to mirror the semantics of the latter, we would infer the | ||
// outlives-predicate `Alias<K, V>: 'a` instead which is not what we want. | ||
|
||
//@ revisions: default print | ||
//@[default] check-pass | ||
|
||
#![feature(lazy_type_alias)] | ||
#![cfg_attr(print, feature(rustc_attrs))] | ||
#![allow(incomplete_features)] | ||
|
||
#[cfg_attr(print, rustc_outlives)] | ||
struct Type<'a, K, V>(&'a mut Alias<K, V>); //[print]~ ERROR rustc_outlives | ||
|
||
type Alias<K, V> = (K, V); | ||
|
||
fn main() {} |
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
27 changes: 3 additions & 24 deletions
27
tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.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 |
---|---|---|
@@ -1,37 +1,16 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/implied_lifetime_wf_check3.rs:7:43 | ||
| | ||
LL | fn test<'a>() where Ty<'a>: 'static { assert_static::<'a>() } | ||
| -- lifetime `'a` defined here ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/implied_lifetime_wf_check3.rs:15:46 | ||
--> $DIR/implied_lifetime_wf_check3.rs:14:46 | ||
| | ||
LL | fn test<'a>() where for<'b> Ty<'b>: 'a { assert_static::<'a>() } | ||
| -- lifetime `'a` defined here ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/implied_lifetime_wf_check3.rs:21:21 | ||
--> $DIR/implied_lifetime_wf_check3.rs:20:21 | ||
| | ||
LL | fn test<'a>() { assert_static::<'a>() } | ||
| -- ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` | ||
| | | ||
| lifetime `'a` defined here | ||
|
||
error[E0310]: the parameter type `A` may not live long enough | ||
--> $DIR/implied_lifetime_wf_check3.rs:29:41 | ||
| | ||
LL | fn test<A>() where Ty<A>: 'static { assert_static::<A>() } | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| the parameter type `A` must be valid for the static lifetime... | ||
| ...so that the type `A` will meet its required lifetime bounds | ||
| | ||
help: consider adding an explicit lifetime bound | ||
| | ||
LL | fn test<A: 'static>() where Ty<A>: 'static { assert_static::<A>() } | ||
| +++++++++ | ||
|
||
error: aborting due to 4 previous errors | ||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0310`. |
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