Skip to content

Commit d3f8b8b

Browse files
committed
Move hygiene tests to UI
1 parent 4f69b7f commit d3f8b8b

25 files changed

+223
-0
lines changed
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0407]: method `method` is not a member of trait `Tr`
2+
--> $DIR/assoc_item_ctxt.rs:45:13
3+
|
4+
LL | fn method() {} //~ ERROR method `method` is not a member of trait `Tr`
5+
| ^^^^^^^^^^^^^^ not a member of trait `Tr`
6+
...
7+
LL | mac_trait_impl!();
8+
| ------------------ in this macro invocation
9+
10+
error[E0046]: not all trait items implemented, missing: `method`
11+
--> $DIR/assoc_item_ctxt.rs:44:9
12+
|
13+
LL | fn method();
14+
| ------------ `method` from trait
15+
...
16+
LL | impl Tr for u8 { //~ ERROR not all trait items implemented, missing: `method`
17+
| ^^^^^^^^^^^^^^ missing `method` in implementation
18+
...
19+
LL | mac_trait_impl!();
20+
| ------------------ in this macro invocation
21+
22+
error: aborting due to 2 previous errors
23+
24+
Some errors occurred: E0046, E0407.
25+
For more information about an error, try `rustc --explain E0046`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: compilation successful
2+
--> $DIR/assoc_ty_bindings.rs:49:1
3+
|
4+
LL | fn main() {} //~ ERROR compilation successful
5+
| ^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

src/test/ui/hygiene/fields.stderr

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
error: type `foo::S` is private
2+
--> $DIR/fields.rs:25:17
3+
|
4+
LL | let s = S { x: 0 }; //~ ERROR type `foo::S` is private
5+
| ^^^^^^^^^^
6+
...
7+
LL | let s = foo::m!(S, x);
8+
| ------------- in this macro invocation
9+
10+
error: type `foo::S` is private
11+
--> $DIR/fields.rs:26:17
12+
|
13+
LL | let _ = s.x; //~ ERROR type `foo::S` is private
14+
| ^
15+
...
16+
LL | let s = foo::m!(S, x);
17+
| ------------- in this macro invocation
18+
19+
error: type `foo::T` is private
20+
--> $DIR/fields.rs:28:17
21+
|
22+
LL | let t = T(0); //~ ERROR type `foo::T` is private
23+
| ^^^^
24+
...
25+
LL | let s = foo::m!(S, x);
26+
| ------------- in this macro invocation
27+
28+
error: type `foo::T` is private
29+
--> $DIR/fields.rs:29:17
30+
|
31+
LL | let _ = t.0; //~ ERROR type `foo::T` is private
32+
| ^
33+
...
34+
LL | let s = foo::m!(S, x);
35+
| ------------- in this macro invocation
36+
37+
error: aborting due to 4 previous errors
38+

src/test/ui/hygiene/for-loop.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0425]: cannot find value `iter` in this scope
2+
--> $DIR/for-loop.rs:16:9
3+
|
4+
LL | iter.next(); //~ ERROR cannot find value `iter` in this scope
5+
| ^^^^ not found in this scope
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0425`.
File renamed without changes.

src/test/ui/hygiene/globs.stderr

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
error[E0425]: cannot find function `f` in this scope
2+
--> $DIR/globs.rs:32:9
3+
|
4+
LL | f(); //~ ERROR cannot find function `f` in this scope
5+
| ^ not found in this scope
6+
help: possible candidates are found in other modules, you can import them into scope
7+
|
8+
LL | use foo::f;
9+
|
10+
LL | use foo::f;
11+
|
12+
LL | use foo::f;
13+
|
14+
15+
error[E0425]: cannot find function `g` in this scope
16+
--> $DIR/globs.rs:25:5
17+
|
18+
LL | g(); //~ ERROR cannot find function `g` in this scope
19+
| ^ not found in this scope
20+
...
21+
LL | / m! {
22+
LL | | use bar::*;
23+
LL | | g();
24+
LL | | f(); //~ ERROR cannot find function `f` in this scope
25+
LL | | }
26+
| |_____- in this macro invocation
27+
help: possible candidates are found in other modules, you can import them into scope
28+
|
29+
LL | use bar::g;
30+
|
31+
LL | use foo::test2::test::g;
32+
|
33+
LL | use foo::test::g;
34+
|
35+
LL | use foo::test::g;
36+
|
37+
38+
error[E0425]: cannot find function `f` in this scope
39+
--> $DIR/globs.rs:64:17
40+
|
41+
LL | n!(f);
42+
| ------ in this macro invocation
43+
...
44+
LL | f //~ ERROR cannot find function `f` in this scope
45+
| ^ not found in this scope
46+
47+
error: aborting due to 3 previous errors
48+
49+
For more information about this error, try `rustc --explain E0425`.

src/test/ui/hygiene/impl_items.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: type `for<'r> fn(&'r foo::S) {foo::S::f}` is private
2+
--> $DIR/impl_items.rs:22:23
3+
|
4+
LL | let _: () = S.f(); //~ ERROR type `for<'r> fn(&'r foo::S) {foo::S::f}` is private
5+
| ^
6+
...
7+
LL | foo::m!();
8+
| ---------- in this macro invocation
9+
10+
error: aborting due to previous error
11+

src/test/ui/hygiene/intercrate.stderr

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: type `fn() -> u32 {intercrate::foo::bar::f}` is private
2+
--> $DIR/intercrate.rs:22:16
3+
|
4+
LL | assert_eq!(intercrate::foo::m!(), 1);
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
8+
9+
error: aborting due to previous error
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0616]: field `i` of struct `foo::S` is private
2+
--> $DIR/nested_macro_privacy.rs:25:5
3+
|
4+
LL | S::default().i; //~ ERROR field `i` of struct `foo::S` is private
5+
| ^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0616`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
error[E0433]: failed to resolve. Use of undeclared type or module `Vec`
2+
--> $DIR/no_implicit_prelude.rs:21:9
3+
|
4+
LL | fn f() { ::bar::m!(); }
5+
| ------------ in this macro invocation
6+
...
7+
LL | Vec::new(); //~ ERROR failed to resolve
8+
| ^^^ Use of undeclared type or module `Vec`
9+
10+
error[E0601]: `main` function not found in crate `no_implicit_prelude`
11+
|
12+
= note: consider adding a `main` function to `$DIR/no_implicit_prelude.rs`
13+
14+
error[E0599]: no method named `clone` found for type `()` in the current scope
15+
--> $DIR/no_implicit_prelude.rs:22:12
16+
|
17+
LL | fn f() { ::bar::m!(); }
18+
| ------------ in this macro invocation
19+
...
20+
LL | ().clone() //~ ERROR no method named `clone` found
21+
| ^^^^^
22+
|
23+
= help: items from traits can only be used if the trait is in scope
24+
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
25+
candidate #1: `use std::clone::Clone;`
26+
27+
error: aborting due to 3 previous errors
28+
29+
Some errors occurred: E0433, E0599, E0601.
30+
For more information about an error, try `rustc --explain E0433`.
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0425]: cannot find value `x` in this scope
2+
--> $DIR/pattern-macro.rs:15:5
3+
|
4+
LL | x + 1; //~ ERROR cannot find value `x` in this scope
5+
| ^ not found in this scope
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0425`.

src/test/ui/hygiene/privacy.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0603]: function `f` is private
2+
--> $DIR/privacy.rs:26:9
3+
|
4+
LL | foo::f() //~ ERROR `f` is private
5+
| ^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0603`.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0599]: no method named `f` found for type `()` in the current scope
2+
--> $DIR/trait_items.rs:27:24
3+
|
4+
LL | fn f() { ::baz::m!(); }
5+
| ------------ in this macro invocation
6+
...
7+
LL | pub macro m() { ().f() } //~ ERROR no method named `f` found for type `()` in the current scope
8+
| ^
9+
|
10+
= help: items from traits can only be used if the trait is in scope
11+
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
12+
candidate #1: `use foo::T;`
13+
14+
error: aborting due to previous error
15+
16+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)