-
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.
Auto merge of #116935 - oli-obk:different_lifetime_taits_in_same_sig,…
… r=<try> Prevent opaque types being instantiated twice with different regions within the same function addresses https://github.com/orgs/rust-lang/projects/22/views/1?pane=issue&itemId=41329537 r? `@compiler-errors`
- Loading branch information
Showing
10 changed files
with
182 additions
and
42 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,22 @@ | ||
#![feature(type_alias_impl_trait)] | ||
|
||
type Foo<'a> = impl Sized; | ||
|
||
fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> (Foo<'a>, Foo<'b>) { | ||
(x, y) | ||
//~^ ERROR opaque type used twice with different lifetimes | ||
} | ||
|
||
type Bar<'a, 'b> = impl std::fmt::Debug; | ||
|
||
fn bar<'x, 'y>(i: &'x i32, j: &'y i32) -> (Bar<'x, 'y>, Bar<'y, 'x>) { | ||
(i, j) | ||
//~^ ERROR opaque type used twice with different lifetimes | ||
//~| ERROR opaque type used twice with different lifetimes | ||
} | ||
|
||
fn main() { | ||
let meh = 42; | ||
let muh = 69; | ||
println!("{:?}", bar(&meh, &muh)); | ||
} |
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,47 @@ | ||
error: opaque type used twice with different lifetimes | ||
--> $DIR/lifetime_mismatch.rs:6:5 | ||
| | ||
LL | (x, y) | ||
| ^^^^^^ | ||
| | | ||
| lifetime `'a` used here | ||
| lifetime `'b` previously used here | ||
| | ||
note: if all non-lifetime generic parameters are the same, but the lifetime parameters differ, it is not possible to differentiate the opaque types. | ||
--> $DIR/lifetime_mismatch.rs:6:5 | ||
| | ||
LL | (x, y) | ||
| ^^^^^^ | ||
|
||
error: opaque type used twice with different lifetimes | ||
--> $DIR/lifetime_mismatch.rs:13:5 | ||
| | ||
LL | (i, j) | ||
| ^^^^^^ | ||
| | | ||
| lifetime `'x` used here | ||
| lifetime `'y` previously used here | ||
| | ||
note: if all non-lifetime generic parameters are the same, but the lifetime parameters differ, it is not possible to differentiate the opaque types. | ||
--> $DIR/lifetime_mismatch.rs:13:5 | ||
| | ||
LL | (i, j) | ||
| ^^^^^^ | ||
|
||
error: opaque type used twice with different lifetimes | ||
--> $DIR/lifetime_mismatch.rs:13:5 | ||
| | ||
LL | (i, j) | ||
| ^^^^^^ | ||
| | | ||
| lifetime `'y` used here | ||
| lifetime `'x` previously used here | ||
| | ||
note: if all non-lifetime generic parameters are the same, but the lifetime parameters differ, it is not possible to differentiate the opaque types. | ||
--> $DIR/lifetime_mismatch.rs:13:5 | ||
| | ||
LL | (i, j) | ||
| ^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
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
29 changes: 25 additions & 4 deletions
29
tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.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,11 +1,32 @@ | ||
error: concrete type differs from previous defining opaque type use | ||
error: opaque type used twice with different lifetimes | ||
--> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:5 | ||
| | ||
LL | (i, i) | ||
| ^^^^^^ | ||
| | | ||
| expected `&'a i32`, got `&'b i32` | ||
| this expression supplies two conflicting concrete types for the same opaque type | ||
| lifetime `'x` used here | ||
| lifetime `'y` previously used here | ||
| | ||
note: if all non-lifetime generic parameters are the same, but the lifetime parameters differ, it is not possible to differentiate the opaque types. | ||
--> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:5 | ||
| | ||
LL | (i, i) | ||
| ^^^^^^ | ||
|
||
error: opaque type used twice with different lifetimes | ||
--> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:5 | ||
| | ||
LL | (i, i) | ||
| ^^^^^^ | ||
| | | ||
| lifetime `'y` used here | ||
| lifetime `'x` previously used here | ||
| | ||
note: if all non-lifetime generic parameters are the same, but the lifetime parameters differ, it is not possible to differentiate the opaque types. | ||
--> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:5 | ||
| | ||
LL | (i, i) | ||
| ^^^^^^ | ||
|
||
error: aborting due to previous error | ||
error: aborting due to 2 previous errors | ||
|
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