From 2e4e98335662dd0636338a0dfbbaf234f7ed473b Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 15 Oct 2018 06:14:08 -0400 Subject: [PATCH] update tests --- .../dump-adt-brace-struct.stderr | 2 +- .../user-annotations/dump-fn-method.stderr | 8 ++--- .../method-ufcs-inherent-1.rs | 19 ++++++++++++ .../method-ufcs-inherent-1.stderr | 17 ++++++++++ .../method-ufcs-inherent-2.rs | 19 ++++++++++++ .../method-ufcs-inherent-2.stderr | 31 +++++++++++++++++++ .../method-ufcs-inherent-3.rs | 19 ++++++++++++ .../method-ufcs-inherent-3.stderr | 17 ++++++++++ .../method-ufcs-inherent-4.rs | 20 ++++++++++++ .../method-ufcs-inherent-4.stderr | 31 +++++++++++++++++++ 10 files changed, 178 insertions(+), 5 deletions(-) create mode 100644 src/test/ui/nll/user-annotations/method-ufcs-inherent-1.rs create mode 100644 src/test/ui/nll/user-annotations/method-ufcs-inherent-1.stderr create mode 100644 src/test/ui/nll/user-annotations/method-ufcs-inherent-2.rs create mode 100644 src/test/ui/nll/user-annotations/method-ufcs-inherent-2.stderr create mode 100644 src/test/ui/nll/user-annotations/method-ufcs-inherent-3.rs create mode 100644 src/test/ui/nll/user-annotations/method-ufcs-inherent-3.stderr create mode 100644 src/test/ui/nll/user-annotations/method-ufcs-inherent-4.rs create mode 100644 src/test/ui/nll/user-annotations/method-ufcs-inherent-4.stderr 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 2b0e5039d8d4..901ace59d33a 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,4 +1,4 @@ -error: user substs: Canonical { variables: [], value: [u32] } +error: user substs: Canonical { variables: [], value: UserSubsts { substs: [u32], user_self_ty: None } } --> $DIR/dump-adt-brace-struct.rs:28:5 | LL | SomeStruct:: { t: 22 }; //~ ERROR [u32] diff --git a/src/test/ui/nll/user-annotations/dump-fn-method.stderr b/src/test/ui/nll/user-annotations/dump-fn-method.stderr index 6531f87dd987..a26be359fc4a 100644 --- a/src/test/ui/nll/user-annotations/dump-fn-method.stderr +++ b/src/test/ui/nll/user-annotations/dump-fn-method.stderr @@ -1,22 +1,22 @@ -error: user substs: Canonical { variables: [], value: [u32] } +error: user substs: Canonical { variables: [], value: UserSubsts { substs: [u32], user_self_ty: None } } --> $DIR/dump-fn-method.rs:36:13 | LL | let x = foo::; //~ ERROR [u32] | ^^^^^^^^^^ -error: user substs: Canonical { variables: [CanonicalVarInfo { kind: Ty(General) }, CanonicalVarInfo { kind: Ty(General) }], value: [?0, u32, ?1] } +error: user substs: Canonical { variables: [CanonicalVarInfo { kind: Ty(General) }, CanonicalVarInfo { kind: Ty(General) }], value: UserSubsts { substs: [?0, u32, ?1], user_self_ty: None } } --> $DIR/dump-fn-method.rs:42:13 | LL | let x = <_ as Bazoom>::method::<_>; //~ ERROR [?0, u32, ?1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: user substs: Canonical { variables: [], value: [u8, u16, u32] } +error: user substs: Canonical { variables: [], value: UserSubsts { substs: [u8, u16, u32], user_self_ty: None } } --> $DIR/dump-fn-method.rs:46:13 | LL | let x = >::method::; //~ ERROR [u8, u16, u32] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: user substs: Canonical { variables: [CanonicalVarInfo { kind: Ty(General) }, CanonicalVarInfo { kind: Ty(General) }], value: [?0, ?1, u32] } +error: user substs: Canonical { variables: [CanonicalVarInfo { kind: Ty(General) }, CanonicalVarInfo { kind: Ty(General) }], value: UserSubsts { substs: [?0, ?1, u32], user_self_ty: None } } --> $DIR/dump-fn-method.rs:54:5 | LL | y.method::(44, 66); //~ ERROR [?0, ?1, u32] diff --git a/src/test/ui/nll/user-annotations/method-ufcs-inherent-1.rs b/src/test/ui/nll/user-annotations/method-ufcs-inherent-1.rs new file mode 100644 index 000000000000..4bca114e953f --- /dev/null +++ b/src/test/ui/nll/user-annotations/method-ufcs-inherent-1.rs @@ -0,0 +1,19 @@ +#![feature(nll)] + +// Check that substitutions given on the self type (here, `A`) carry +// through to NLL. + +struct A<'a> { x: &'a u32 } + +impl<'a> A<'a> { + fn new<'b, T>(x: &'a u32, y: T) -> Self { + Self { x } + } +} + +fn foo<'a>() { + let v = 22; + let x = A::<'a>::new(&v, 22); +} + +fn main() {} diff --git a/src/test/ui/nll/user-annotations/method-ufcs-inherent-1.stderr b/src/test/ui/nll/user-annotations/method-ufcs-inherent-1.stderr new file mode 100644 index 000000000000..68a7684c963f --- /dev/null +++ b/src/test/ui/nll/user-annotations/method-ufcs-inherent-1.stderr @@ -0,0 +1,17 @@ +error[E0597]: `v` does not live long enough + --> $DIR/method-ufcs-inherent-1.rs:16:26 + | +LL | let x = A::<'a>::new(&v, 22); + | ^^ borrowed value does not live long enough +LL | } + | - `v` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:8... + --> $DIR/method-ufcs-inherent-1.rs:14:8 + | +LL | fn foo<'a>() { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/user-annotations/method-ufcs-inherent-2.rs b/src/test/ui/nll/user-annotations/method-ufcs-inherent-2.rs new file mode 100644 index 000000000000..f87f5cba3915 --- /dev/null +++ b/src/test/ui/nll/user-annotations/method-ufcs-inherent-2.rs @@ -0,0 +1,19 @@ +#![feature(nll)] + +// Check that substitutions given on the self type (here, `A`) can be +// used in combination with annotations given for method arguments. + +struct A<'a> { x: &'a u32 } + +impl<'a> A<'a> { + fn new<'b, T>(x: &'a u32, y: T) -> Self { + Self { x } + } +} + +fn foo<'a>() { + let v = 22; + let x = A::<'a>::new::<&'a u32>(&v, &v); +} + +fn main() {} diff --git a/src/test/ui/nll/user-annotations/method-ufcs-inherent-2.stderr b/src/test/ui/nll/user-annotations/method-ufcs-inherent-2.stderr new file mode 100644 index 000000000000..0bdff99da9ee --- /dev/null +++ b/src/test/ui/nll/user-annotations/method-ufcs-inherent-2.stderr @@ -0,0 +1,31 @@ +error[E0597]: `v` does not live long enough + --> $DIR/method-ufcs-inherent-2.rs:16:37 + | +LL | let x = A::<'a>::new::<&'a u32>(&v, &v); + | ^^ borrowed value does not live long enough +LL | } + | - `v` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:8... + --> $DIR/method-ufcs-inherent-2.rs:14:8 + | +LL | fn foo<'a>() { + | ^^ + +error[E0597]: `v` does not live long enough + --> $DIR/method-ufcs-inherent-2.rs:16:41 + | +LL | let x = A::<'a>::new::<&'a u32>(&v, &v); + | ^^ borrowed value does not live long enough +LL | } + | - `v` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:8... + --> $DIR/method-ufcs-inherent-2.rs:14:8 + | +LL | fn foo<'a>() { + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/user-annotations/method-ufcs-inherent-3.rs b/src/test/ui/nll/user-annotations/method-ufcs-inherent-3.rs new file mode 100644 index 000000000000..d8376e4bdc47 --- /dev/null +++ b/src/test/ui/nll/user-annotations/method-ufcs-inherent-3.rs @@ -0,0 +1,19 @@ +#![feature(nll)] + +// Check that inherent methods invoked with `::new` style +// carry their annotations through to NLL. + +struct A<'a> { x: &'a u32 } + +impl<'a> A<'a> { + fn new<'b, T>(x: &'a u32, y: T) -> Self { + Self { x } + } +} + +fn foo<'a>() { + let v = 22; + let x = >::new(&v, 22); +} + +fn main() {} diff --git a/src/test/ui/nll/user-annotations/method-ufcs-inherent-3.stderr b/src/test/ui/nll/user-annotations/method-ufcs-inherent-3.stderr new file mode 100644 index 000000000000..122b26c72b23 --- /dev/null +++ b/src/test/ui/nll/user-annotations/method-ufcs-inherent-3.stderr @@ -0,0 +1,17 @@ +error[E0597]: `v` does not live long enough + --> $DIR/method-ufcs-inherent-3.rs:16:26 + | +LL | let x = >::new(&v, 22); + | ^^ borrowed value does not live long enough +LL | } + | - `v` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:8... + --> $DIR/method-ufcs-inherent-3.rs:14:8 + | +LL | fn foo<'a>() { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/user-annotations/method-ufcs-inherent-4.rs b/src/test/ui/nll/user-annotations/method-ufcs-inherent-4.rs new file mode 100644 index 000000000000..e0fb9cedd37d --- /dev/null +++ b/src/test/ui/nll/user-annotations/method-ufcs-inherent-4.rs @@ -0,0 +1,20 @@ +#![feature(nll)] + +// Check that inherent methods invoked with `::new` style +// carry their annotations through to NLL in connection with +// method type parameters. + +struct A<'a> { x: &'a u32 } + +impl<'a> A<'a> { + fn new<'b, T>(x: &'a u32, y: T) -> Self { + Self { x } + } +} + +fn foo<'a>() { + let v = 22; + let x = >::new::<&'a u32>(&v, &v); +} + +fn main() {} diff --git a/src/test/ui/nll/user-annotations/method-ufcs-inherent-4.stderr b/src/test/ui/nll/user-annotations/method-ufcs-inherent-4.stderr new file mode 100644 index 000000000000..b2f4066b2e86 --- /dev/null +++ b/src/test/ui/nll/user-annotations/method-ufcs-inherent-4.stderr @@ -0,0 +1,31 @@ +error[E0597]: `v` does not live long enough + --> $DIR/method-ufcs-inherent-4.rs:17:37 + | +LL | let x = >::new::<&'a u32>(&v, &v); + | ^^ borrowed value does not live long enough +LL | } + | - `v` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 15:8... + --> $DIR/method-ufcs-inherent-4.rs:15:8 + | +LL | fn foo<'a>() { + | ^^ + +error[E0597]: `v` does not live long enough + --> $DIR/method-ufcs-inherent-4.rs:17:41 + | +LL | let x = >::new::<&'a u32>(&v, &v); + | ^^ borrowed value does not live long enough +LL | } + | - `v` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 15:8... + --> $DIR/method-ufcs-inherent-4.rs:15:8 + | +LL | fn foo<'a>() { + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`.