forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
don't eagerly normalize SelfCtor type
Delay until user annotations are registered. See the added test.
- Loading branch information
Showing
8 changed files
with
148 additions
and
36 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// check-fail | ||
|
||
trait Trait { type Assoc; } | ||
impl<'a> Trait for &'a () { type Assoc = &'a (); } | ||
|
||
struct MyTuple<T, U = <&'static () as Trait>::Assoc>(T, U); | ||
fn test_tuple(x: &(), y: &()) { | ||
MyTuple::<_>((), x); | ||
//~^ ERROR | ||
let _: MyTuple::<_> = MyTuple((), y); | ||
//~^ ERROR | ||
} | ||
|
||
struct MyStruct<T, U = <&'static () as Trait>::Assoc> { val: (T, U), } | ||
fn test_struct(x: &(), y: &()) { | ||
MyStruct::<_> { val: ((), x) }; | ||
//~^ ERROR | ||
let _: MyStruct::<_> = MyStruct { val: ((), y) }; | ||
//~^ ERROR | ||
} | ||
|
||
fn main() {} |
36 changes: 36 additions & 0 deletions
36
src/test/ui/nll/user-annotations/normalization-default.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,36 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/normalization-default.rs:8:22 | ||
| | ||
LL | fn test_tuple(x: &(), y: &()) { | ||
| - let's call the lifetime of this reference `'1` | ||
LL | MyTuple::<_>((), x); | ||
| ^ this usage requires that `'1` must outlive `'static` | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/normalization-default.rs:10:12 | ||
| | ||
LL | fn test_tuple(x: &(), y: &()) { | ||
| - let's call the lifetime of this reference `'2` | ||
... | ||
LL | let _: MyTuple::<_> = MyTuple((), y); | ||
| ^^^^^^^^^^^^ type annotation requires that `'2` must outlive `'static` | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/normalization-default.rs:16:26 | ||
| | ||
LL | fn test_struct(x: &(), y: &()) { | ||
| - let's call the lifetime of this reference `'1` | ||
LL | MyStruct::<_> { val: ((), x) }; | ||
| ^^^^^^^ this usage requires that `'1` must outlive `'static` | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/normalization-default.rs:18:12 | ||
| | ||
LL | fn test_struct(x: &(), y: &()) { | ||
| - let's call the lifetime of this reference `'2` | ||
... | ||
LL | let _: MyStruct::<_> = MyStruct { val: ((), y) }; | ||
| ^^^^^^^^^^^^^ type annotation requires that `'2` must outlive `'static` | ||
|
||
error: aborting due to 4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// check-fail | ||
|
||
trait Trait { type Assoc; } | ||
impl<'a> Trait for &'a () { type Assoc = &'a (); } | ||
|
||
struct MyTuple<T>(T); | ||
impl MyTuple<<&'static () as Trait>::Assoc> { | ||
fn test(x: &(), y: &()) { | ||
Self(x); | ||
//~^ ERROR | ||
let _: Self = MyTuple(y); | ||
//~^ ERROR | ||
} | ||
} | ||
|
||
struct MyStruct<T> { val: T, } | ||
impl MyStruct<<&'static () as Trait>::Assoc> { | ||
fn test(x: &(), y: &()) { | ||
Self { val: x }; | ||
//~^ ERROR | ||
let _: Self = MyStruct { val: y }; | ||
//~^ ERROR | ||
} | ||
} | ||
|
||
fn main() {} |
36 changes: 36 additions & 0 deletions
36
src/test/ui/nll/user-annotations/normalization-self.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,36 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/normalization-self.rs:9:14 | ||
| | ||
LL | fn test(x: &(), y: &()) { | ||
| - let's call the lifetime of this reference `'1` | ||
LL | Self(x); | ||
| ^ this usage requires that `'1` must outlive `'static` | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/normalization-self.rs:11:16 | ||
| | ||
LL | fn test(x: &(), y: &()) { | ||
| - let's call the lifetime of this reference `'2` | ||
... | ||
LL | let _: Self = MyTuple(y); | ||
| ^^^^ type annotation requires that `'2` must outlive `'static` | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/normalization-self.rs:19:21 | ||
| | ||
LL | fn test(x: &(), y: &()) { | ||
| - let's call the lifetime of this reference `'1` | ||
LL | Self { val: x }; | ||
| ^ this usage requires that `'1` must outlive `'static` | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/normalization-self.rs:21:16 | ||
| | ||
LL | fn test(x: &(), y: &()) { | ||
| - let's call the lifetime of this reference `'2` | ||
... | ||
LL | let _: Self = MyStruct { val: y }; | ||
| ^^^^ type annotation requires that `'2` must outlive `'static` | ||
|
||
error: aborting due to 4 previous errors | ||
|