about summary refs log tree commit diff
path: root/tests/ui/invalid
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/invalid')
-rw-r--r--tests/ui/invalid/invalid-crate-type-macro.rs7
-rw-r--r--tests/ui/invalid/invalid-crate-type-macro.stderr8
-rw-r--r--tests/ui/invalid/invalid-crate-type.rs48
-rw-r--r--tests/ui/invalid/invalid-crate-type.stderr58
-rw-r--r--tests/ui/invalid/invalid-debugger-visualizer-option.rs7
-rw-r--r--tests/ui/invalid/invalid-debugger-visualizer-option.stderr18
-rw-r--r--tests/ui/invalid/invalid-debugger-visualizer-target.rs4
-rw-r--r--tests/ui/invalid/invalid-debugger-visualizer-target.stderr8
-rw-r--r--tests/ui/invalid/invalid-inline.rs14
-rw-r--r--tests/ui/invalid/invalid-inline.stderr15
-rw-r--r--tests/ui/invalid/invalid-llvm-passes.rs4
-rw-r--r--tests/ui/invalid/invalid-llvm-passes.stderr4
-rw-r--r--tests/ui/invalid/invalid-macro-matcher.rs8
-rw-r--r--tests/ui/invalid/invalid-macro-matcher.stderr8
-rw-r--r--tests/ui/invalid/invalid-no-sanitize.rs5
-rw-r--r--tests/ui/invalid/invalid-no-sanitize.stderr10
-rw-r--r--tests/ui/invalid/invalid-path-in-const.rs4
-rw-r--r--tests/ui/invalid/invalid-path-in-const.stderr9
-rw-r--r--tests/ui/invalid/invalid-plugin-attr.rs7
-rw-r--r--tests/ui/invalid/invalid-plugin-attr.stderr22
-rw-r--r--tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs43
-rw-r--r--tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr95
-rw-r--r--tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.rs30
-rw-r--r--tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr37
24 files changed, 473 insertions, 0 deletions
diff --git a/tests/ui/invalid/invalid-crate-type-macro.rs b/tests/ui/invalid/invalid-crate-type-macro.rs
new file mode 100644
index 00000000000..9ba5e79ba94
--- /dev/null
+++ b/tests/ui/invalid/invalid-crate-type-macro.rs
@@ -0,0 +1,7 @@
+#![crate_type = foo!()] //~ ERROR malformed `crate_type` attribute
+
+macro_rules! foo {
+    () => {"rlib"};
+}
+
+fn main() {}
diff --git a/tests/ui/invalid/invalid-crate-type-macro.stderr b/tests/ui/invalid/invalid-crate-type-macro.stderr
new file mode 100644
index 00000000000..c196d4278a2
--- /dev/null
+++ b/tests/ui/invalid/invalid-crate-type-macro.stderr
@@ -0,0 +1,8 @@
+error: malformed `crate_type` attribute input
+  --> $DIR/invalid-crate-type-macro.rs:1:1
+   |
+LL | #![crate_type = foo!()]
+   | ^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_type = "bin|lib|..."]`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/invalid/invalid-crate-type.rs b/tests/ui/invalid/invalid-crate-type.rs
new file mode 100644
index 00000000000..6c44c3b4f2b
--- /dev/null
+++ b/tests/ui/invalid/invalid-crate-type.rs
@@ -0,0 +1,48 @@
+// regression test for issue 11256
+#![crate_type="foo"]    //~ ERROR invalid `crate_type` value
+
+// Tests for suggestions (#53958)
+
+#![crate_type="statoclib"]
+//~^ ERROR invalid `crate_type` value
+//~| HELP did you mean
+//~| SUGGESTION staticlib
+
+#![crate_type="procmacro"]
+//~^ ERROR invalid `crate_type` value
+//~| HELP did you mean
+//~| SUGGESTION proc-macro
+
+#![crate_type="static-lib"]
+//~^ ERROR invalid `crate_type` value
+//~| HELP did you mean
+//~| SUGGESTION staticlib
+
+#![crate_type="drylib"]
+//~^ ERROR invalid `crate_type` value
+//~| HELP did you mean
+//~| SUGGESTION dylib
+
+#![crate_type="dlib"]
+//~^ ERROR invalid `crate_type` value
+//~| HELP did you mean
+//~| SUGGESTION rlib
+
+#![crate_type="lob"]
+//~^ ERROR invalid `crate_type` value
+//~| HELP did you mean
+//~| SUGGESTION lib
+
+#![crate_type="bon"]
+//~^ ERROR invalid `crate_type` value
+//~| HELP did you mean
+//~| SUGGESTION bin
+
+#![crate_type="cdalib"]
+//~^ ERROR invalid `crate_type` value
+//~| HELP did you mean
+//~| SUGGESTION cdylib
+
+fn main() {
+    return
+}
diff --git a/tests/ui/invalid/invalid-crate-type.stderr b/tests/ui/invalid/invalid-crate-type.stderr
new file mode 100644
index 00000000000..59d5d7bc9bb
--- /dev/null
+++ b/tests/ui/invalid/invalid-crate-type.stderr
@@ -0,0 +1,58 @@
+error: invalid `crate_type` value
+  --> $DIR/invalid-crate-type.rs:2:15
+   |
+LL | #![crate_type="foo"]
+   |               ^^^^^
+   |
+   = note: `#[deny(unknown_crate_types)]` on by default
+
+error: invalid `crate_type` value
+  --> $DIR/invalid-crate-type.rs:6:15
+   |
+LL | #![crate_type="statoclib"]
+   |               ^^^^^^^^^^^ help: did you mean: `"staticlib"`
+
+error: invalid `crate_type` value
+  --> $DIR/invalid-crate-type.rs:11:15
+   |
+LL | #![crate_type="procmacro"]
+   |               ^^^^^^^^^^^ help: did you mean: `"proc-macro"`
+
+error: invalid `crate_type` value
+  --> $DIR/invalid-crate-type.rs:16:15
+   |
+LL | #![crate_type="static-lib"]
+   |               ^^^^^^^^^^^^ help: did you mean: `"staticlib"`
+
+error: invalid `crate_type` value
+  --> $DIR/invalid-crate-type.rs:21:15
+   |
+LL | #![crate_type="drylib"]
+   |               ^^^^^^^^ help: did you mean: `"dylib"`
+
+error: invalid `crate_type` value
+  --> $DIR/invalid-crate-type.rs:26:15
+   |
+LL | #![crate_type="dlib"]
+   |               ^^^^^^ help: did you mean: `"rlib"`
+
+error: invalid `crate_type` value
+  --> $DIR/invalid-crate-type.rs:31:15
+   |
+LL | #![crate_type="lob"]
+   |               ^^^^^ help: did you mean: `"lib"`
+
+error: invalid `crate_type` value
+  --> $DIR/invalid-crate-type.rs:36:15
+   |
+LL | #![crate_type="bon"]
+   |               ^^^^^ help: did you mean: `"bin"`
+
+error: invalid `crate_type` value
+  --> $DIR/invalid-crate-type.rs:41:15
+   |
+LL | #![crate_type="cdalib"]
+   |               ^^^^^^^^ help: did you mean: `"cdylib"`
+
+error: aborting due to 9 previous errors
+
diff --git a/tests/ui/invalid/invalid-debugger-visualizer-option.rs b/tests/ui/invalid/invalid-debugger-visualizer-option.rs
new file mode 100644
index 00000000000..5645a30ccee
--- /dev/null
+++ b/tests/ui/invalid/invalid-debugger-visualizer-option.rs
@@ -0,0 +1,7 @@
+// normalize-stderr-test: "foo.random:.*\(" -> "foo.random: $$FILE_NOT_FOUND_MSG ("
+// normalize-stderr-test: "os error \d+" -> "os error $$FILE_NOT_FOUND_CODE"
+
+#![feature(debugger_visualizer)]
+#![debugger_visualizer(random_file = "../foo.random")] //~ ERROR invalid argument
+#![debugger_visualizer(natvis_file = "../foo.random")] //~ ERROR
+fn main() {}
diff --git a/tests/ui/invalid/invalid-debugger-visualizer-option.stderr b/tests/ui/invalid/invalid-debugger-visualizer-option.stderr
new file mode 100644
index 00000000000..afb8d16ee96
--- /dev/null
+++ b/tests/ui/invalid/invalid-debugger-visualizer-option.stderr
@@ -0,0 +1,18 @@
+error: invalid argument
+  --> $DIR/invalid-debugger-visualizer-option.rs:5:24
+   |
+LL | #![debugger_visualizer(random_file = "../foo.random")]
+   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: expected: `natvis_file = "..."`
+   = note: OR
+   = note: expected: `gdb_script_file = "..."`
+
+error: couldn't read $DIR/../foo.random: $FILE_NOT_FOUND_MSG (os error $FILE_NOT_FOUND_CODE)
+  --> $DIR/invalid-debugger-visualizer-option.rs:6:24
+   |
+LL | #![debugger_visualizer(natvis_file = "../foo.random")]
+   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/invalid/invalid-debugger-visualizer-target.rs b/tests/ui/invalid/invalid-debugger-visualizer-target.rs
new file mode 100644
index 00000000000..f0aba6a75c4
--- /dev/null
+++ b/tests/ui/invalid/invalid-debugger-visualizer-target.rs
@@ -0,0 +1,4 @@
+#![feature(debugger_visualizer)]
+
+#[debugger_visualizer(natvis_file = "../foo.natvis")] //~ ERROR attribute should be applied to a module
+fn main() {}
diff --git a/tests/ui/invalid/invalid-debugger-visualizer-target.stderr b/tests/ui/invalid/invalid-debugger-visualizer-target.stderr
new file mode 100644
index 00000000000..3555bbb169b
--- /dev/null
+++ b/tests/ui/invalid/invalid-debugger-visualizer-target.stderr
@@ -0,0 +1,8 @@
+error: attribute should be applied to a module
+  --> $DIR/invalid-debugger-visualizer-target.rs:3:1
+   |
+LL | #[debugger_visualizer(natvis_file = "../foo.natvis")]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/invalid/invalid-inline.rs b/tests/ui/invalid/invalid-inline.rs
new file mode 100644
index 00000000000..2501b1e23f2
--- /dev/null
+++ b/tests/ui/invalid/invalid-inline.rs
@@ -0,0 +1,14 @@
+#![allow(dead_code)]
+
+#[inline(please,no)] //~ ERROR expected one argument
+fn a() {
+}
+
+#[inline()] //~ ERROR expected one argument
+fn b() {
+}
+
+fn main() {
+    a();
+    b();
+}
diff --git a/tests/ui/invalid/invalid-inline.stderr b/tests/ui/invalid/invalid-inline.stderr
new file mode 100644
index 00000000000..7edbf936b1b
--- /dev/null
+++ b/tests/ui/invalid/invalid-inline.stderr
@@ -0,0 +1,15 @@
+error[E0534]: expected one argument
+  --> $DIR/invalid-inline.rs:3:1
+   |
+LL | #[inline(please,no)]
+   | ^^^^^^^^^^^^^^^^^^^^
+
+error[E0534]: expected one argument
+  --> $DIR/invalid-inline.rs:7:1
+   |
+LL | #[inline()]
+   | ^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0534`.
diff --git a/tests/ui/invalid/invalid-llvm-passes.rs b/tests/ui/invalid/invalid-llvm-passes.rs
new file mode 100644
index 00000000000..ee28f5eb6d6
--- /dev/null
+++ b/tests/ui/invalid/invalid-llvm-passes.rs
@@ -0,0 +1,4 @@
+// build-fail
+// compile-flags: -Cpasses=unknown-pass
+
+fn main() {}
diff --git a/tests/ui/invalid/invalid-llvm-passes.stderr b/tests/ui/invalid/invalid-llvm-passes.stderr
new file mode 100644
index 00000000000..ae1f85e41e4
--- /dev/null
+++ b/tests/ui/invalid/invalid-llvm-passes.stderr
@@ -0,0 +1,4 @@
+error: failed to run LLVM passes: unknown pass name 'unknown-pass'
+
+error: aborting due to previous error
+
diff --git a/tests/ui/invalid/invalid-macro-matcher.rs b/tests/ui/invalid/invalid-macro-matcher.rs
new file mode 100644
index 00000000000..ff79d4e1a92
--- /dev/null
+++ b/tests/ui/invalid/invalid-macro-matcher.rs
@@ -0,0 +1,8 @@
+#![allow(unused_macros)]
+
+macro_rules! invalid {
+    _ => (); //~ ERROR invalid macro matcher
+}
+
+fn main() {
+}
diff --git a/tests/ui/invalid/invalid-macro-matcher.stderr b/tests/ui/invalid/invalid-macro-matcher.stderr
new file mode 100644
index 00000000000..dbe025b7330
--- /dev/null
+++ b/tests/ui/invalid/invalid-macro-matcher.stderr
@@ -0,0 +1,8 @@
+error: invalid macro matcher; matchers must be contained in balanced delimiters
+  --> $DIR/invalid-macro-matcher.rs:4:5
+   |
+LL |     _ => ();
+   |     ^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/invalid/invalid-no-sanitize.rs b/tests/ui/invalid/invalid-no-sanitize.rs
new file mode 100644
index 00000000000..b52e3cc83fa
--- /dev/null
+++ b/tests/ui/invalid/invalid-no-sanitize.rs
@@ -0,0 +1,5 @@
+#![feature(no_sanitize)]
+
+#[no_sanitize(brontosaurus)] //~ ERROR invalid argument
+fn main() {
+}
diff --git a/tests/ui/invalid/invalid-no-sanitize.stderr b/tests/ui/invalid/invalid-no-sanitize.stderr
new file mode 100644
index 00000000000..4600034952b
--- /dev/null
+++ b/tests/ui/invalid/invalid-no-sanitize.stderr
@@ -0,0 +1,10 @@
+error: invalid argument for `no_sanitize`
+  --> $DIR/invalid-no-sanitize.rs:3:15
+   |
+LL | #[no_sanitize(brontosaurus)]
+   |               ^^^^^^^^^^^^
+   |
+   = note: expected one of: `address`, `cfi`, `hwaddress`, `kcfi`, `memory`, `memtag`, `shadow-call-stack`, or `thread`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/invalid/invalid-path-in-const.rs b/tests/ui/invalid/invalid-path-in-const.rs
new file mode 100644
index 00000000000..51eb8607211
--- /dev/null
+++ b/tests/ui/invalid/invalid-path-in-const.rs
@@ -0,0 +1,4 @@
+fn main() {
+    fn f(a: [u8; u32::DOESNOTEXIST]) {}
+    //~^ ERROR no associated item named `DOESNOTEXIST` found for type `u32`
+}
diff --git a/tests/ui/invalid/invalid-path-in-const.stderr b/tests/ui/invalid/invalid-path-in-const.stderr
new file mode 100644
index 00000000000..a14ab7d85e8
--- /dev/null
+++ b/tests/ui/invalid/invalid-path-in-const.stderr
@@ -0,0 +1,9 @@
+error[E0599]: no associated item named `DOESNOTEXIST` found for type `u32` in the current scope
+  --> $DIR/invalid-path-in-const.rs:2:23
+   |
+LL |     fn f(a: [u8; u32::DOESNOTEXIST]) {}
+   |                       ^^^^^^^^^^^^ associated item not found in `u32`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/tests/ui/invalid/invalid-plugin-attr.rs b/tests/ui/invalid/invalid-plugin-attr.rs
new file mode 100644
index 00000000000..3080af24500
--- /dev/null
+++ b/tests/ui/invalid/invalid-plugin-attr.rs
@@ -0,0 +1,7 @@
+#![deny(unused_attributes)]
+#![feature(plugin)]
+
+#[plugin(bla)] //~ ERROR should be an inner attribute
+//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated
+
+fn main() {}
diff --git a/tests/ui/invalid/invalid-plugin-attr.stderr b/tests/ui/invalid/invalid-plugin-attr.stderr
new file mode 100644
index 00000000000..d3882d33fc4
--- /dev/null
+++ b/tests/ui/invalid/invalid-plugin-attr.stderr
@@ -0,0 +1,22 @@
+warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
+  --> $DIR/invalid-plugin-attr.rs:4:1
+   |
+LL | #[plugin(bla)]
+   | ^^^^^^^^^^^^^^ help: may be removed in a future compiler version
+   |
+   = note: `#[warn(deprecated)]` on by default
+
+error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
+  --> $DIR/invalid-plugin-attr.rs:4:1
+   |
+LL | #[plugin(bla)]
+   | ^^^^^^^^^^^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/invalid-plugin-attr.rs:1:9
+   |
+LL | #![deny(unused_attributes)]
+   |         ^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error; 1 warning emitted
+
diff --git a/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs b/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs
new file mode 100644
index 00000000000..6eabd9b1015
--- /dev/null
+++ b/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs
@@ -0,0 +1,43 @@
+#![feature(rustc_attrs)]
+
+#[rustc_legacy_const_generics(0)] //~ ERROR #[rustc_legacy_const_generics] must have one index for
+fn foo1() {}
+
+#[rustc_legacy_const_generics(1)] //~ ERROR index exceeds number of arguments
+fn foo2<const X: usize>() {}
+
+#[rustc_legacy_const_generics(2)] //~ ERROR index exceeds number of arguments
+fn foo3<const X: usize>(_: u8) {}
+
+#[rustc_legacy_const_generics(a)] //~ ERROR arguments should be non-negative integers
+fn foo4<const X: usize>() {}
+
+#[rustc_legacy_const_generics(1, a, 2, b)] //~ ERROR arguments should be non-negative integers
+fn foo5<const X: usize, const Y: usize, const Z: usize, const W: usize>() {}
+
+#[rustc_legacy_const_generics(0)] //~ ERROR attribute should be applied to a function
+struct S;
+
+#[rustc_legacy_const_generics(0usize)] //~ ERROR suffixed literals are not allowed in attributes
+fn foo6<const X: usize>() {}
+
+extern {
+    #[rustc_legacy_const_generics(1)] //~ ERROR attribute should be applied to a function
+    fn foo7<const X: usize>(); //~ ERROR foreign items may not have const parameters
+}
+
+#[rustc_legacy_const_generics(0)] //~ ERROR #[rustc_legacy_const_generics] functions must only have
+fn foo8<X>() {}
+
+impl S {
+    #[rustc_legacy_const_generics(0)] //~ ERROR attribute should be applied to a function
+    fn foo9<const X: usize>() {}
+}
+
+#[rustc_legacy_const_generics] //~ ERROR malformed `rustc_legacy_const_generics` attribute
+fn bar1() {}
+
+#[rustc_legacy_const_generics = 1] //~ ERROR malformed `rustc_legacy_const_generics` attribute
+fn bar2() {}
+
+fn main() {}
diff --git a/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr b/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr
new file mode 100644
index 00000000000..1ced1433fe9
--- /dev/null
+++ b/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr
@@ -0,0 +1,95 @@
+error: suffixed literals are not allowed in attributes
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:21:31
+   |
+LL | #[rustc_legacy_const_generics(0usize)]
+   |                               ^^^^^^
+   |
+   = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
+
+error: malformed `rustc_legacy_const_generics` attribute input
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:37:1
+   |
+LL | #[rustc_legacy_const_generics]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]`
+
+error: malformed `rustc_legacy_const_generics` attribute input
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:40:1
+   |
+LL | #[rustc_legacy_const_generics = 1]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]`
+
+error: #[rustc_legacy_const_generics] must have one index for each generic parameter
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:3:1
+   |
+LL | #[rustc_legacy_const_generics(0)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | fn foo1() {}
+   |        - generic parameters
+
+error: index exceeds number of arguments
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:6:31
+   |
+LL | #[rustc_legacy_const_generics(1)]
+   |                               ^ there is only 1 argument
+
+error: index exceeds number of arguments
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:9:31
+   |
+LL | #[rustc_legacy_const_generics(2)]
+   |                               ^ there are only 2 arguments
+
+error: arguments should be non-negative integers
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:12:31
+   |
+LL | #[rustc_legacy_const_generics(a)]
+   |                               ^
+
+error: arguments should be non-negative integers
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:15:34
+   |
+LL | #[rustc_legacy_const_generics(1, a, 2, b)]
+   |                                  ^     ^
+
+error: attribute should be applied to a function definition
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:18:1
+   |
+LL | #[rustc_legacy_const_generics(0)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | struct S;
+   | --------- not a function definition
+
+error: #[rustc_legacy_const_generics] functions must only have const generics
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:29:1
+   |
+LL | #[rustc_legacy_const_generics(0)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | fn foo8<X>() {}
+   |         - non-const generic parameter
+
+error: attribute should be applied to a function definition
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:33:5
+   |
+LL |     #[rustc_legacy_const_generics(0)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     fn foo9<const X: usize>() {}
+   |     ---------------------------- not a function definition
+
+error: attribute should be applied to a function definition
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:25:5
+   |
+LL |     #[rustc_legacy_const_generics(1)]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     fn foo7<const X: usize>();
+   |     -------------------------- not a function definition
+
+error[E0044]: foreign items may not have const parameters
+  --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:26:5
+   |
+LL |     fn foo7<const X: usize>();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't have const parameters
+   |
+   = help: replace the const parameters with concrete consts
+
+error: aborting due to 13 previous errors
+
+For more information about this error, try `rustc --explain E0044`.
diff --git a/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.rs b/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.rs
new file mode 100644
index 00000000000..06cf8c0f0f6
--- /dev/null
+++ b/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.rs
@@ -0,0 +1,30 @@
+#![feature(rustc_attrs)]
+
+#[rustc_layout_scalar_valid_range_start(u32::MAX)] //~ ERROR
+pub struct A(u32);
+
+#[rustc_layout_scalar_valid_range_end(1, 2)] //~ ERROR
+pub struct B(u8);
+
+#[rustc_layout_scalar_valid_range_end(a = "a")] //~ ERROR
+pub struct C(i32);
+
+#[rustc_layout_scalar_valid_range_end(1)] //~ ERROR
+enum E {
+    X = 1,
+    Y = 14,
+}
+
+#[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)] //~ ERROR
+struct NonZero<T>(T);
+
+fn not_field() -> impl Send {
+    NonZero(false)
+}
+
+fn main() {
+    let _ = A(0);
+    let _ = B(0);
+    let _ = C(0);
+    let _ = E::X;
+}
diff --git a/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr b/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr
new file mode 100644
index 00000000000..7879e7358c0
--- /dev/null
+++ b/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr
@@ -0,0 +1,37 @@
+error: expected exactly one integer literal argument
+  --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:3:1
+   |
+LL | #[rustc_layout_scalar_valid_range_start(u32::MAX)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: expected exactly one integer literal argument
+  --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:6:1
+   |
+LL | #[rustc_layout_scalar_valid_range_end(1, 2)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: expected exactly one integer literal argument
+  --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:9:1
+   |
+LL | #[rustc_layout_scalar_valid_range_end(a = "a")]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: attribute should be applied to a struct
+  --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:12:1
+   |
+LL |   #[rustc_layout_scalar_valid_range_end(1)]
+   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | / enum E {
+LL | |     X = 1,
+LL | |     Y = 14,
+LL | | }
+   | |_- not a struct
+
+error: expected exactly one integer literal argument
+  --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:18:1
+   |
+LL | #[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 5 previous errors
+