Uh oh!
There was an error while loading. Please reload this page.
Opaque types' generic params do not imply anything about their hidden type's lifetimes - #98933
Conversation
rust-highfive
commented
Jul 5, 2022
r? @cjgillot (rust-highfive has picked a reviewer for you, use r? to override) |
aliemjay
left a comment
There was a problem hiding this comment.
Looks good. Thanks!
I'm thinking if we should consider forcing the hidden type to constrain all generic params of the type alias in TAIT. If so, we won't have such weird differences between opaque types Adts. I'll discuss it further in a zulip stream https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/generic.20TAIT.20problems/near/286519266
Uh oh!
There was an error while loading. Please reload this page.
cjgillot
commented
Jul 5, 2022
r? rust-lang/types |
don't fully understand whether this is the correct fix, not sure whether #97104 has a meaningful relation to impl trait 😅 the ub here doesn't rely on impl trait at all. traitFoo<ARG:'static>:'static{typeAssoc:AsRef<str>;}fnhr_shit<T: ?Sized,ARG>(x:T::Assoc) -> Box<dynAsRef<str> + 'static>whereT:Foo<ARG>{Box::new(x)}fnextend_lt<'a>(x:&'astr) -> Box<dynAsRef<str> + 'static>{typeDynTrait = dynfor<'a>Foo<&'astr,Assoc = &'astr>;hr_shit::<DynTrait,_>(x)}fnmain(){let extended = extend_lt(&String::from("hello"));println!("{}", extended.as_ref().as_ref());}I think we already have an issue for this? edit: I think that's #44454 |
bors
commented
Jul 6, 2022
☔ The latest upstream changes (presumably #98206) made this pull request unmergeable. Please resolve the merge conflicts. |
@lcnr I believe the your reduced example is a separate problem, completely orthogonal to the one in hand. The type Meanwhile, the type from your example |
lcnr
left a comment
There was a problem hiding this comment.
seems good, so after my nits are dealt with, r=me
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
why is the note "lifetimes appearing in an associated type are not considered constrained" not emitted here?
There was a problem hiding this comment.
We're not checking for higher kinded lifetimes in the diagnostic, we're just checking for names. It would be a larger refactoring to handle the difference between lifetimes on the type alias and lifetimes in a binder.
08441cb to
64d11fcCompareoli-obk
commented
Sep 8, 2022
@bors r=lcnr |
bors
commented
Sep 8, 2022
…times, r=lcnr Opaque types' generic params do not imply anything about their hidden type's lifetimes fixesrust-lang#97104 cc `@aliemjay`
…times, r=lcnr Opaque types' generic params do not imply anything about their hidden type's lifetimes fixesrust-lang#97104 cc ``@aliemjay``
Rollup of 7 pull requests Successful merges: - rust-lang#98933 (Opaque types' generic params do not imply anything about their hidden type's lifetimes) - rust-lang#101041 (translations(rustc_session): migrates rustc_session to use SessionDiagnostic - Pt. 2) - rust-lang#101424 (Adjust and slightly generalize operator error suggestion) - rust-lang#101496 (Allow lower_lifetime_binder receive a closure) - rust-lang#101501 (Allow lint passes to be bound by `TyCtxt`) - rust-lang#101515 (Recover from typo where == is used in place of =) - rust-lang#101545 (Remove unnecessary `PartialOrd` and `Ord`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 7 pull requests Successful merges: - rust-lang#98933 (Opaque types' generic params do not imply anything about their hidden type's lifetimes) - rust-lang#101041 (translations(rustc_session): migrates rustc_session to use SessionDiagnostic - Pt. 2) - rust-lang#101424 (Adjust and slightly generalize operator error suggestion) - rust-lang#101496 (Allow lower_lifetime_binder receive a closure) - rust-lang#101501 (Allow lint passes to be bound by `TyCtxt`) - rust-lang#101515 (Recover from typo where == is used in place of =) - rust-lang#101545 (Remove unnecessary `PartialOrd` and `Ord`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
fixes#97104
cc @aliemjay