Skip to content
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

Add a regression test for issue-85113 #86248

Merged
merged 1 commit into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/test/ui/type-alias-impl-trait/issue-85113.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#![feature(min_type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]
#![allow(incomplete_features)]

type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
//~^ ERROR: hidden type for `impl Trait` captures lifetime that does not appear in bounds
//~| ERROR: the type `&'<empty> str` does not fulfill the required lifetime
//~| ERROR: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements

trait Output<'a> {}

impl<'a> Output<'a> for &'a str {}

fn cool_fn<'a>(arg: &'a str) -> OpaqueOutputImpl<'a> {
let out: OpaqueOutputImpl<'a> = arg;
arg
}

fn main() {
let s = String::from("wassup");
cool_fn(&s);
}
48 changes: 48 additions & 0 deletions src/test/ui/type-alias-impl-trait/issue-85113.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
--> $DIR/issue-85113.rs:5:29
|
LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
| ^^^^^^^^^^^^^^^^^^^^
|
note: hidden type `&'<empty> str` captures lifetime smaller than the function body
--> $DIR/issue-85113.rs:5:29
|
LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
| ^^^^^^^^^^^^^^^^^^^^

error[E0477]: the type `&'<empty> str` does not fulfill the required lifetime
--> $DIR/issue-85113.rs:5:29
|
LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
| ^^^^^^^^^^^^^^^^^^^^
|
note: type must outlive the lifetime `'a` as defined on the item at 5:23
--> $DIR/issue-85113.rs:5:23
|
LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
| ^^

error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
--> $DIR/issue-85113.rs:5:29
|
LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
| ^^^^^^^^^^^^^^^^^^^^
|
= note: first, the lifetime cannot outlive the empty lifetime...
note: ...but the lifetime must also be valid for the lifetime `'a` as defined on the item at 5:23...
--> $DIR/issue-85113.rs:5:23
|
LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
| ^^
note: ...so that the types are compatible
--> $DIR/issue-85113.rs:5:29
|
LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
| ^^^^^^^^^^^^^^^^^^^^
= note: expected `Output<'a>`
found `Output<'_>`

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0477, E0495, E0700.
For more information about an error, try `rustc --explain E0477`.