diff options
| author | Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com> | 2022-10-31 11:45:11 +0300 |
|---|---|---|
| committer | Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com> | 2023-01-07 13:38:39 +0300 |
| commit | be5a45d39240ab3f6410c4808b0840142c657228 (patch) | |
| tree | 01431cdca81d374a6a4ac14f5a84a081dadc8287 /src/test | |
| parent | 34329d6f6c73a6f0080e169007d099a40db3aea1 (diff) | |
| download | rust-be5a45d39240ab3f6410c4808b0840142c657228.tar.gz rust-be5a45d39240ab3f6410c4808b0840142c657228.zip | |
fix struct path
Diffstat (limited to 'src/test')
5 files changed, 107 insertions, 38 deletions
diff --git a/src/test/ui/const-generics/issue-97007.rs b/src/test/ui/const-generics/issue-97007.rs index 7b9b9701ff1..7036834c4b1 100644 --- a/src/test/ui/const-generics/issue-97007.rs +++ b/src/test/ui/const-generics/issue-97007.rs @@ -1,8 +1,4 @@ -//~ ERROR broken MIR - -// known-bug -// failure-status: 101 -// rustc-env: RUSTC_BACKTRACE=0 +// check-pass #![feature(adt_const_params, generic_const_exprs)] #![allow(incomplete_features)] diff --git a/src/test/ui/nll/user-annotations/dump-adt-brace-struct.rs b/src/test/ui/nll/user-annotations/dump-adt-brace-struct.rs index 8a80958fc67..ccda9129dab 100644 --- a/src/test/ui/nll/user-annotations/dump-adt-brace-struct.rs +++ b/src/test/ui/nll/user-annotations/dump-adt-brace-struct.rs @@ -11,10 +11,8 @@ struct SomeStruct<T> { t: T } #[rustc_dump_user_substs] fn main() { SomeStruct { t: 22 }; // Nothing given, no annotation. - //~^ ERROR SomeStruct<^0> SomeStruct::<_> { t: 22 }; // Nothing interesting given, no annotation. - //~^ ERROR SomeStruct<^0> SomeStruct::<u32> { t: 22 }; // No lifetime bounds given. diff --git a/src/test/ui/nll/user-annotations/dump-adt-brace-struct.stderr b/src/test/ui/nll/user-annotations/dump-adt-brace-struct.stderr index b5adc584b28..5860621909c 100644 --- a/src/test/ui/nll/user-annotations/dump-adt-brace-struct.stderr +++ b/src/test/ui/nll/user-annotations/dump-adt-brace-struct.stderr @@ -1,20 +1,8 @@ -error: user substs: UserSubsts { substs: [^0], user_self_ty: Some(UserSelfTy { impl_def_id: DefId(0:3 ~ dump_adt_brace_struct[4679]::SomeStruct), self_ty: SomeStruct<^0> }) } - --> $DIR/dump-adt-brace-struct.rs:13:5 - | -LL | SomeStruct { t: 22 }; // Nothing given, no annotation. - | ^^^^^^^^^^^^^^^^^^^^ - -error: user substs: UserSubsts { substs: [^0], user_self_ty: Some(UserSelfTy { impl_def_id: DefId(0:3 ~ dump_adt_brace_struct[4679]::SomeStruct), self_ty: SomeStruct<^0> }) } - --> $DIR/dump-adt-brace-struct.rs:16:5 - | -LL | SomeStruct::<_> { t: 22 }; // Nothing interesting given, no annotation. - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: user substs: UserSubsts { substs: [&ReStatic u32], user_self_ty: Some(UserSelfTy { impl_def_id: DefId(0:3 ~ dump_adt_brace_struct[4679]::SomeStruct), self_ty: SomeStruct<&ReStatic u32> }) } - --> $DIR/dump-adt-brace-struct.rs:21:5 +error: user substs: UserSubsts { substs: [&ReStatic u32], user_self_ty: None } + --> $DIR/dump-adt-brace-struct.rs:19:5 | LL | SomeStruct::<&'static u32> { t: &22 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to previous error diff --git a/src/test/ui/nll/user-annotations/normalization-2.rs b/src/test/ui/nll/user-annotations/normalization-2.rs index 00e9eb651cd..92600155c7f 100644 --- a/src/test/ui/nll/user-annotations/normalization-2.rs +++ b/src/test/ui/nll/user-annotations/normalization-2.rs @@ -24,6 +24,7 @@ enum MyTy<T> { impl<T> MyTy<T> { fn method<X>() {} + fn method2<X>(&self) {} } type Ty<'a> = <&'a () as Trait>::Assoc; @@ -45,6 +46,9 @@ fn test_path<'a, 'b, 'c, 'd>() { //~^ ERROR lifetime may not live long enough <Ty<'static>>::method::<Ty<'b>>; //~^ ERROR lifetime may not live long enough + + MyTy::Unit::<Ty<'c>>; + //~^ ERROR lifetime may not live long enough } fn test_call<'a, 'b, 'c>() { @@ -55,7 +59,7 @@ fn test_call<'a, 'b, 'c>() { } fn test_variants<'a, 'b, 'c>() { - <Ty<'a>>::Struct {}; //TODO + <Ty<'a>>::Struct {}; //~^ ERROR lifetime may not live long enough <Ty<'b>>::Tuple(); //~^ ERROR lifetime may not live long enough @@ -63,6 +67,36 @@ fn test_variants<'a, 'b, 'c>() { //~^ ERROR lifetime may not live long enough } +fn test_method_call<'a>(x: MyTy<()>) { + // FIXME This should fail. + x.method2::<Ty<'a>>(); +} + +fn test_struct_path<'a, 'b, 'c, 'd>() { + struct Struct<T> { x: Option<T>, } + + trait Project { + type Struct; + type Enum; + } + impl<T> Project for T { + type Struct = Struct<()>; + type Enum = MyTy<()>; + } + + // Resolves to enum variant + MyTy::<Ty<'a>>::Struct {}; // without SelfTy + //~^ ERROR lifetime may not live long enough + <Ty<'b> as Project>::Enum::Struct {}; // with SelfTy + //~^ ERROR lifetime may not live long enough + + // Resolves to struct and associated type respectively + Struct::<Ty<'c>> { x: None, }; // without SelfTy + //~^ ERROR lifetime may not live long enough + <Ty<'d> as Project>::Struct { x: None, }; // with SelfTy + //~^ ERROR lifetime may not live long enough +} + fn test_pattern<'a, 'b, 'c>() { use MyTy::*; match MyTy::Unit { diff --git a/src/test/ui/nll/user-annotations/normalization-2.stderr b/src/test/ui/nll/user-annotations/normalization-2.stderr index 3c235171ef5..5dbdb2ecea8 100644 --- a/src/test/ui/nll/user-annotations/normalization-2.stderr +++ b/src/test/ui/nll/user-annotations/normalization-2.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/normalization-2.rs:32:12 + --> $DIR/normalization-2.rs:33:12 | LL | fn test_local<'a>() { | -- lifetime `'a` defined here @@ -7,7 +7,7 @@ LL | let _: Ty<'a> = MyTy::Unit; | ^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/normalization-2.rs:37:6 + --> $DIR/normalization-2.rs:38:6 | LL | fn test_closure_sig<'a, 'b>() { | -- lifetime `'a` defined here @@ -15,7 +15,7 @@ LL | |_: Ty<'a>| {}; | ^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/normalization-2.rs:39:11 + --> $DIR/normalization-2.rs:40:11 | LL | fn test_closure_sig<'a, 'b>() { | -- lifetime `'b` defined here @@ -29,7 +29,7 @@ help: the following changes may resolve your lifetime errors = help: replace `'b` with `'static` error: lifetime may not live long enough - --> $DIR/normalization-2.rs:44:5 + --> $DIR/normalization-2.rs:45:5 | LL | fn test_path<'a, 'b, 'c, 'd>() { | -- lifetime `'a` defined here @@ -37,7 +37,7 @@ LL | <Ty<'a>>::method::<Ty<'static>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/normalization-2.rs:46:5 + --> $DIR/normalization-2.rs:47:5 | LL | fn test_path<'a, 'b, 'c, 'd>() { | -- lifetime `'b` defined here @@ -45,13 +45,23 @@ LL | fn test_path<'a, 'b, 'c, 'd>() { LL | <Ty<'static>>::method::<Ty<'b>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` +error: lifetime may not live long enough + --> $DIR/normalization-2.rs:50:5 + | +LL | fn test_path<'a, 'b, 'c, 'd>() { + | -- lifetime `'c` defined here +... +LL | MyTy::Unit::<Ty<'c>>; + | ^^^^^^^^^^^^^^^^^^^^ requires that `'c` must outlive `'static` + help: the following changes may resolve your lifetime errors | = help: replace `'a` with `'static` = help: replace `'b` with `'static` + = help: replace `'c` with `'static` error: lifetime may not live long enough - --> $DIR/normalization-2.rs:51:5 + --> $DIR/normalization-2.rs:55:5 | LL | fn test_call<'a, 'b, 'c>() { | -- lifetime `'a` defined here @@ -59,7 +69,7 @@ LL | <Ty<'a>>::method::<Ty<'static>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/normalization-2.rs:53:5 + --> $DIR/normalization-2.rs:57:5 | LL | fn test_call<'a, 'b, 'c>() { | -- lifetime `'b` defined here @@ -73,15 +83,15 @@ help: the following changes may resolve your lifetime errors = help: replace `'b` with `'static` error: lifetime may not live long enough - --> $DIR/normalization-2.rs:58:5 + --> $DIR/normalization-2.rs:62:5 | LL | fn test_variants<'a, 'b, 'c>() { | -- lifetime `'a` defined here -LL | <Ty<'a>>::Struct {}; //TODO +LL | <Ty<'a>>::Struct {}; | ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/normalization-2.rs:60:5 + --> $DIR/normalization-2.rs:64:5 | LL | fn test_variants<'a, 'b, 'c>() { | -- lifetime `'b` defined here @@ -90,7 +100,7 @@ LL | <Ty<'b>>::Tuple(); | ^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` error: lifetime may not live long enough - --> $DIR/normalization-2.rs:62:5 + --> $DIR/normalization-2.rs:66:5 | LL | fn test_variants<'a, 'b, 'c>() { | -- lifetime `'c` defined here @@ -105,7 +115,50 @@ help: the following changes may resolve your lifetime errors = help: replace `'c` with `'static` error: lifetime may not live long enough - --> $DIR/normalization-2.rs:69:9 + --> $DIR/normalization-2.rs:88:5 + | +LL | fn test_struct_path<'a, 'b, 'c, 'd>() { + | -- lifetime `'a` defined here +... +LL | MyTy::<Ty<'a>>::Struct {}; // without SelfTy + | ^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/normalization-2.rs:90:5 + | +LL | fn test_struct_path<'a, 'b, 'c, 'd>() { + | -- lifetime `'b` defined here +... +LL | <Ty<'b> as Project>::Enum::Struct {}; // with SelfTy + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/normalization-2.rs:94:5 + | +LL | fn test_struct_path<'a, 'b, 'c, 'd>() { + | -- lifetime `'c` defined here +... +LL | Struct::<Ty<'c>> { x: None, }; // without SelfTy + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'c` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/normalization-2.rs:96:5 + | +LL | fn test_struct_path<'a, 'b, 'c, 'd>() { + | -- lifetime `'d` defined here +... +LL | <Ty<'d> as Project>::Struct { x: None, }; // with SelfTy + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'d` must outlive `'static` + +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + = help: replace `'b` with `'static` + = help: replace `'c` with `'static` + = help: replace `'d` with `'static` + +error: lifetime may not live long enough + --> $DIR/normalization-2.rs:103:9 | LL | fn test_pattern<'a, 'b, 'c>() { | -- lifetime `'a` defined here @@ -114,7 +167,7 @@ LL | Struct::<Ty<'a>> {..} => {}, | ^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/normalization-2.rs:71:9 + --> $DIR/normalization-2.rs:105:9 | LL | fn test_pattern<'a, 'b, 'c>() { | -- lifetime `'b` defined here @@ -123,7 +176,7 @@ LL | Tuple::<Ty<'b>> (..) => {}, | ^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` error: lifetime may not live long enough - --> $DIR/normalization-2.rs:73:9 + --> $DIR/normalization-2.rs:107:9 | LL | fn test_pattern<'a, 'b, 'c>() { | -- lifetime `'c` defined here @@ -137,5 +190,5 @@ help: the following changes may resolve your lifetime errors = help: replace `'b` with `'static` = help: replace `'c` with `'static` -error: aborting due to 13 previous errors +error: aborting due to 18 previous errors |
