diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2018-08-09 12:32:00 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2018-08-24 13:27:38 -0400 |
| commit | f8653006d3f714348f05195e2597040aa3acf916 (patch) | |
| tree | 4535ec318acbb73e2a853266804e99a17662264b | |
| parent | 05c1b89308dc92cf05deb6bc3c051346006be80c (diff) | |
| download | rust-f8653006d3f714348f05195e2597040aa3acf916.tar.gz rust-f8653006d3f714348f05195e2597040aa3acf916.zip | |
ufcs with annot in position 1 and 2
| -rw-r--r-- | src/test/ui/nll/user-annotations/method-ufcs-1.rs | 75 | ||||
| -rw-r--r-- | src/test/ui/nll/user-annotations/method-ufcs-1.stderr | 45 | ||||
| -rw-r--r-- | src/test/ui/nll/user-annotations/method-ufcs-2.rs | 75 | ||||
| -rw-r--r-- | src/test/ui/nll/user-annotations/method-ufcs-2.stderr | 45 |
4 files changed, 240 insertions, 0 deletions
diff --git a/src/test/ui/nll/user-annotations/method-ufcs-1.rs b/src/test/ui/nll/user-annotations/method-ufcs-1.rs new file mode 100644 index 00000000000..5ac2ba5fa48 --- /dev/null +++ b/src/test/ui/nll/user-annotations/method-ufcs-1.rs @@ -0,0 +1,75 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Unit test for the "user substitutions" that are annotated on each +// node. + +#![feature(nll)] + +trait Bazoom<T>: Sized { + fn method<U>(self, arg: T, arg2: U) { } +} + +impl<T, U> Bazoom<U> for T { +} + +fn annot_underscore() { + let a = 22; + let b = 44; + let c = 66; + <_ as Bazoom<_>>::method::<_>(&a, b, c); // OK +} + +fn annot_reference_any_lifetime() { + let a = 22; + let b = 44; + let c = 66; + <&u32 as Bazoom<_>>::method(&a, b, c); // OK +} + +fn annot_reference_static_lifetime() { + let a = 22; + let b = 44; + let c = 66; + let x = <&'static u32 as Bazoom<_>>::method; + x(&a, b, c); //~ ERROR +} + +fn annot_reference_named_lifetime<'a>(_d: &'a u32) { + let a = 22; + let b = 44; + let c = 66; + <&'a u32 as Bazoom<_>>::method(&a, b, c); //~ ERROR +} + +fn annot_reference_named_lifetime_ok<'a>(a: &'a u32) { + let b = 44; + let c = 66; + <&'a u32 as Bazoom<_>>::method(&a, b, c); +} + +fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { + let a = 22; + let b = 44; + let _closure = || { + let c = 66; + <&'a u32 as Bazoom<_>>::method(&a, b, c); //~ ERROR + }; +} + +fn annot_reference_named_lifetime_in_closure_ok<'a>(a: &'a u32) { + let b = 44; + let c = 66; + let _closure = || { + <&'a u32 as Bazoom<_>>::method(&a, b, c); + }; +} + +fn main() { } diff --git a/src/test/ui/nll/user-annotations/method-ufcs-1.stderr b/src/test/ui/nll/user-annotations/method-ufcs-1.stderr new file mode 100644 index 00000000000..f439748ef97 --- /dev/null +++ b/src/test/ui/nll/user-annotations/method-ufcs-1.stderr @@ -0,0 +1,45 @@ +error[E0597]: `a` does not live long enough + --> $DIR/method-ufcs-1.rs:42:7 + | +LL | x(&a, b, c); //~ ERROR + | ^^ borrowed value does not live long enough +LL | } + | - `a` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: `a` does not live long enough + --> $DIR/method-ufcs-1.rs:49:36 + | +LL | <&'a u32 as Bazoom<_>>::method(&a, b, c); //~ ERROR + | ^^ borrowed value does not live long enough +LL | } + | - `a` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 45:35... + --> $DIR/method-ufcs-1.rs:45:35 + | +LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { + | ^^ + +error[E0597]: `a` does not live long enough + --> $DIR/method-ufcs-1.rs:63:41 + | +LL | let _closure = || { + | -- value captured here +LL | let c = 66; +LL | <&'a u32 as Bazoom<_>>::method(&a, b, c); //~ ERROR + | ^ borrowed value does not live long enough +LL | }; +LL | } + | - `a` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 58:46... + --> $DIR/method-ufcs-1.rs:58:46 + | +LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { + | ^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/user-annotations/method-ufcs-2.rs b/src/test/ui/nll/user-annotations/method-ufcs-2.rs new file mode 100644 index 00000000000..082cc561ae7 --- /dev/null +++ b/src/test/ui/nll/user-annotations/method-ufcs-2.rs @@ -0,0 +1,75 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Unit test for the "user substitutions" that are annotated on each +// node. + +#![feature(nll)] + +trait Bazoom<T>: Sized { + fn method<U>(self, arg: T, arg2: U) { } +} + +impl<T, U> Bazoom<U> for T { +} + +fn annot_underscore() { + let a = 22; + let b = 44; + let c = 66; + <_ as Bazoom<_>>::method(a, &b, c); // OK +} + +fn annot_reference_any_lifetime() { + let a = 22; + let b = 44; + let c = 66; + <_ as Bazoom<&u32>>::method(a, &b, c); // OK +} + +fn annot_reference_static_lifetime() { + let a = 22; + let b = 44; + let c = 66; + let x = <&'static u32 as Bazoom<_>>::method; + x(&a, b, c); //~ ERROR +} + +fn annot_reference_named_lifetime<'a>(_d: &'a u32) { + let a = 22; + let b = 44; + let c = 66; + <_ as Bazoom<&'a u32>>::method(a, &b, c); //~ ERROR +} + +fn annot_reference_named_lifetime_ok<'a>(b: &'a u32) { + let a = 44; + let c = 66; + <_ as Bazoom<&'a u32>>::method(a, &b, c); +} + +fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { + let a = 22; + let b = 44; + let _closure = || { + let c = 66; + <_ as Bazoom<&'a u32>>::method(a, &b, c); //~ ERROR + }; +} + +fn annot_reference_named_lifetime_in_closure_ok<'a>(b: &'a u32) { + let a = 44; + let c = 66; + let _closure = || { + <_ as Bazoom<&'a u32>>::method(a, &b, c); + }; +} + +fn main() { } diff --git a/src/test/ui/nll/user-annotations/method-ufcs-2.stderr b/src/test/ui/nll/user-annotations/method-ufcs-2.stderr new file mode 100644 index 00000000000..dc0f5596590 --- /dev/null +++ b/src/test/ui/nll/user-annotations/method-ufcs-2.stderr @@ -0,0 +1,45 @@ +error[E0597]: `a` does not live long enough + --> $DIR/method-ufcs-2.rs:42:7 + | +LL | x(&a, b, c); //~ ERROR + | ^^ borrowed value does not live long enough +LL | } + | - `a` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: `b` does not live long enough + --> $DIR/method-ufcs-2.rs:49:39 + | +LL | <_ as Bazoom<&'a u32>>::method(a, &b, c); //~ ERROR + | ^^ borrowed value does not live long enough +LL | } + | - `b` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 45:35... + --> $DIR/method-ufcs-2.rs:45:35 + | +LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { + | ^^ + +error[E0597]: `b` does not live long enough + --> $DIR/method-ufcs-2.rs:63:44 + | +LL | let _closure = || { + | -- value captured here +LL | let c = 66; +LL | <_ as Bazoom<&'a u32>>::method(a, &b, c); //~ ERROR + | ^ borrowed value does not live long enough +LL | }; +LL | } + | - `b` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 58:46... + --> $DIR/method-ufcs-2.rs:58:46 + | +LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { + | ^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0597`. |
