diff options
| author | bors <bors@rust-lang.org> | 2021-09-26 05:15:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-09-26 05:15:11 +0000 |
| commit | f6e6ddc09d660fbfb4d483a9677d80768cc4e31c (patch) | |
| tree | 61b3e7fda85f83fa96d221012da392502e7d1cf6 /src/test/ui/modules | |
| parent | 4da89a180facdecf168cbe0ddbc6bfbdd9f6e696 (diff) | |
| parent | 75f058dbfd1c02daa191efb6eb53dc91fda8add6 (diff) | |
Auto merge of #88680 - ehuss:more-attr-validation, r=petrochenkov
Validate builtin attributes for macro args. This adds some validation for `path`, `crate_type`, and `recursion_limit` attributes so that they will now return an error if you attempt to pass a macro into them (such as `#[path = foo!()]`). Previously, the attribute would be completely ignored. These attributes are special because their values need to be known before/during expansion. cc #87681
Diffstat (limited to 'src/test/ui/modules')
| -rw-r--r-- | src/test/ui/modules/path-invalid-form.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/modules/path-invalid-form.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/modules/path-macro.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/modules/path-macro.stderr | 8 |
4 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/modules/path-invalid-form.rs b/src/test/ui/modules/path-invalid-form.rs new file mode 100644 index 00000000000..713ef4a795d --- /dev/null +++ b/src/test/ui/modules/path-invalid-form.rs @@ -0,0 +1,4 @@ +#[path = 123] //~ ERROR malformed `path` attribute +mod foo; + +fn main() {} diff --git a/src/test/ui/modules/path-invalid-form.stderr b/src/test/ui/modules/path-invalid-form.stderr new file mode 100644 index 00000000000..7e8aa44ef8b --- /dev/null +++ b/src/test/ui/modules/path-invalid-form.stderr @@ -0,0 +1,8 @@ +error: malformed `path` attribute input + --> $DIR/path-invalid-form.rs:1:1 + | +LL | #[path = 123] + | ^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]` + +error: aborting due to previous error + diff --git a/src/test/ui/modules/path-macro.rs b/src/test/ui/modules/path-macro.rs new file mode 100644 index 00000000000..ce2d1e2da26 --- /dev/null +++ b/src/test/ui/modules/path-macro.rs @@ -0,0 +1,8 @@ +macro_rules! foo { + () => {"bar.rs"}; +} + +#[path = foo!()] //~ ERROR malformed `path` attribute +mod abc; + +fn main() {} diff --git a/src/test/ui/modules/path-macro.stderr b/src/test/ui/modules/path-macro.stderr new file mode 100644 index 00000000000..9a2e01ea264 --- /dev/null +++ b/src/test/ui/modules/path-macro.stderr @@ -0,0 +1,8 @@ +error: malformed `path` attribute input + --> $DIR/path-macro.rs:5:1 + | +LL | #[path = foo!()] + | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]` + +error: aborting due to previous error + |
