Skip to content

Commit a76a2d4

Browse files
committed
Add comments to hygiene tests
1 parent d8426ea commit a76a2d4

13 files changed

+37
-4
lines changed

src/test/ui/hygiene/cross-crate-define-and-use.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Check that a marco from another crate can define an item in one expansion
2+
// and use it from another, without it being visible to everyone.
3+
// This requires that the definition of `my_struct` preserves the hygiene
4+
// information for the tokens in its definition.
5+
16
// check-pass
27
// aux-build:use_by_macro.rs
38

src/test/ui/hygiene/cross-crate-fields.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Test that fields on a struct defined in another crate are resolved correctly
2+
// their names differ only in `SyntaxContext`.
3+
14
// run-pass
25
// aux-build:fields.rs
36

src/test/ui/hygiene/cross-crate-glob-hygiene.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Check that globs cannot import hygienic identifiers from a macro expansion
2+
// in another crate. `my_struct` is a `macro_rules` macro, so the struct it
3+
// defines is only not imported because `my_struct` is defined by a macros 2.0
4+
// macro.
5+
16
// aux-build:use_by_macro.rs
27

38
extern crate use_by_macro;

src/test/ui/hygiene/cross-crate-glob-hygiene.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0422]: cannot find struct, variant or union type `MyStruct` in this scope
2-
--> $DIR/cross-crate-glob-hygiene.rs:16:13
2+
--> $DIR/cross-crate-glob-hygiene.rs:21:13
33
|
44
LL | let x = my_struct!(create);
55
| ^^^^^^^^^^^^^^^^^^ not found in this scope

src/test/ui/hygiene/cross-crate-methods.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Test that methods defined in another crate are resolved correctly their
2+
// names differ only in `SyntaxContext`. This also checks that any name
3+
// resolution done when monomorphizing is correct.
4+
15
// run-pass
26
// aux-build:methods.rs
37

src/test/ui/hygiene/cross-crate-name-collision.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Check that two items defined in another crate that have identifiers that
2+
// only differ by `SyntaxContext` do not cause name collisions when imported
3+
// in another crate.
4+
15
// check-pass
26
// aux-build:needs_hygiene.rs
37

src/test/ui/hygiene/cross-crate-name-hiding-2.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Check that an identifier from a 2.0 macro in another crate cannot be
2+
// resolved with an identifier that's not from a macro expansion.
3+
14
// aux-build:use_by_macro.rs
25

36
extern crate use_by_macro;

src/test/ui/hygiene/cross-crate-name-hiding-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0422]: cannot find struct, variant or union type `MyStruct` in this scope
2-
--> $DIR/cross-crate-name-hiding-2.rs:10:13
2+
--> $DIR/cross-crate-name-hiding-2.rs:13:13
33
|
44
LL | let x = MyStruct {};
55
| ^^^^^^^^ not found in this scope

src/test/ui/hygiene/cross-crate-name-hiding.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Check that an item defined by a 2.0 macro in another crate cannot be used in
2+
// another crate.
3+
14
// aux-build:pub_hygiene.rs
25

36
extern crate pub_hygiene;

src/test/ui/hygiene/cross-crate-name-hiding.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0422]: cannot find struct, variant or union type `MyStruct` in this scope
2-
--> $DIR/cross-crate-name-hiding.rs:8:13
2+
--> $DIR/cross-crate-name-hiding.rs:11:13
33
|
44
LL | let x = MyStruct {};
55
| ^^^^^^^^ not found in this scope

src/test/ui/hygiene/cross-crate-redefine.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Check that items with identical `SyntaxContext` conflict even when that
2+
// context involves a mark from another crate.
3+
14
// aux-build:use_by_macro.rs
25

36
extern crate use_by_macro;

src/test/ui/hygiene/cross-crate-redefine.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0428]: the name `MyStruct` is defined multiple times
2-
--> $DIR/cross-crate-redefine.rs:7:1
2+
--> $DIR/cross-crate-redefine.rs:10:1
33
|
44
LL | my_struct!(define);
55
| ^^^^^^^^^^^^^^^^^^ `MyStruct` redefined here

src/test/ui/hygiene/cross-crate-variants.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Test that variants of an enum defined in another crate are resolved
2+
// correctly when their names differ only in `SyntaxContext`.
3+
14
// run-pass
25
// aux-build:variants.rs
36

0 commit comments

Comments
 (0)