diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-12-01 01:35:25 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-12-26 12:58:33 +0300 |
| commit | 3fb676afb061edc708030a5ed1e5f3983e0beaa5 (patch) | |
| tree | f06a2361158bd406e3931f60e410037a74e674c7 /src/test/ui | |
| parent | 5752eae5f5ce3517d36f6668619dd2c70e6d2d88 (diff) | |
Move some compile-fail tests into UI directory
Diffstat (limited to 'src/test/ui')
61 files changed, 1953 insertions, 0 deletions
diff --git a/src/test/ui/resolve/auxiliary/issue-21221-3.rs b/src/test/ui/resolve/auxiliary/issue-21221-3.rs new file mode 100644 index 00000000000..fae0fe16a26 --- /dev/null +++ b/src/test/ui/resolve/auxiliary/issue-21221-3.rs @@ -0,0 +1,29 @@ +// Copyright 2016 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. + +// testing whether the lookup mechanism picks up types +// defined in the outside crate + +#![crate_type="lib"] + +pub mod outer { + // should suggest this + pub trait OuterTrait {} + + // should not suggest this since the module is private + mod private_module { + pub trait OuterTrait {} + } + + // should not suggest since the trait is private + pub mod public_module { + trait OuterTrait {} + } +} diff --git a/src/test/ui/resolve/auxiliary/issue-21221-4.rs b/src/test/ui/resolve/auxiliary/issue-21221-4.rs new file mode 100644 index 00000000000..fffe060ee24 --- /dev/null +++ b/src/test/ui/resolve/auxiliary/issue-21221-4.rs @@ -0,0 +1,22 @@ +// Copyright 2016 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. + +// testing whether the lookup mechanism picks up types +// defined in the outside crate + +#![crate_type="lib"] + +mod foo { + // should not be suggested => foo is private + pub trait T {} +} + +// should be suggested +pub use foo::T; diff --git a/src/test/ui/resolve/auxiliary/issue_19452_aux.rs b/src/test/ui/resolve/auxiliary/issue_19452_aux.rs new file mode 100644 index 00000000000..205566e4b1f --- /dev/null +++ b/src/test/ui/resolve/auxiliary/issue_19452_aux.rs @@ -0,0 +1,13 @@ +// Copyright 2016 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. + +pub enum Homura { + Madoka { age: u32 } +} diff --git a/src/test/ui/resolve/auxiliary/issue_3907.rs b/src/test/ui/resolve/auxiliary/issue_3907.rs new file mode 100644 index 00000000000..6472c08c222 --- /dev/null +++ b/src/test/ui/resolve/auxiliary/issue_3907.rs @@ -0,0 +1,13 @@ +// Copyright 2013 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. + +pub trait Foo { + fn bar(); +} diff --git a/src/test/ui/resolve/auxiliary/namespaced_enums.rs b/src/test/ui/resolve/auxiliary/namespaced_enums.rs new file mode 100644 index 00000000000..3bf39b788db --- /dev/null +++ b/src/test/ui/resolve/auxiliary/namespaced_enums.rs @@ -0,0 +1,20 @@ +// Copyright 2014 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. + +pub enum Foo { + A, + B(isize), + C { a: isize }, +} + +impl Foo { + pub fn foo() {} + pub fn bar(&self) {} +} diff --git a/src/test/ui/resolve/enums-are-namespaced-xc.rs b/src/test/ui/resolve/enums-are-namespaced-xc.rs new file mode 100644 index 00000000000..4f55f33d7f8 --- /dev/null +++ b/src/test/ui/resolve/enums-are-namespaced-xc.rs @@ -0,0 +1,24 @@ +// Copyright 2014 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. + +// aux-build:namespaced_enums.rs +extern crate namespaced_enums; + +fn main() { + let _ = namespaced_enums::A; + //~^ ERROR unresolved value `namespaced_enums::A` + //~| HELP you can import it into scope: `use namespaced_enums::Foo::A;` + let _ = namespaced_enums::B(10); + //~^ ERROR unresolved function `namespaced_enums::B` + //~| HELP you can import it into scope: `use namespaced_enums::Foo::B;` + let _ = namespaced_enums::C { a: 10 }; + //~^ ERROR unresolved struct, variant or union type `namespaced_enums::C` + //~| HELP you can import it into scope: `use namespaced_enums::Foo::C;` +} diff --git a/src/test/ui/resolve/enums-are-namespaced-xc.stderr b/src/test/ui/resolve/enums-are-namespaced-xc.stderr new file mode 100644 index 00000000000..5c88d4456da --- /dev/null +++ b/src/test/ui/resolve/enums-are-namespaced-xc.stderr @@ -0,0 +1,20 @@ +error[E0425]: unresolved name `namespaced_enums::A` + --> $DIR/enums-are-namespaced-xc.rs:15:13 + | +15 | let _ = namespaced_enums::A; + | ^^^^^^^^^^^^^^^^^^^ unresolved name + +error[E0425]: unresolved name `namespaced_enums::B` + --> $DIR/enums-are-namespaced-xc.rs:18:13 + | +18 | let _ = namespaced_enums::B(10); + | ^^^^^^^^^^^^^^^^^^^ unresolved name + +error[E0531]: unresolved struct, variant or union type `namespaced_enums::C` + --> $DIR/enums-are-namespaced-xc.rs:21:13 + | +21 | let _ = namespaced_enums::C { a: 10 }; + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/resolve/issue-14254.rs b/src/test/ui/resolve/issue-14254.rs new file mode 100644 index 00000000000..b1fc6c47720 --- /dev/null +++ b/src/test/ui/resolve/issue-14254.rs @@ -0,0 +1,137 @@ +// Copyright 2014 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. + +trait Foo { + fn bar(&self); + fn baz(&self) { } + fn bah(_: Option<&Self>) { } +} + +struct BarTy { + x : isize, + y : f64, +} + +impl BarTy { + fn a() {} + fn b(&self) {} +} + +impl Foo for *const BarTy { + fn bar(&self) { + baz(); + //~^ ERROR unresolved function `baz` + //~| NOTE did you mean `self.baz(...)`? + a; + //~^ ERROR unresolved value `a` + //~| NOTE no resolution found + } +} + +impl<'a> Foo for &'a BarTy { + fn bar(&self) { + baz(); + //~^ ERROR unresolved function `baz` + //~| NOTE did you mean `self.baz(...)`? + x; + //~^ ERROR unresolved value `x` + //~| NOTE did you mean `self.x`? + y; + //~^ ERROR unresolved value `y` + //~| NOTE did you mean `self.y`? + a; + //~^ ERROR unresolved value `a` + //~| NOTE no resolution found + bah; + //~^ ERROR unresolved value `bah` + //~| NOTE did you mean `Self::bah`? + b; + //~^ ERROR unresolved value `b` + //~| NOTE no resolution found + } +} + +impl<'a> Foo for &'a mut BarTy { + fn bar(&self) { + baz(); + //~^ ERROR unresolved function `baz` + //~| NOTE did you mean `self.baz(...)`? + x; + //~^ ERROR unresolved value `x` + //~| NOTE did you mean `self.x`? + y; + //~^ ERROR unresolved value `y` + //~| NOTE did you mean `self.y`? + a; + //~^ ERROR unresolved value `a` + //~| NOTE no resolution found + bah; + //~^ ERROR unresolved value `bah` + //~| NOTE did you mean `Self::bah`? + b; + //~^ ERROR unresolved value `b` + //~| NOTE no resolution found + } +} + +impl Foo for Box<BarTy> { + fn bar(&self) { + baz(); + //~^ ERROR unresolved function `baz` + //~| NOTE did you mean `self.baz(...)`? + bah; + //~^ ERROR unresolved value `bah` + //~| NOTE did you mean `Self::bah`? + } +} + +impl Foo for *const isize { + fn bar(&self) { + baz(); + //~^ ERROR unresolved function `baz` + //~| NOTE did you mean `self.baz(...)`? + bah; + //~^ ERROR unresolved value `bah` + //~| NOTE did you mean `Self::bah`? + } +} + +impl<'a> Foo for &'a isize { + fn bar(&self) { + baz(); + //~^ ERROR unresolved function `baz` + //~| NOTE did you mean `self.baz(...)`? + bah; + //~^ ERROR unresolved value `bah` + //~| NOTE did you mean `Self::bah`? + } +} + +impl<'a> Foo for &'a mut isize { + fn bar(&self) { + baz(); + //~^ ERROR unresolved function `baz` + //~| NOTE did you mean `self.baz(...)`? + bah; + //~^ ERROR unresolved value `bah` + //~| NOTE did you mean `Self::bah`? + } +} + +impl Foo for Box<isize> { + fn bar(&self) { + baz(); + //~^ ERROR unresolved function `baz` + //~| NOTE did you mean `self.baz(...)`? + bah; + //~^ ERROR unresolved value `bah` + //~| NOTE did you mean `Self::bah`? + } +} diff --git a/src/test/ui/resolve/issue-14254.stderr b/src/test/ui/resolve/issue-14254.stderr new file mode 100644 index 00000000000..b80a4be535b --- /dev/null +++ b/src/test/ui/resolve/issue-14254.stderr @@ -0,0 +1,148 @@ +error[E0425]: unresolved name `baz` + --> $DIR/issue-14254.rs:29:9 + | +29 | baz(); + | ^^^ did you mean to call `self.baz`? + +error[E0425]: unresolved name `a` + --> $DIR/issue-14254.rs:32:9 + | +32 | a; + | ^ unresolved name + +error[E0425]: unresolved name `baz` + --> $DIR/issue-14254.rs:40:9 + | +40 | baz(); + | ^^^ did you mean to call `self.baz`? + +error[E0425]: unresolved name `x` + --> $DIR/issue-14254.rs:43:9 + | +43 | x; + | ^ did you mean `self.x`? + +error[E0425]: unresolved name `y` + --> $DIR/issue-14254.rs:46:9 + | +46 | y; + | ^ did you mean `self.y`? + +error[E0425]: unresolved name `a` + --> $DIR/issue-14254.rs:49:9 + | +49 | a; + | ^ unresolved name + +error[E0425]: unresolved name `bah` + --> $DIR/issue-14254.rs:52:9 + | +52 | bah; + | ^^^ did you mean to call `Foo::bah`? + +error[E0425]: unresolved name `b` + --> $DIR/issue-14254.rs:55:9 + | +55 | b; + | ^ unresolved name + +error[E0425]: unresolved name `baz` + --> $DIR/issue-14254.rs:63:9 + | +63 | baz(); + | ^^^ did you mean to call `self.baz`? + +error[E0425]: unresolved name `x` + --> $DIR/issue-14254.rs:66:9 + | +66 | x; + | ^ did you mean `self.x`? + +error[E0425]: unresolved name `y` + --> $DIR/issue-14254.rs:69:9 + | +69 | y; + | ^ did you mean `self.y`? + +error[E0425]: unresolved name `a` + --> $DIR/issue-14254.rs:72:9 + | +72 | a; + | ^ unresolved name + +error[E0425]: unresolved name `bah` + --> $DIR/issue-14254.rs:75:9 + | +75 | bah; + | ^^^ did you mean to call `Foo::bah`? + +error[E0425]: unresolved name `b` + --> $DIR/issue-14254.rs:78:9 + | +78 | b; + | ^ unresolved name + +error[E0425]: unresolved name `baz` + --> $DIR/issue-14254.rs:86:9 + | +86 | baz(); + | ^^^ did you mean to call `self.baz`? + +error[E0425]: unresolved name `bah` + --> $DIR/issue-14254.rs:89:9 + | +89 | bah; + | ^^^ did you mean to call `Foo::bah`? + +error[E0425]: unresolved name `baz` + --> $DIR/issue-14254.rs:97:9 + | +97 | baz(); + | ^^^ did you mean to call `self.baz`? + +error[E0425]: unresolved name `bah` + --> $DIR/issue-14254.rs:100:9 + | +100 | bah; + | ^^^ did you mean to call `Foo::bah`? + +error[E0425]: unresolved name `baz` + --> $DIR/issue-14254.rs:108:9 + | +108 | baz(); + | ^^^ did you mean to call `self.baz`? + +error[E0425]: unresolved name `bah` + --> $DIR/issue-14254.rs:111:9 + | +111 | bah; + | ^^^ did you mean to call `Foo::bah`? + +error[E0425]: unresolved name `baz` + --> $DIR/issue-14254.rs:119:9 + | +119 | baz(); + | ^^^ did you mean to call `self.baz`? + +error[E0425]: unresolved name `bah` + --> $DIR/issue-14254.rs:122:9 + | +122 | bah; + | ^^^ did you mean to call `Foo::bah`? + +error[E0425]: unresolved name `baz` + --> $DIR/issue-14254.rs:130:9 + | +130 | baz(); + | ^^^ did you mean to call `self.baz`? + +error[E0425]: unresolved name `bah` + --> $DIR/issue-14254.rs:133:9 + | +133 | bah; + | ^^^ did you mean to call `Foo::bah`? + +error: main function not found + +error: aborting due to 25 previous errors + diff --git a/src/test/ui/resolve/issue-16058.rs b/src/test/ui/resolve/issue-16058.rs new file mode 100644 index 00000000000..1f777e53632 --- /dev/null +++ b/src/test/ui/resolve/issue-16058.rs @@ -0,0 +1,31 @@ +// Copyright 2012-2014 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. + + +pub struct GslResult { + pub val: f64, + pub err: f64 +} + +impl GslResult { + pub fn new() -> GslResult { + Result { +//~^ ERROR expected struct, variant or union type, found enum `Result` +//~| HELP possible better candidates are found in other modules, you can import them into scope +//~| HELP std::fmt::Result +//~| HELP std::io::Result +//~| HELP std::thread::Result + val: 0f64, + err: 0f64 + } + } +} + +fn main() {} diff --git a/src/test/ui/resolve/issue-16058.stderr b/src/test/ui/resolve/issue-16058.stderr new file mode 100644 index 00000000000..049f2de7bb4 --- /dev/null +++ b/src/test/ui/resolve/issue-16058.stderr @@ -0,0 +1,8 @@ +error[E0532]: expected struct, variant or union type, found enum `Result` + --> $DIR/issue-16058.rs:19:9 + | +19 | Result { + | ^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/resolve/issue-17518.rs b/src/test/ui/resolve/issue-17518.rs new file mode 100644 index 00000000000..3ac9b379d18 --- /dev/null +++ b/src/test/ui/resolve/issue-17518.rs @@ -0,0 +1,18 @@ +// Copyright 2014 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. + +enum SomeEnum { + E +} + +fn main() { + E { name: "foobar" }; //~ ERROR unresolved struct, variant or union type `E` + //~^ HELP you can import it into scope: `use SomeEnum::E;` +} diff --git a/src/test/ui/resolve/issue-17518.stderr b/src/test/ui/resolve/issue-17518.stderr new file mode 100644 index 00000000000..4c0bb20d09c --- /dev/null +++ b/src/test/ui/resolve/issue-17518.stderr @@ -0,0 +1,8 @@ +error[E0531]: unresolved struct, variant or union type `E` + --> $DIR/issue-17518.rs:16:5 + | +16 | E { name: "foobar" }; //~ ERROR unresolved struct, variant or union type `E` + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/resolve/issue-18252.rs b/src/test/ui/resolve/issue-18252.rs new file mode 100644 index 00000000000..02c6643a920 --- /dev/null +++ b/src/test/ui/resolve/issue-18252.rs @@ -0,0 +1,18 @@ +// Copyright 2014 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. + +enum Foo { + Variant { x: usize } +} + +fn main() { + let f = Foo::Variant(42); + //~^ ERROR expected function, found struct variant `Foo::Variant` +} diff --git a/src/test/ui/resolve/issue-18252.stderr b/src/test/ui/resolve/issue-18252.stderr new file mode 100644 index 00000000000..fa1604f46ec --- /dev/null +++ b/src/test/ui/resolve/issue-18252.stderr @@ -0,0 +1,10 @@ +error[E0423]: `Foo::Variant` is the name of a struct or struct variant, but this expression uses it like a function name + --> $DIR/issue-18252.rs:16:13 + | +16 | let f = Foo::Variant(42); + | ^^^^^^^^^^^^ struct called like a function + | + = help: did you mean to write: `Foo::Variant { /* fields */ }`? + +error: aborting due to previous error + diff --git a/src/test/ui/resolve/issue-19452.rs b/src/test/ui/resolve/issue-19452.rs new file mode 100644 index 00000000000..080fb064c9f --- /dev/null +++ b/src/test/ui/resolve/issue-19452.rs @@ -0,0 +1,24 @@ +// Copyright 2014 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. + +// aux-build:issue_19452_aux.rs +extern crate issue_19452_aux; + +enum Homura { + Madoka { age: u32 } +} + +fn main() { + let homura = Homura::Madoka; + //~^ ERROR expected value, found struct variant `Homura::Madoka` + + let homura = issue_19452_aux::Homura::Madoka; + //~^ ERROR expected value, found struct variant `issue_19452_aux::Homura::Madoka` +} diff --git a/src/test/ui/resolve/issue-19452.stderr b/src/test/ui/resolve/issue-19452.stderr new file mode 100644 index 00000000000..c0c4047ef12 --- /dev/null +++ b/src/test/ui/resolve/issue-19452.stderr @@ -0,0 +1,18 @@ +error[E0423]: `Homura::Madoka` is the name of a struct or struct variant, but this expression uses it like a function name + --> $DIR/issue-19452.rs:19:18 + | +19 | let homura = Homura::Madoka; + | ^^^^^^^^^^^^^^ struct called like a function + | + = help: did you mean to write: `Homura::Madoka { /* fields */ }`? + +error[E0423]: `issue_19452_aux::Homura::Madoka` is the name of a struct or struct variant, but this expression uses it like a function name + --> $DIR/issue-19452.rs:22:18 + | +22 | let homura = issue_19452_aux::Homura::Madoka; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ struct called like a function + | + = help: did you mean to write: `issue_19452_aux::Homura::Madoka { /* fields */ }`? + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/resolve/issue-21221-1.rs b/src/test/ui/resolve/issue-21221-1.rs new file mode 100644 index 00000000000..b1266a5af35 --- /dev/null +++ b/src/test/ui/resolve/issue-21221-1.rs @@ -0,0 +1,96 @@ +// Copyright 2016 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. + +mod mul1 { + pub trait Mul {} +} + +mod mul2 { + pub trait Mul {} +} + +mod mul3 { + enum Mul { + Yes, + No + } +} + +mod mul4 { + type Mul = String; +} + +mod mul5 { + struct Mul{ + left_term: u32, + right_term: u32 + } +} + +#[derive(Debug)] +struct Foo; + +// When we comment the next line: +//use mul1::Mul; + +// BEFORE, we got the following error for the `impl` below: +// error: use of undeclared trait name `Mul` [E0405] +// AFTER, we get this message: +// error: trait `Mul` is not in scope. +// help: ... +// help: you can import several candidates into scope (`use ...;`): +// help: `mul1::Mul` +// help: `mul2::Mul` +// help: `std::ops::Mul` + +impl Mul for Foo { +//~^ ERROR unresolved trait `Mul` +//~| HELP possible candidates are found in other modules, you can import them into scope +//~| HELP `mul1::Mul` +//~| HELP `mul2::Mul` +//~| HELP `std::ops::Mul` +} + +// BEFORE, we got: +// error: use of undeclared type name `Mul` [E0412] +// AFTER, we get: +// error: type name `Mul` is not in scope. Maybe you meant: +// help: ... +// help: you can import several candidates into scope (`use ...;`): +// help: `mul1::Mul` +// help: `mul2::Mul` +// help: `mul3::Mul` +// help: `mul4::Mul` +// help: and 2 other candidates +fn getMul() -> Mul { +//~^ ERROR unresolved type `Mul` +//~| HELP possible candidates are found in other modules, you can import them into scope +//~| HELP `mul1::Mul` +//~| HELP `mul2::Mul` +//~| HELP `mul3::Mul` +//~| HELP `mul4::Mul` +//~| HELP and 2 other candidates +} + +// Let's also test what happens if the trait doesn't exist: +impl ThisTraitReallyDoesntExistInAnyModuleReally for Foo { +//~^ ERROR unresolved trait `ThisTraitReallyDoesntExistInAnyModuleReally` +} + +// Let's also test what happens if there's just one alternative: +impl Div for Foo { +//~^ ERROR unresolved trait `Div` +//~| HELP `use std::ops::Div;` +} + +fn main() { + let foo = Foo(); + println!("Hello, {:?}!", foo); +} diff --git a/src/test/ui/resolve/issue-21221-1.stderr b/src/test/ui/resolve/issue-21221-1.stderr new file mode 100644 index 00000000000..e16eedf71ef --- /dev/null +++ b/src/test/ui/resolve/issue-21221-1.stderr @@ -0,0 +1,42 @@ +error[E0405]: trait `Mul` is not in scope + --> $DIR/issue-21221-1.rs:53:6 + | +53 | impl Mul for Foo { + | ^^^ `Mul` is not in scope + | + = help: you can import several candidates into scope (`use ...;`): + = help: `mul1::Mul` + = help: `mul2::Mul` + = help: `std::ops::Mul` + +error[E0412]: type name `Mul` is undefined or not in scope + --> $DIR/issue-21221-1.rs:72:16 + | +72 | fn getMul() -> Mul { + | ^^^ undefined or not in scope + | + = help: you can import several candidates into scope (`use ...;`): + = help: `mul1::Mul` + = help: `mul2::Mul` + = help: `mul3::Mul` + = help: `mul4::Mul` + = help: and 2 other candidates + +error[E0405]: trait `ThisTraitReallyDoesntExistInAnyModuleReally` is not in scope + --> $DIR/issue-21221-1.rs:83:6 + | +83 | impl ThisTraitReallyDoesntExistInAnyModuleReally for Foo { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ThisTraitReallyDoesntExistInAnyModuleReally` is not in scope + | + = help: no candidates by the name of `ThisTraitReallyDoesntExistInAnyModuleReally` found in your project; maybe you misspelled the name or forgot to import an external crate? + +error[E0405]: trait `Div` is not in scope + --> $DIR/issue-21221-1.rs:88:6 + | +88 | impl Div for Foo { + | ^^^ `Div` is not in scope + | + = help: you can import it into scope: `use std::ops::Div;`. + +error: cannot continue compilation due to previous error + diff --git a/src/test/ui/resolve/issue-21221-2.rs b/src/test/ui/resolve/issue-21221-2.rs new file mode 100644 index 00000000000..15e859329c4 --- /dev/null +++ b/src/test/ui/resolve/issue-21221-2.rs @@ -0,0 +1,30 @@ +// Copyright 2016 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. + +pub mod foo { + pub mod bar { + // note: trait T is not public, but being in the current + // crate, it's fine to show it, since the programmer can + // decide to make it public based on the suggestion ... + pub trait T {} + } + // imports should be ignored: + use self::bar::T; +} + +pub mod baz { + pub use foo; + pub use std::ops::{Mul as T}; +} + +struct Foo; +impl T for Foo { } +//~^ ERROR unresolved trait `T` +//~| HELP you can import it into scope: `use foo::bar::T;` diff --git a/src/test/ui/resolve/issue-21221-2.stderr b/src/test/ui/resolve/issue-21221-2.stderr new file mode 100644 index 00000000000..dad56c6b087 --- /dev/null +++ b/src/test/ui/resolve/issue-21221-2.stderr @@ -0,0 +1,12 @@ +error[E0405]: trait `T` is not in scope + --> $DIR/issue-21221-2.rs:28:6 + | +28 | impl T for Foo { } + | ^ `T` is not in scope + | + = help: you can import it into scope: `use foo::bar::T;`. + +error: main function not found + +error: cannot continue compilation due to previous error + diff --git a/src/test/ui/resolve/issue-21221-3.rs b/src/test/ui/resolve/issue-21221-3.rs new file mode 100644 index 00000000000..5d62cb85914 --- /dev/null +++ b/src/test/ui/resolve/issue-21221-3.rs @@ -0,0 +1,30 @@ +// Copyright 2016 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. + +// testing whether the lookup mechanism picks up types +// defined in the outside crate + +// aux-build:issue-21221-3.rs + +extern crate issue_21221_3; + +struct Foo; + +// NOTE: This shows only traits accessible from the current +// crate, thus the two private entities: +// `issue_21221_3::outer::private_module::OuterTrait` and +// `issue_21221_3::outer::public_module::OuterTrait` +// are hidden from the view. +impl OuterTrait for Foo {} +//~^ ERROR unresolved trait `OuterTrait` +//~| HELP you can import it into scope: `use issue_21221_3::outer::OuterTrait;` +fn main() { + println!("Hello, world!"); +} diff --git a/src/test/ui/resolve/issue-21221-3.stderr b/src/test/ui/resolve/issue-21221-3.stderr new file mode 100644 index 00000000000..601487cf19e --- /dev/null +++ b/src/test/ui/resolve/issue-21221-3.stderr @@ -0,0 +1,10 @@ +error[E0405]: trait `OuterTrait` is not in scope + --> $DIR/issue-21221-3.rs:25:6 + | +25 | impl OuterTrait for Foo {} + | ^^^^^^^^^^ `OuterTrait` is not in scope + | + = help: you can import it into scope: `use issue_21221_3::outer::OuterTrait;`. + +error: cannot continue compilation due to previous error + diff --git a/src/test/ui/resolve/issue-21221-4.rs b/src/test/ui/resolve/issue-21221-4.rs new file mode 100644 index 00000000000..ff6698f8717 --- /dev/null +++ b/src/test/ui/resolve/issue-21221-4.rs @@ -0,0 +1,26 @@ +// Copyright 2016 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. + +// testing whether the lookup mechanism picks up types +// defined in the outside crate + +// aux-build:issue-21221-4.rs + +extern crate issue_21221_4; + +struct Foo; + +impl T for Foo {} +//~^ ERROR unresolved trait `T` +//~| HELP you can import it into scope: `use issue_21221_4::T;` + +fn main() { + println!("Hello, world!"); +} diff --git a/src/test/ui/resolve/issue-21221-4.stderr b/src/test/ui/resolve/issue-21221-4.stderr new file mode 100644 index 00000000000..3ce9073e59f --- /dev/null +++ b/src/test/ui/resolve/issue-21221-4.stderr @@ -0,0 +1,10 @@ +error[E0405]: trait `T` is not in scope + --> $DIR/issue-21221-4.rs:20:6 + | +20 | impl T for Foo {} + | ^ `T` is not in scope + | + = help: you can import it into scope: `use issue_21221_4::T;`. + +error: cannot continue compilation due to previous error + diff --git a/src/test/ui/resolve/issue-23305.rs b/src/test/ui/resolve/issue-23305.rs new file mode 100644 index 00000000000..19069f49167 --- /dev/null +++ b/src/test/ui/resolve/issue-23305.rs @@ -0,0 +1,22 @@ +// Copyright 2015 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. + +pub trait ToNbt<T> { + fn new(val: T) -> Self; +} + +impl ToNbt<Self> {} +//~^ ERROR unresolved type `Self` +//~| NOTE `Self` is only available in traits and impls +//~| ERROR the trait `ToNbt` cannot be made into an object +//~| NOTE the trait `ToNbt` cannot be made into an object +//~| NOTE method `new` has no receiver + +fn main() {} diff --git a/src/test/ui/resolve/issue-23305.stderr b/src/test/ui/resolve/issue-23305.stderr new file mode 100644 index 00000000000..02f27a47c9b --- /dev/null +++ b/src/test/ui/resolve/issue-23305.stderr @@ -0,0 +1,16 @@ +error[E0411]: use of `Self` outside of an impl or trait + --> $DIR/issue-23305.rs:15:12 + | +15 | impl ToNbt<Self> {} + | ^^^^ used outside of impl or trait + +error[E0038]: the trait `ToNbt` cannot be made into an object + --> $DIR/issue-23305.rs:15:6 + | +15 | impl ToNbt<Self> {} + | ^^^^^^^^^^^ the trait `ToNbt` cannot be made into an object + | + = note: method `new` has no receiver + +error: aborting due to previous error + diff --git a/src/test/ui/resolve/issue-2356.rs b/src/test/ui/resolve/issue-2356.rs new file mode 100644 index 00000000000..6deb598b631 --- /dev/null +++ b/src/test/ui/resolve/issue-2356.rs @@ -0,0 +1,125 @@ +// Copyright 2012-2014 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. + +trait Groom { + fn shave(other: usize); +} + +pub struct cat { + whiskers: isize, +} + +pub enum MaybeDog { + Dog, + NoDog +} + +impl MaybeDog { + fn bark() { + // If this provides a suggestion, it's a bug as MaybeDog doesn't impl Groom + shave(); + //~^ ERROR unresolved function `shave` + //~| NOTE no resolution found + } +} + +impl Clone for cat { + fn clone(&self) -> Self { + clone(); + //~^ ERROR unresolved function `clone` + //~| NOTE did you mean `self.clone(...)`? + loop {} + } +} +impl Default for cat { + fn default() -> Self { + default(); + //~^ ERROR unresolved function `default` + //~| NOTE did you mean `Self::default`? + loop {} + } +} + +impl Groom for cat { + fn shave(other: usize) { + whiskers -= other; + //~^ ERROR unresolved value `whiskers` + //~| ERROR unresolved value `whiskers` + //~| NOTE did you mean `self.whiskers`? + //~| NOTE `self` value is only available in methods with `self` parameter + shave(4); + //~^ ERROR unresolved function `shave` + //~| NOTE did you mean `Self::shave`? + purr(); + //~^ ERROR unresolved function `purr` + //~| NOTE no resolution found + } +} + +impl cat { + fn static_method() {} + + fn purr_louder() { + static_method(); + //~^ ERROR unresolved function `static_method` + //~| NOTE no resolution found + purr(); + //~^ ERROR unresolved function `purr` + //~| NOTE no resolution found + purr(); + //~^ ERROR unresolved function `purr` + //~| NOTE no resolution found + purr(); + //~^ ERROR unresolved function `purr` + //~| NOTE no resolution found + } +} + +impl cat { + fn meow() { + if self.whiskers > 3 { + //~^ ERROR expected value, found module `self` + //~| NOTE `self` value is only available in methods with `self` parameter + println!("MEOW"); + } + } + + fn purr(&self) { + grow_older(); + //~^ ERROR unresolved function `grow_older` + //~| NOTE no resolution found + shave(); + //~^ ERROR unresolved function `shave` + //~| NOTE no resolution found + } + + fn burn_whiskers(&mut self) { + whiskers = 0; + //~^ ERROR unresolved value `whiskers` + //~| NOTE did you mean `self.whiskers`? + } + + pub fn grow_older(other:usize) { + whiskers = 4; + //~^ ERROR unresolved value `whiskers` + //~| ERROR unresolved value `whiskers` + //~| NOTE did you mean `self.whiskers`? + //~| NOTE `self` value is only available in methods with `self` parameter + purr_louder(); + //~^ ERROR unresolved function `purr_louder` + //~| NOTE no resolution found + } +} + +fn main() { + self += 1; + //~^ ERROR expected value, found module `self` + //~| NOTE `self` value is only available in methods with `self` parameter +} diff --git a/src/test/ui/resolve/issue-2356.stderr b/src/test/ui/resolve/issue-2356.stderr new file mode 100644 index 00000000000..c15228cc262 --- /dev/null +++ b/src/test/ui/resolve/issue-2356.stderr @@ -0,0 +1,112 @@ +error[E0425]: unresolved name `shave` + --> $DIR/issue-2356.rs:27:5 + | +27 | shave(); + | ^^^^^ unresolved name + +error[E0425]: unresolved name `clone` + --> $DIR/issue-2356.rs:35:5 + | +35 | clone(); + | ^^^^^ did you mean to call `self.clone`? + +error[E0425]: unresolved name `default` + --> $DIR/issue-2356.rs:43:5 + | +43 | default(); + | ^^^^^^^ did you mean to call `self.default`? + +error[E0425]: unresolved name `whiskers` + --> $DIR/issue-2356.rs:52:5 + | +52 | whiskers -= other; + | ^^^^^^^^ unresolved name + | + = help: this is an associated function, you don't have access to this type's fields or methods + +error[E0425]: unresolved name `shave` + --> $DIR/issue-2356.rs:57:5 + | +57 | shave(4); + | ^^^^^ did you mean to call `Groom::shave`? + +error[E0425]: unresolved name `purr` + --> $DIR/issue-2356.rs:60:5 + | +60 | purr(); + | ^^^^ unresolved name + +error[E0425]: unresolved name `static_method` + --> $DIR/issue-2356.rs:70:9 + | +70 | static_method(); + | ^^^^^^^^^^^^^ unresolved name + +error[E0425]: unresolved name `purr` + --> $DIR/issue-2356.rs:73:9 + | +73 | purr(); + | ^^^^ unresolved name + +error[E0425]: unresolved name `purr` + --> $DIR/issue-2356.rs:76:9 + | +76 | purr(); + | ^^^^ unresolved name + +error[E0425]: unresolved name `purr` + --> $DIR/issue-2356.rs:79:9 + | +79 | purr(); + | ^^^^ unresolved name + +error[E0424]: `self` is not available in a static method + --> $DIR/issue-2356.rs:87:8 + | +87 | if self.whiskers > 3 { + | ^^^^ not available in static method + | + = note: maybe a `self` argument is missing? + +error[E0425]: unresolved name `grow_older` + --> $DIR/issue-2356.rs:95:5 + | +95 | grow_older(); + | ^^^^^^^^^^ unresolved name + +error[E0425]: unresolved name `shave` + --> $DIR/issue-2356.rs:98:5 + | +98 | shave(); + | ^^^^^ unresolved name + +error[E0425]: unresolved name `whiskers` + --> $DIR/issue-2356.rs:104:5 + | +104 | whiskers = 0; + | ^^^^^^^^ did you mean `self.whiskers`? + +error[E0425]: unresolved name `whiskers` + --> $DIR/issue-2356.rs:110:5 + | +110 | whiskers = 4; + | ^^^^^^^^ unresolved name + | + = help: this is an associated function, you don't have access to this type's fields or methods + +error[E0425]: unresolved name `purr_louder` + --> $DIR/issue-2356.rs:115:5 + | +115 | purr_louder(); + | ^^^^^^^^^^^ unresolved name + +error[E0425]: unresolved name `self` + --> $DIR/issue-2356.rs:122:5 + | +122 | self += 1; + | ^^^^ unresolved name + | + = help: module `self` cannot be used as an expression + +error: aborting due to 17 previous errors + diff --git a/src/test/ui/resolve/issue-24968.rs b/src/test/ui/resolve/issue-24968.rs new file mode 100644 index 00000000000..0d562cab6b8 --- /dev/null +++ b/src/test/ui/resolve/issue-24968.rs @@ -0,0 +1,16 @@ +// Copyright 2015 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. + +fn foo(_: Self) { +//~^ ERROR unresolved type `Self` +//~| NOTE `Self` is only available in traits and impls +} + +fn main() {} diff --git a/src/test/ui/resolve/issue-24968.stderr b/src/test/ui/resolve/issue-24968.stderr new file mode 100644 index 00000000000..f8068d29fd6 --- /dev/null +++ b/src/test/ui/resolve/issue-24968.stderr @@ -0,0 +1,8 @@ +error[E0411]: use of `Self` outside of an impl or trait + --> $DIR/issue-24968.rs:11:11 + | +11 | fn foo(_: Self) { + | ^^^^ used outside of impl or trait + +error: aborting due to previous error + diff --git a/src/test/ui/resolve/issue-33876.rs b/src/test/ui/resolve/issue-33876.rs new file mode 100644 index 00000000000..a97cc5e4101 --- /dev/null +++ b/src/test/ui/resolve/issue-33876.rs @@ -0,0 +1,22 @@ +// Copyright 2016 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. + +use std::any::Any; + +struct Foo; + +trait Bar {} + +impl Bar for Foo {} + +fn main() { + let any: &Any = &Bar; //~ ERROR expected value, found trait `Bar` + if any.is::<u32>() { println!("u32"); } +} diff --git a/src/test/ui/resolve/issue-33876.stderr b/src/test/ui/resolve/issue-33876.stderr new file mode 100644 index 00000000000..ecc3a2b30e0 --- /dev/null +++ b/src/test/ui/resolve/issue-33876.stderr @@ -0,0 +1,10 @@ +error[E0425]: unresolved name `Bar` + --> $DIR/issue-33876.rs:20:22 + | +20 | let any: &Any = &Bar; //~ ERROR expected value, found trait `Bar` + | ^^^ unresolved name + | + = help: trait `Bar` cannot be used as an expression + +error: aborting due to previous error + diff --git a/src/test/ui/resolve/issue-3907-2.rs b/src/test/ui/resolve/issue-3907-2.rs new file mode 100644 index 00000000000..130647966f2 --- /dev/null +++ b/src/test/ui/resolve/issue-3907-2.rs @@ -0,0 +1,23 @@ +// Copyright 2013-2014 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. + +// aux-build:issue_3907.rs +extern crate issue_3907; + +type Foo = issue_3907::Foo+'static; + +struct S { + name: isize +} + +fn bar(_x: Foo) {} +//~^ ERROR E0038 + +fn main() {} diff --git a/src/test/ui/resolve/issue-3907-2.stderr b/src/test/ui/resolve/issue-3907-2.stderr new file mode 100644 index 00000000000..ef02250e21c --- /dev/null +++ b/src/test/ui/resolve/issue-3907-2.stderr @@ -0,0 +1,10 @@ +error[E0038]: the trait `issue_3907::Foo` cannot be made into an object + --> $DIR/issue-3907-2.rs:20:1 + | +20 | fn bar(_x: Foo) {} + | ^^^^^^^^^^^^^^^^^^ the trait `issue_3907::Foo` cannot be made into an object + | + = note: method `bar` has no receiver + +error: aborting due to previous error + diff --git a/src/test/ui/resolve/issue-3907.rs b/src/test/ui/resolve/issue-3907.rs new file mode 100644 index 00000000000..0e54e68df0d --- /dev/null +++ b/src/test/ui/resolve/issue-3907.rs @@ -0,0 +1,29 @@ +// Copyright 2013-2014 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. + +// aux-build:issue_3907.rs +extern crate issue_3907; + +type Foo = issue_3907::Foo; + +struct S { + name: isize +} + +impl Foo for S { //~ ERROR expected trait, found type alias `Foo` + fn bar() { } +} + +fn main() { + let s = S { + name: 0 + }; + s.bar(); +} diff --git a/src/test/ui/resolve/issue-3907.stderr b/src/test/ui/resolve/issue-3907.stderr new file mode 100644 index 00000000000..4d0cd93d31f --- /dev/null +++ b/src/test/ui/resolve/issue-3907.stderr @@ -0,0 +1,10 @@ +error[E0404]: `Foo` is not a trait + --> $DIR/issue-3907.rs:20:6 + | +20 | impl Foo for S { //~ ERROR expected trait, found type alias `Foo` + | ^^^ expected trait, found type alias + | + = note: type aliases cannot be used for traits + +error: cannot continue compilation due to previous error + diff --git a/src/test/ui/resolve/issue-5035-2.rs b/src/test/ui/resolve/issue-5035-2.rs new file mode 100644 index 00000000000..83ff95cc2ea --- /dev/null +++ b/src/test/ui/resolve/issue-5035-2.rs @@ -0,0 +1,16 @@ +// Copyright 2013-2014 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. + +trait I {} +type K = I+'static; + +fn foo(_x: K) {} //~ ERROR: `I + 'static: std::marker::Sized` is not satisfied + +fn main() {} diff --git a/src/test/ui/resolve/issue-5035-2.stderr b/src/test/ui/resolve/issue-5035-2.stderr new file mode 100644 index 00000000000..72b1578e0d0 --- /dev/null +++ b/src/test/ui/resolve/issue-5035-2.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `I + 'static: std::marker::Sized` is not satisfied + --> $DIR/issue-5035-2.rs:14:8 + | +14 | fn foo(_x: K) {} //~ ERROR: `I + 'static: std::marker::Sized` is not satisfied + | ^^ the trait `std::marker::Sized` is not implemented for `I + 'static` + | + = note: `I + 'static` does not have a constant size known at compile-time + = note: all local variables must have a statically known size + +error: aborting due to previous error + diff --git a/src/test/ui/resolve/issue-5035.rs b/src/test/ui/resolve/issue-5035.rs new file mode 100644 index 00000000000..6263e6f6db4 --- /dev/null +++ b/src/test/ui/resolve/issue-5035.rs @@ -0,0 +1,20 @@ +// Copyright 2013-2014 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. + +trait I {} +type K = I; +impl K for isize {} //~ ERROR expected trait, found type alias `K` + //~| NOTE type aliases cannot be used for traits + +use ImportError; //~ ERROR unresolved import `ImportError` [E0432] + //~^ no `ImportError` in the root +impl ImportError for () {} // check that this is not an additional error (c.f. #35142) + +fn main() {} diff --git a/src/test/ui/resolve/issue-5035.stderr b/src/test/ui/resolve/issue-5035.stderr new file mode 100644 index 00000000000..def1aba694b --- /dev/null +++ b/src/test/ui/resolve/issue-5035.stderr @@ -0,0 +1,16 @@ +error[E0432]: unresolved import `ImportError` + --> $DIR/issue-5035.rs:16:5 + | +16 | use ImportError; //~ ERROR unresolved import `ImportError` [E0432] + | ^^^^^^^^^^^ no `ImportError` in the root + +error[E0404]: `K` is not a trait + --> $DIR/issue-5035.rs:13:6 + | +13 | impl K for isize {} //~ ERROR expected trait, found type alias `K` + | ^ expected trait, found type alias + | + = note: type aliases cannot be used for traits + +error: cannot continue compilation due to previous error + diff --git a/src/test/ui/resolve/issue-6702.rs b/src/test/ui/resolve/issue-6702.rs new file mode 100644 index 00000000000..b391ddf3469 --- /dev/null +++ b/src/test/ui/resolve/issue-6702.rs @@ -0,0 +1,19 @@ +// Copyright 2013 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. + +struct Monster { + damage: isize +} + + +fn main() { + let _m = Monster(); //~ ERROR expected function, found struct `Monster` + //~^ NOTE did you mean `Monster { /* fields */ }`? +} diff --git a/src/test/ui/resolve/issue-6702.stderr b/src/test/ui/resolve/issue-6702.stderr new file mode 100644 index 00000000000..c8df55225e2 --- /dev/null +++ b/src/test/ui/resolve/issue-6702.stderr @@ -0,0 +1,10 @@ +error[E0423]: `Monster` is the name of a struct or struct variant, but this expression uses it like a function name + --> $DIR/issue-6702.rs:17:14 + | +17 | let _m = Monster(); //~ ERROR expected function, found struct `Monster` + | ^^^^^^^ struct called like a function + | + = help: did you mean to write: `Monster { /* fields */ }`? + +error: aborting due to previous error + diff --git a/src/test/ui/resolve/resolve-assoc-suggestions.rs b/src/test/ui/resolve/resolve-assoc-suggestions.rs new file mode 100644 index 00000000000..53e26ddafec --- /dev/null +++ b/src/test/ui/resolve/resolve-assoc-suggestions.rs @@ -0,0 +1,58 @@ +// Copyright 2016 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. + +// Make sure associated items are recommended only in appropriate contexts. + +struct S { + field: u8, +} + +trait Tr { + fn method(&self); + type Type; +} + +impl Tr for S { + type Type = u8; + + fn method(&self) { + let _: field; + //~^ ERROR unresolved type `field` + //~| NOTE no resolution found + let field(..); + //~^ ERROR unresolved tuple struct/variant `field` + //~| NOTE no resolution found + field; + //~^ ERROR unresolved value `field` + //~| NOTE did you mean `self.field`? + + let _: Type; + //~^ ERROR unresolved type `Type` + //~| NOTE did you mean `Self::Type`? + let Type(..); + //~^ ERROR unresolved tuple struct/variant `Type` + //~| NOTE no resolution found + Type; + //~^ ERROR unresolved value `Type` + //~| NOTE no resolution found + + let _: method; + //~^ ERROR unresolved type `method` + //~| NOTE no resolution found + let method(..); + //~^ ERROR unresolved tuple struct/variant `method` + //~| NOTE no resolution found + method; + //~^ ERROR unresolved value `method` + //~| NOTE did you mean `self.method(...)`? + } +} + +fn main() {} diff --git a/src/test/ui/resolve/resolve-assoc-suggestions.stderr b/src/test/ui/resolve/resolve-assoc-suggestions.stderr new file mode 100644 index 00000000000..09c66fa6c28 --- /dev/null +++ b/src/test/ui/resolve/resolve-assoc-suggestions.stderr @@ -0,0 +1,62 @@ +error[E0412]: type name `field` is undefined or not in scope + --> $DIR/resolve-assoc-suggestions.rs:26:16 + | +26 | let _: field; + | ^^^^^ undefined or not in scope + | + = help: no candidates by the name of `field` found in your project; maybe you misspelled the name or forgot to import an external crate? + +error[E0531]: unresolved tuple struct/variant `field` + --> $DIR/resolve-assoc-suggestions.rs:29:13 + | +29 | let field(..); + | ^^^^^ + +error[E0425]: unresolved name `field` + --> $DIR/resolve-assoc-suggestions.rs:32:9 + | +32 | field; + | ^^^^^ did you mean `self.field`? + +error[E0412]: type name `Type` is undefined or not in scope + --> $DIR/resolve-assoc-suggestions.rs:36:16 + | +36 | let _: Type; + | ^^^^ undefined or not in scope + | + = help: no candidates by the name of `Type` found in your project; maybe you misspelled the name or forgot to import an external crate? + +error[E0531]: unresolved tuple struct/variant `Type` + --> $DIR/resolve-assoc-suggestions.rs:39:13 + | +39 | let Type(..); + | ^^^^ + +error[E0425]: unresolved name `Type` + --> $DIR/resolve-assoc-suggestions.rs:42:9 + | +42 | Type; + | ^^^^ did you mean to call `self.Type`? + +error[E0412]: type name `method` is undefined or not in scope + --> $DIR/resolve-assoc-suggestions.rs:46:16 + | +46 | let _: method; + | ^^^^^^ undefined or not in scope + | + = help: no candidates by the name of `method` found in your project; maybe you misspelled the name or forgot to import an external crate? + +error[E0531]: unresolved tuple struct/variant `method` + --> $DIR/resolve-assoc-suggestions.rs:49:13 + | +49 | let method(..); + | ^^^^^^ + +error[E0425]: unresolved name `method` + --> $DIR/resolve-assoc-suggestions.rs:52:9 + | +52 | method; + | ^^^^^^ did you mean to call `self.method`? + +error: aborting due to 9 previous errors + diff --git a/src/test/ui/resolve/resolve-hint-macro.rs b/src/test/ui/resolve/resolve-hint-macro.rs new file mode 100644 index 00000000000..72fd9a79376 --- /dev/null +++ b/src/test/ui/resolve/resolve-hint-macro.rs @@ -0,0 +1,15 @@ +// Copyright 2014 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. + +fn main() { + assert(true); + //~^ ERROR expected function, found macro `assert` + //~| NOTE did you mean `assert!(...)`? +} diff --git a/src/test/ui/resolve/resolve-hint-macro.stderr b/src/test/ui/resolve/resolve-hint-macro.stderr new file mode 100644 index 00000000000..ef7c2f7e632 --- /dev/null +++ b/src/test/ui/resolve/resolve-hint-macro.stderr @@ -0,0 +1,8 @@ +error[E0425]: unresolved name `assert` + --> $DIR/resolve-hint-macro.rs:12:5 + | +12 | assert(true); + | ^^^^^^ did you mean the macro `assert!`? + +error: aborting due to previous error + diff --git a/src/test/ui/resolve/resolve-speculative-adjustment.rs b/src/test/ui/resolve/resolve-speculative-adjustment.rs new file mode 100644 index 00000000000..95289e23f9e --- /dev/null +++ b/src/test/ui/resolve/resolve-speculative-adjustment.rs @@ -0,0 +1,44 @@ +// Copyright 2016 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. + +// Make sure speculative path resolution works properly when resolution +// adjustment happens and no extra errors is reported. + +struct S { + field: u8, +} + +trait Tr { + fn method(&self); +} + +impl Tr for S { + fn method(&self) { + fn g() { + // Speculative resolution of `Self` and `self` silently fails, + // "did you mean" messages are not printed. + field; + //~^ ERROR unresolved value `field` + //~| NOTE no resolution found + method(); + //~^ ERROR unresolved function `method` + //~| NOTE no resolution found + } + + field; + //~^ ERROR unresolved value `field` + //~| NOTE did you mean `self.field`? + method(); + //~^ ERROR unresolved function `method` + //~| NOTE did you mean `self.method(...)`? + } +} + +fn main() {} diff --git a/src/test/ui/resolve/resolve-speculative-adjustment.stderr b/src/test/ui/resolve/resolve-speculative-adjustment.stderr new file mode 100644 index 00000000000..7c1547221ba --- /dev/null +++ b/src/test/ui/resolve/resolve-speculative-adjustment.stderr @@ -0,0 +1,26 @@ +error[E0425]: unresolved name `field` + --> $DIR/resolve-speculative-adjustment.rs:27:13 + | +27 | field; + | ^^^^^ did you mean `self.field`? + +error[E0425]: unresolved name `method` + --> $DIR/resolve-speculative-adjustment.rs:30:13 + | +30 | method(); + | ^^^^^^ did you mean to call `self.method`? + +error[E0425]: unresolved name `field` + --> $DIR/resolve-speculative-adjustment.rs:35:9 + | +35 | field; + | ^^^^^ did you mean `self.field`? + +error[E0425]: unresolved name `method` + --> $DIR/resolve-speculative-adjustment.rs:38:9 + | +38 | method(); + | ^^^^^^ did you mean to call `self.method`? + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.rs b/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.rs new file mode 100644 index 00000000000..789bdfb414d --- /dev/null +++ b/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.rs @@ -0,0 +1,76 @@ +// Copyright 2015 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. + +// Beginners write `mod.item` when they should write `mod::item`. +// This tests that we suggest the latter when we encounter the former. + +pub mod a { + pub const I: i32 = 1; + + pub fn f() -> i32 { 2 } + + pub mod b { + pub const J: i32 = 3; + + pub fn g() -> i32 { 4 } + } +} + +fn h1() -> i32 { + a.I + //~^ ERROR expected value, found module `a` + //~| NOTE did you mean `a::I`? +} + +fn h2() -> i32 { + a.g() + //~^ ERROR expected value, found module `a` + //~| NOTE did you mean `a::g(...)`? +} + +fn h3() -> i32 { + a.b.J + //~^ ERROR expected value, found module `a` + //~| NOTE did you mean `a::b`? +} + +fn h4() -> i32 { + a::b.J + //~^ ERROR expected value, found module `a::b` + //~| NOTE did you mean `a::b::J`? +} + +fn h5() { + a.b.f(); + //~^ ERROR expected value, found module `a` + //~| NOTE did you mean `a::b`? + let v = Vec::new(); + v.push(a::b); + //~^ ERROR expected value, found module `a::b` + //~| NOTE not a value +} + +fn h6() -> i32 { + a::b.f() + //~^ ERROR expected value, found module `a::b` + //~| NOTE did you mean `a::b::f(...)`? +} + +fn h7() { + a::b + //~^ ERROR expected value, found module `a::b` + //~| NOTE not a value +} + +fn h8() -> i32 { + a::b() + //~^ ERROR expected function, found module `a::b` + //~| NOTE not a function +} diff --git a/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr b/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr new file mode 100644 index 00000000000..bd98223ffd2 --- /dev/null +++ b/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr @@ -0,0 +1,76 @@ +error[E0425]: unresolved name `a` + --> $DIR/suggest-path-instead-of-mod-dot-item.rs:27:5 + | +27 | a.I + | ^ unresolved name + | + = help: to reference an item from the `a` module, use `a::I` + +error[E0425]: unresolved name `a` + --> $DIR/suggest-path-instead-of-mod-dot-item.rs:33:5 + | +33 | a.g() + | ^ unresolved name + | + = help: to call a function from the `a` module, use `a::g(..)` + +error[E0425]: unresolved name `a` + --> $DIR/suggest-path-instead-of-mod-dot-item.rs:39:5 + | +39 | a.b.J + | ^ unresolved name + | + = help: to reference an item from the `a` module, use `a::b` + +error[E0425]: unresolved name `a::b` + --> $DIR/suggest-path-instead-of-mod-dot-item.rs:45:5 + | +45 | a::b.J + | ^^^^ unresolved name + | + = help: to reference an item from the `a::b` module, use `a::b::J` + +error[E0425]: unresolved name `a` + --> $DIR/suggest-path-instead-of-mod-dot-item.rs:51:5 + | +51 | a.b.f(); + | ^ unresolved name + | + = help: to reference an item from the `a` module, use `a::b` + +error[E0425]: unresolved name `a::b` + --> $DIR/suggest-path-instead-of-mod-dot-item.rs:55:12 + | +55 | v.push(a::b); + | ^^^^ unresolved name + | + = help: module `a::b` cannot be used as an expression + +error[E0425]: unresolved name `a::b` + --> $DIR/suggest-path-instead-of-mod-dot-item.rs:61:5 + | +61 | a::b.f() + | ^^^^ unresolved name + | + = help: to call a function from the `a::b` module, use `a::b::f(..)` + +error[E0425]: unresolved name `a::b` + --> $DIR/suggest-path-instead-of-mod-dot-item.rs:67:5 + | +67 | a::b + | ^^^^ unresolved name + | + = help: module `a::b` cannot be used as an expression + +error[E0425]: unresolved name `a::b` + --> $DIR/suggest-path-instead-of-mod-dot-item.rs:73:5 + | +73 | a::b() + | ^^^^ unresolved name + | + = help: module `a::b` cannot be used as an expression + +error: main function not found + +error: aborting due to 10 previous errors + diff --git a/src/test/ui/resolve/token-error-correct-2.rs b/src/test/ui/resolve/token-error-correct-2.rs new file mode 100644 index 00000000000..6fa1260d180 --- /dev/null +++ b/src/test/ui/resolve/token-error-correct-2.rs @@ -0,0 +1,19 @@ +// Copyright 2016 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. + +// Test that we do some basic error correcton in the tokeniser (and don't ICE). + +fn main() { + if foo { + //~^ NOTE: unclosed delimiter + //~| ERROR: unresolved value `foo` + //~| NOTE: no resolution found + ) //~ ERROR: incorrect close delimiter: `)` +} diff --git a/src/test/ui/resolve/token-error-correct-2.stderr b/src/test/ui/resolve/token-error-correct-2.stderr new file mode 100644 index 00000000000..77927b14e8c --- /dev/null +++ b/src/test/ui/resolve/token-error-correct-2.stderr @@ -0,0 +1,20 @@ +error: incorrect close delimiter: `)` + --> $DIR/token-error-correct-2.rs:18:5 + | +18 | ) //~ ERROR: incorrect close delimiter: `)` + | ^ + | +note: unclosed delimiter + --> $DIR/token-error-correct-2.rs:14:12 + | +14 | if foo { + | ^ + +error[E0425]: unresolved name `foo` + --> $DIR/token-error-correct-2.rs:14:8 + | +14 | if foo { + | ^^^ unresolved name + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/resolve/token-error-correct-3.rs b/src/test/ui/resolve/token-error-correct-3.rs new file mode 100644 index 00000000000..f72b7adf593 --- /dev/null +++ b/src/test/ui/resolve/token-error-correct-3.rs @@ -0,0 +1,38 @@ +// Copyright 2016 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. + +// Test that we do some basic error correcton in the tokeniser (and don't spew +// too many bogus errors). + +pub mod raw { + use std::{io, fs}; + use std::path::Path; + + pub fn ensure_dir_exists<P: AsRef<Path>, F: FnOnce(&Path)>(path: P, + callback: F) + -> io::Result<bool> { + if !is_directory(path.as_ref()) { //~ ERROR: unresolved function `is_directory` + //~^ NOTE: no resolution found + callback(path.as_ref(); //~ NOTE: unclosed delimiter + //~^ ERROR: expected one of + fs::create_dir_all(path.as_ref()).map(|()| true) //~ ERROR: mismatched types + //~^ expected (), found enum `std::result::Result` + //~| expected type `()` + //~| found type `std::result::Result<bool, std::io::Error>` + } else { //~ ERROR: incorrect close delimiter: `}` + //~^ ERROR: expected one of + Ok(false); + } + + panic!(); + } +} + +fn main() {} diff --git a/src/test/ui/resolve/token-error-correct-3.stderr b/src/test/ui/resolve/token-error-correct-3.stderr new file mode 100644 index 00000000000..e210449a398 --- /dev/null +++ b/src/test/ui/resolve/token-error-correct-3.stderr @@ -0,0 +1,41 @@ +error: incorrect close delimiter: `}` + --> $DIR/token-error-correct-3.rs:29:9 + | +29 | } else { //~ ERROR: incorrect close delimiter: `}` + | ^ + | +note: unclosed delimiter + --> $DIR/token-error-correct-3.rs:23:21 + | +23 | callback(path.as_ref(); //~ NOTE: unclosed delimiter + | ^ + +error: expected one of `,`, `.`, `?`, or an operator, found `;` + --> $DIR/token-error-correct-3.rs:23:35 + | +23 | callback(path.as_ref(); //~ NOTE: unclosed delimiter + | ^ + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)` + --> $DIR/token-error-correct-3.rs:29:9 + | +29 | } else { //~ ERROR: incorrect close delimiter: `}` + | ^ + +error[E0425]: unresolved name `is_directory` + --> $DIR/token-error-correct-3.rs:21:13 + | +21 | if !is_directory(path.as_ref()) { //~ ERROR: unresolved function `is_directory` + | ^^^^^^^^^^^^ unresolved name + +error[E0308]: mismatched types + --> $DIR/token-error-correct-3.rs:25:13 + | +25 | fs::create_dir_all(path.as_ref()).map(|()| true) //~ ERROR: mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `std::result::Result` + | + = note: expected type `()` + = note: found type `std::result::Result<bool, std::io::Error>` + +error: aborting due to previous error + diff --git a/src/test/ui/resolve/token-error-correct.rs b/src/test/ui/resolve/token-error-correct.rs new file mode 100644 index 00000000000..5fd35e51336 --- /dev/null +++ b/src/test/ui/resolve/token-error-correct.rs @@ -0,0 +1,26 @@ +// Copyright 2016 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. + +// Test that we do some basic error correcton in the tokeniser. + +fn main() { + foo(bar(; + //~^ NOTE: unclosed delimiter + //~| NOTE: unclosed delimiter + //~| ERROR: expected expression, found `;` + //~| ERROR: unresolved function `foo` + //~| NOTE: no resolution found + //~| ERROR: unresolved function `bar` + //~| NOTE: no resolution found + //~| ERROR: expected one of `)`, `,`, `.`, `<`, `?` +} +//~^ ERROR: incorrect close delimiter: `}` +//~| ERROR: incorrect close delimiter: `}` +//~| ERROR: expected expression, found `)` diff --git a/src/test/ui/resolve/token-error-correct.stderr b/src/test/ui/resolve/token-error-correct.stderr new file mode 100644 index 00000000000..d8af4e842a3 --- /dev/null +++ b/src/test/ui/resolve/token-error-correct.stderr @@ -0,0 +1,56 @@ +error: incorrect close delimiter: `}` + --> $DIR/token-error-correct.rs:23:1 + | +23 | } + | ^ + | +note: unclosed delimiter + --> $DIR/token-error-correct.rs:14:12 + | +14 | foo(bar(; + | ^ + +error: incorrect close delimiter: `}` + --> $DIR/token-error-correct.rs:23:1 + | +23 | } + | ^ + | +note: unclosed delimiter + --> $DIR/token-error-correct.rs:14:8 + | +14 | foo(bar(; + | ^ + +error: expected expression, found `;` + --> $DIR/token-error-correct.rs:14:13 + | +14 | foo(bar(; + | ^ + +error: expected one of `)`, `,`, `.`, `<`, `?`, `break`, `continue`, `false`, `for`, `if`, `loop`, `match`, `move`, `return`, `true`, `unsafe`, `while`, or an operator, found `;` + --> $DIR/token-error-correct.rs:14:13 + | +14 | foo(bar(; + | ^ + +error: expected expression, found `)` + --> $DIR/token-error-correct.rs:23:1 + | +23 | } + | ^ + +error[E0425]: unresolved name `foo` + --> $DIR/token-error-correct.rs:14:5 + | +14 | foo(bar(; + | ^^^ unresolved name + +error[E0425]: unresolved name `bar` + --> $DIR/token-error-correct.rs:14:9 + | +14 | foo(bar(; + | ^^^ unresolved name + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/resolve/unboxed-closure-sugar-nonexistent-trait.rs b/src/test/ui/resolve/unboxed-closure-sugar-nonexistent-trait.rs new file mode 100644 index 00000000000..57f6ddd2d3c --- /dev/null +++ b/src/test/ui/resolve/unboxed-closure-sugar-nonexistent-trait.rs @@ -0,0 +1,21 @@ +// Copyright 2014 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. + +fn f<F:Nonexist(isize) -> isize>(x: F) {} +//~^ ERROR unresolved trait `Nonexist` +//~| NOTE no resolution found + +type Typedef = isize; + +fn g<F:Typedef(isize) -> isize>(x: F) {} +//~^ ERROR expected trait, found type alias `Typedef` +//~| NOTE type aliases cannot be used for traits + +fn main() {} diff --git a/src/test/ui/resolve/unboxed-closure-sugar-nonexistent-trait.stderr b/src/test/ui/resolve/unboxed-closure-sugar-nonexistent-trait.stderr new file mode 100644 index 00000000000..a21c114c3b1 --- /dev/null +++ b/src/test/ui/resolve/unboxed-closure-sugar-nonexistent-trait.stderr @@ -0,0 +1,18 @@ +error[E0405]: trait `Nonexist` is not in scope + --> $DIR/unboxed-closure-sugar-nonexistent-trait.rs:11:8 + | +11 | fn f<F:Nonexist(isize) -> isize>(x: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ `Nonexist` is not in scope + | + = help: no candidates by the name of `Nonexist` found in your project; maybe you misspelled the name or forgot to import an external crate? + +error[E0404]: `Typedef` is not a trait + --> $DIR/unboxed-closure-sugar-nonexistent-trait.rs:17:8 + | +17 | fn g<F:Typedef(isize) -> isize>(x: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ expected trait, found type alias + | + = note: type aliases cannot be used for traits + +error: cannot continue compilation due to previous error + diff --git a/src/test/ui/resolve/unresolved_static_type_field.rs b/src/test/ui/resolve/unresolved_static_type_field.rs new file mode 100644 index 00000000000..19beabd8823 --- /dev/null +++ b/src/test/ui/resolve/unresolved_static_type_field.rs @@ -0,0 +1,27 @@ +// Copyright 2016 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. + +fn f(_: bool) {} + +struct Foo { + cx: bool, +} + +impl Foo { + fn bar() { + f(cx); + //~^ ERROR unresolved value `cx` + //~| ERROR unresolved value `cx` + //~| NOTE did you mean `self.cx`? + //~| NOTE `self` value is only available in methods with `self` parameter + } +} + +fn main() {} diff --git a/src/test/ui/resolve/unresolved_static_type_field.stderr b/src/test/ui/resolve/unresolved_static_type_field.stderr new file mode 100644 index 00000000000..ffda25db3b7 --- /dev/null +++ b/src/test/ui/resolve/unresolved_static_type_field.stderr @@ -0,0 +1,10 @@ +error[E0425]: unresolved name `cx` + --> $DIR/unresolved_static_type_field.rs:19:11 + | +19 | f(cx); + | ^^ unresolved name + | + = help: this is an associated function, you don't have access to this type's fields or methods + +error: aborting due to previous error + |
