Skip to content

Commit

Permalink
Add comments to hygiene tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjasper committed Oct 28, 2021
1 parent d8426ea commit a76a2d4
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/test/ui/hygiene/cross-crate-define-and-use.rs
@@ -1,3 +1,8 @@
// Check that a marco from another crate can define an item in one expansion
// and use it from another, without it being visible to everyone.
// This requires that the definition of `my_struct` preserves the hygiene
// information for the tokens in its definition.

// check-pass
// aux-build:use_by_macro.rs

Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/hygiene/cross-crate-fields.rs
@@ -1,3 +1,6 @@
// Test that fields on a struct defined in another crate are resolved correctly
// their names differ only in `SyntaxContext`.

// run-pass
// aux-build:fields.rs

Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/hygiene/cross-crate-glob-hygiene.rs
@@ -1,3 +1,8 @@
// Check that globs cannot import hygienic identifiers from a macro expansion
// in another crate. `my_struct` is a `macro_rules` macro, so the struct it
// defines is only not imported because `my_struct` is defined by a macros 2.0
// macro.

// aux-build:use_by_macro.rs

extern crate use_by_macro;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/hygiene/cross-crate-glob-hygiene.stderr
@@ -1,5 +1,5 @@
error[E0422]: cannot find struct, variant or union type `MyStruct` in this scope
--> $DIR/cross-crate-glob-hygiene.rs:16:13
--> $DIR/cross-crate-glob-hygiene.rs:21:13
|
LL | let x = my_struct!(create);
| ^^^^^^^^^^^^^^^^^^ not found in this scope
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/hygiene/cross-crate-methods.rs
@@ -1,3 +1,7 @@
// Test that methods defined in another crate are resolved correctly their
// names differ only in `SyntaxContext`. This also checks that any name
// resolution done when monomorphizing is correct.

// run-pass
// aux-build:methods.rs

Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/hygiene/cross-crate-name-collision.rs
@@ -1,3 +1,7 @@
// Check that two items defined in another crate that have identifiers that
// only differ by `SyntaxContext` do not cause name collisions when imported
// in another crate.

// check-pass
// aux-build:needs_hygiene.rs

Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/hygiene/cross-crate-name-hiding-2.rs
@@ -1,3 +1,6 @@
// Check that an identifier from a 2.0 macro in another crate cannot be
// resolved with an identifier that's not from a macro expansion.

// aux-build:use_by_macro.rs

extern crate use_by_macro;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/hygiene/cross-crate-name-hiding-2.stderr
@@ -1,5 +1,5 @@
error[E0422]: cannot find struct, variant or union type `MyStruct` in this scope
--> $DIR/cross-crate-name-hiding-2.rs:10:13
--> $DIR/cross-crate-name-hiding-2.rs:13:13
|
LL | let x = MyStruct {};
| ^^^^^^^^ not found in this scope
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/hygiene/cross-crate-name-hiding.rs
@@ -1,3 +1,6 @@
// Check that an item defined by a 2.0 macro in another crate cannot be used in
// another crate.

// aux-build:pub_hygiene.rs

extern crate pub_hygiene;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/hygiene/cross-crate-name-hiding.stderr
@@ -1,5 +1,5 @@
error[E0422]: cannot find struct, variant or union type `MyStruct` in this scope
--> $DIR/cross-crate-name-hiding.rs:8:13
--> $DIR/cross-crate-name-hiding.rs:11:13
|
LL | let x = MyStruct {};
| ^^^^^^^^ not found in this scope
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/hygiene/cross-crate-redefine.rs
@@ -1,3 +1,6 @@
// Check that items with identical `SyntaxContext` conflict even when that
// context involves a mark from another crate.

// aux-build:use_by_macro.rs

extern crate use_by_macro;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/hygiene/cross-crate-redefine.stderr
@@ -1,5 +1,5 @@
error[E0428]: the name `MyStruct` is defined multiple times
--> $DIR/cross-crate-redefine.rs:7:1
--> $DIR/cross-crate-redefine.rs:10:1
|
LL | my_struct!(define);
| ^^^^^^^^^^^^^^^^^^ `MyStruct` redefined here
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/hygiene/cross-crate-variants.rs
@@ -1,3 +1,6 @@
// Test that variants of an enum defined in another crate are resolved
// correctly when their names differ only in `SyntaxContext`.

// run-pass
// aux-build:variants.rs

Expand Down

0 comments on commit a76a2d4

Please sign in to comment.