-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Treat weak alias types more like ADTs when computing implied bounds #122340
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
|
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() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ where | |
test_lifetime_param::Ty<'a>: 'static, | ||
{ | ||
test_lifetime_param::assert_static::<'a>() | ||
//~^ ERROR: lifetime may not live long enough | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👀 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is, but we need tests that show that we actually enforce it, too. I don't know if we have any weak alias type tests for that, even if we have old-style type alias tests for it |
||
} | ||
|
||
mod test_higher_kinded_lifetime_param { | ||
|
@@ -50,7 +49,6 @@ where | |
test_type_param::Ty<A>: 'static, | ||
{ | ||
test_type_param::assert_static::<A>() | ||
//~^ ERROR: parameter type `A` may not live long enough | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👀 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, |
||
} | ||
|
||
mod test_implied_from_fn_sig { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a drive-by renaming, cc #117908. I don't know why this used the term free (
ReLateParam
). It should've always been namedis_early_bound_region
or sth. in that vein.