diff options
Diffstat (limited to 'tests')
22 files changed, 260 insertions, 39 deletions
diff --git a/tests/ui/binop/binary-op-suggest-deref.rs b/tests/ui/binop/binary-op-suggest-deref.rs index 57f24a4c28e..ae442a0d0b4 100644 --- a/tests/ui/binop/binary-op-suggest-deref.rs +++ b/tests/ui/binop/binary-op-suggest-deref.rs @@ -72,4 +72,12 @@ fn baz() { //~^ERROR can't compare `str` with `&String` [E0277] } +fn qux() { + // Issue #119352 + const FOO: i32 = 42; + let _ = FOO & (*"Sized".to_string().into_boxed_str()); + //~^ ERROR the size for values of type `str` cannot be known at compilation time + //~| ERROR no implementation for `i32 & str` [E0277] +} + fn main() {} diff --git a/tests/ui/binop/binary-op-suggest-deref.stderr b/tests/ui/binop/binary-op-suggest-deref.stderr index 68b5a24bf97..a98a2ab0706 100644 --- a/tests/ui/binop/binary-op-suggest-deref.stderr +++ b/tests/ui/binop/binary-op-suggest-deref.stderr @@ -295,7 +295,28 @@ help: consider dereferencing here LL | _ = partial[..3] == *string_ref; | + -error: aborting due to 22 previous errors +error[E0277]: no implementation for `i32 & str` + --> $DIR/binary-op-suggest-deref.rs:78:17 + | +LL | let _ = FOO & (*"Sized".to_string().into_boxed_str()); + | ^ no implementation for `i32 & str` + | + = help: the trait `BitAnd<str>` is not implemented for `i32` + = help: the following other types implement trait `BitAnd<Rhs>`: + <i32 as BitAnd> + <i32 as BitAnd<&i32>> + <&'a i32 as BitAnd<i32>> + <&i32 as BitAnd<&i32>> + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/binary-op-suggest-deref.rs:78:17 + | +LL | let _ = FOO & (*"Sized".to_string().into_boxed_str()); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + +error: aborting due to 24 previous errors Some errors have detailed explanations: E0277, E0308, E0369. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/borrowck/issue-119915-bad-clone-suggestion.rs b/tests/ui/borrowck/issue-119915-bad-clone-suggestion.rs new file mode 100644 index 00000000000..0b0ac9448db --- /dev/null +++ b/tests/ui/borrowck/issue-119915-bad-clone-suggestion.rs @@ -0,0 +1,28 @@ +use std::marker::PhantomData; + +struct Example<E, FakeParam>(PhantomData<(fn(E), fn(FakeParam))>); + +struct NoLifetime; +struct Immutable<'a>(PhantomData<&'a ()>); + +impl<'a, E: 'a> Copy for Example<E, Immutable<'a>> {} +impl<'a, E: 'a> Clone for Example<E, Immutable<'a>> { + fn clone(&self) -> Self { + *self + } +} + +impl<E, FakeParam> Example<E, FakeParam> { + unsafe fn change<NewFakeParam>(self) -> Example<E, NewFakeParam> { + Example(PhantomData) + } +} + +impl<E> Example<E, NoLifetime> { + fn the_ice(&mut self) -> Example<E, Immutable<'_>> { + unsafe { self.change() } + //~^ ERROR cannot move out of `*self` which is behind a mutable reference + } +} + +fn main() {} diff --git a/tests/ui/borrowck/issue-119915-bad-clone-suggestion.stderr b/tests/ui/borrowck/issue-119915-bad-clone-suggestion.stderr new file mode 100644 index 00000000000..ab42205d510 --- /dev/null +++ b/tests/ui/borrowck/issue-119915-bad-clone-suggestion.stderr @@ -0,0 +1,17 @@ +error[E0507]: cannot move out of `*self` which is behind a mutable reference + --> $DIR/issue-119915-bad-clone-suggestion.rs:23:18 + | +LL | unsafe { self.change() } + | ^^^^ -------- `*self` moved due to this method call + | | + | move occurs because `*self` has type `Example<E, NoLifetime>`, which does not implement the `Copy` trait + | +note: `Example::<E, FakeParam>::change` takes ownership of the receiver `self`, which moves `*self` + --> $DIR/issue-119915-bad-clone-suggestion.rs:16:36 + | +LL | unsafe fn change<NewFakeParam>(self) -> Example<E, NewFakeParam> { + | ^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/borrowck/issue-85765-closure.rs b/tests/ui/borrowck/issue-85765-closure.rs index edc9eeaffb5..f2d1dd0fbc3 100644 --- a/tests/ui/borrowck/issue-85765-closure.rs +++ b/tests/ui/borrowck/issue-85765-closure.rs @@ -3,7 +3,6 @@ fn main() { let mut test = Vec::new(); let rofl: &Vec<Vec<i32>> = &mut test; //~^ HELP consider changing this binding's type - //~| HELP you can `clone` the `Vec<Vec<i32>>` value and consume it, but this might not be your desired behavior rofl.push(Vec::new()); //~^ ERROR cannot borrow `*rofl` as mutable, as it is behind a `&` reference //~| NOTE `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable diff --git a/tests/ui/borrowck/issue-85765-closure.stderr b/tests/ui/borrowck/issue-85765-closure.stderr index 4a6a0e94bec..936ddd67bcd 100644 --- a/tests/ui/borrowck/issue-85765-closure.stderr +++ b/tests/ui/borrowck/issue-85765-closure.stderr @@ -1,21 +1,16 @@ error[E0596]: cannot borrow `*rofl` as mutable, as it is behind a `&` reference - --> $DIR/issue-85765-closure.rs:7:9 + --> $DIR/issue-85765-closure.rs:6:9 | LL | rofl.push(Vec::new()); | ^^^^ `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable | -help: you can `clone` the `Vec<Vec<i32>>` value and consume it, but this might not be your desired behavior - --> $DIR/issue-85765-closure.rs:4:36 - | -LL | let rofl: &Vec<Vec<i32>> = &mut test; - | ^^^^^^^^^ help: consider changing this binding's type | LL | let rofl: &mut Vec<Vec<i32>> = &mut test; | ~~~~~~~~~~~~~~~~~~ error[E0594]: cannot assign to `*r`, which is behind a `&` reference - --> $DIR/issue-85765-closure.rs:14:9 + --> $DIR/issue-85765-closure.rs:13:9 | LL | *r = 0; | ^^^^^^ `r` is a `&` reference, so the data it refers to cannot be written @@ -26,7 +21,7 @@ LL | let r = &mut mutvar; | +++ error[E0594]: cannot assign to `*x`, which is behind a `&` reference - --> $DIR/issue-85765-closure.rs:21:9 + --> $DIR/issue-85765-closure.rs:20:9 | LL | *x = 1; | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written @@ -37,7 +32,7 @@ LL | let x: &mut usize = &mut{0}; | ~~~~~~~~~~ error[E0594]: cannot assign to `*y`, which is behind a `&` reference - --> $DIR/issue-85765-closure.rs:28:9 + --> $DIR/issue-85765-closure.rs:27:9 | LL | *y = 1; | ^^^^^^ `y` is a `&` reference, so the data it refers to cannot be written diff --git a/tests/ui/borrowck/issue-85765.rs b/tests/ui/borrowck/issue-85765.rs index ce5740bc0e7..76e0b517354 100644 --- a/tests/ui/borrowck/issue-85765.rs +++ b/tests/ui/borrowck/issue-85765.rs @@ -2,7 +2,6 @@ fn main() { let mut test = Vec::new(); let rofl: &Vec<Vec<i32>> = &mut test; //~^ HELP consider changing this binding's type - //~| HELP you can `clone` the `Vec<Vec<i32>>` value and consume it, but this might not be your desired behavior rofl.push(Vec::new()); //~^ ERROR cannot borrow `*rofl` as mutable, as it is behind a `&` reference //~| NOTE `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable diff --git a/tests/ui/borrowck/issue-85765.stderr b/tests/ui/borrowck/issue-85765.stderr index 4889f774afa..57900bfb612 100644 --- a/tests/ui/borrowck/issue-85765.stderr +++ b/tests/ui/borrowck/issue-85765.stderr @@ -1,21 +1,16 @@ error[E0596]: cannot borrow `*rofl` as mutable, as it is behind a `&` reference - --> $DIR/issue-85765.rs:6:5 + --> $DIR/issue-85765.rs:5:5 | LL | rofl.push(Vec::new()); | ^^^^ `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable | -help: you can `clone` the `Vec<Vec<i32>>` value and consume it, but this might not be your desired behavior - --> $DIR/issue-85765.rs:3:32 - | -LL | let rofl: &Vec<Vec<i32>> = &mut test; - | ^^^^^^^^^ help: consider changing this binding's type | LL | let rofl: &mut Vec<Vec<i32>> = &mut test; | ~~~~~~~~~~~~~~~~~~ error[E0594]: cannot assign to `*r`, which is behind a `&` reference - --> $DIR/issue-85765.rs:13:5 + --> $DIR/issue-85765.rs:12:5 | LL | *r = 0; | ^^^^^^ `r` is a `&` reference, so the data it refers to cannot be written @@ -26,7 +21,7 @@ LL | let r = &mut mutvar; | +++ error[E0594]: cannot assign to `*x`, which is behind a `&` reference - --> $DIR/issue-85765.rs:20:5 + --> $DIR/issue-85765.rs:19:5 | LL | *x = 1; | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written @@ -37,7 +32,7 @@ LL | let x: &mut usize = &mut{0}; | ~~~~~~~~~~ error[E0594]: cannot assign to `*y`, which is behind a `&` reference - --> $DIR/issue-85765.rs:27:5 + --> $DIR/issue-85765.rs:26:5 | LL | *y = 1; | ^^^^^^ `y` is a `&` reference, so the data it refers to cannot be written diff --git a/tests/ui/borrowck/issue-91206.rs b/tests/ui/borrowck/issue-91206.rs index c60ac62fa34..e062a253767 100644 --- a/tests/ui/borrowck/issue-91206.rs +++ b/tests/ui/borrowck/issue-91206.rs @@ -10,7 +10,6 @@ fn main() { let client = TestClient; let inner = client.get_inner_ref(); //~^ HELP consider specifying this binding's type - //~| HELP you can `clone` the `Vec<usize>` value and consume it, but this might not be your desired behavior inner.clear(); //~^ ERROR cannot borrow `*inner` as mutable, as it is behind a `&` reference [E0596] //~| NOTE `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable diff --git a/tests/ui/borrowck/issue-91206.stderr b/tests/ui/borrowck/issue-91206.stderr index e3dd65b6419..f96b0c7d9e1 100644 --- a/tests/ui/borrowck/issue-91206.stderr +++ b/tests/ui/borrowck/issue-91206.stderr @@ -1,14 +1,9 @@ error[E0596]: cannot borrow `*inner` as mutable, as it is behind a `&` reference - --> $DIR/issue-91206.rs:14:5 + --> $DIR/issue-91206.rs:13:5 | LL | inner.clear(); | ^^^^^ `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable | -help: you can `clone` the `Vec<usize>` value and consume it, but this might not be your desired behavior - --> $DIR/issue-91206.rs:11:17 - | -LL | let inner = client.get_inner_ref(); - | ^^^^^^^^^^^^^^^^^^^^^^ help: consider specifying this binding's type | LL | let inner: &mut Vec<usize> = client.get_inner_ref(); diff --git a/tests/ui/cfg/diagnostics-cross-crate.rs b/tests/ui/cfg/diagnostics-cross-crate.rs index d2725c94b08..ad4e47b7b2e 100644 --- a/tests/ui/cfg/diagnostics-cross-crate.rs +++ b/tests/ui/cfg/diagnostics-cross-crate.rs @@ -14,9 +14,9 @@ fn main() { // The module isn't found - we would like to get a diagnostic, but currently don't due to // the awkward way the resolver diagnostics are currently implemented. - // FIXME(Nilstrieb): Also add a note to the cfg diagnostic here cfged_out::inner::doesnt_exist::hello(); //~ ERROR failed to resolve //~^ NOTE could not find `doesnt_exist` in `inner` + //~| NOTE found an item that was configured out // It should find the one in the right module, not the wrong one. cfged_out::inner::right::meow(); //~ ERROR cannot find function diff --git a/tests/ui/cfg/diagnostics-cross-crate.stderr b/tests/ui/cfg/diagnostics-cross-crate.stderr index 046929bc260..8a238f36404 100644 --- a/tests/ui/cfg/diagnostics-cross-crate.stderr +++ b/tests/ui/cfg/diagnostics-cross-crate.stderr @@ -1,8 +1,14 @@ error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` - --> $DIR/diagnostics-cross-crate.rs:18:23 + --> $DIR/diagnostics-cross-crate.rs:17:23 | LL | cfged_out::inner::doesnt_exist::hello(); | ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner` + | +note: found an item that was configured out + --> $DIR/auxiliary/cfged_out.rs:6:13 + | +LL | pub mod doesnt_exist { + | ^^^^^^^^^^^^ error[E0425]: cannot find function `uwu` in crate `cfged_out` --> $DIR/diagnostics-cross-crate.rs:7:16 diff --git a/tests/ui/cfg/diagnostics-same-crate.rs b/tests/ui/cfg/diagnostics-same-crate.rs index f76ace06a76..2d0907c6dfb 100644 --- a/tests/ui/cfg/diagnostics-same-crate.rs +++ b/tests/ui/cfg/diagnostics-same-crate.rs @@ -4,7 +4,7 @@ pub mod inner { //~^ NOTE found an item that was configured out #[cfg(FALSE)] - pub mod doesnt_exist { + pub mod doesnt_exist { //~ NOTE found an item that was configured out pub fn hello() {} } @@ -34,7 +34,6 @@ fn main() { // The module isn't found - we would like to get a diagnostic, but currently don't due to // the awkward way the resolver diagnostics are currently implemented. - // FIXME(Nilstrieb): Also add a note to the cfg diagnostic here inner::doesnt_exist::hello(); //~ ERROR failed to resolve //~| NOTE could not find `doesnt_exist` in `inner` diff --git a/tests/ui/cfg/diagnostics-same-crate.stderr b/tests/ui/cfg/diagnostics-same-crate.stderr index 30ee6479bd2..62a9d132de0 100644 --- a/tests/ui/cfg/diagnostics-same-crate.stderr +++ b/tests/ui/cfg/diagnostics-same-crate.stderr @@ -1,8 +1,14 @@ error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` - --> $DIR/diagnostics-same-crate.rs:38:12 + --> $DIR/diagnostics-same-crate.rs:37:12 | LL | inner::doesnt_exist::hello(); | ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner` + | +note: found an item that was configured out + --> $DIR/diagnostics-same-crate.rs:7:13 + | +LL | pub mod doesnt_exist { + | ^^^^^^^^^^^^ error[E0425]: cannot find function `uwu` in module `inner` --> $DIR/diagnostics-same-crate.rs:32:12 @@ -17,7 +23,7 @@ LL | pub fn uwu() {} | ^^^ error[E0425]: cannot find function `meow` in module `inner::right` - --> $DIR/diagnostics-same-crate.rs:42:19 + --> $DIR/diagnostics-same-crate.rs:41:19 | LL | inner::right::meow(); | ^^^^ not found in `inner::right` @@ -36,7 +42,7 @@ LL | uwu(); | ^^^ not found in this scope error[E0425]: cannot find function `vanished` in this scope - --> $DIR/diagnostics-same-crate.rs:49:5 + --> $DIR/diagnostics-same-crate.rs:48:5 | LL | vanished(); | ^^^^^^^^ not found in this scope diff --git a/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs b/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs index c0cde75d4ca..6653bd15ddd 100644 --- a/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs +++ b/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs @@ -7,5 +7,5 @@ fn main() { } #[deprecated(note = test)] -//~^ ERROR expected unsuffixed literal or identifier, found `test` +//~^ ERROR expected unsuffixed literal, found `test` fn foo() {} diff --git a/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr b/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr index 48c763c50e3..078c766deed 100644 --- a/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr +++ b/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr @@ -1,8 +1,13 @@ -error: expected unsuffixed literal or identifier, found `test` +error: expected unsuffixed literal, found `test` --> $DIR/issue-66340-deprecated-attr-non-meta-grammar.rs:9:21 | LL | #[deprecated(note = test)] | ^^^^ + | +help: surround the identifier with quotation marks to parse it as a string + | +LL | #[deprecated(note = "test")] + | + + error: aborting due to 1 previous error diff --git a/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs b/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs new file mode 100644 index 00000000000..252dc7d751e --- /dev/null +++ b/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs @@ -0,0 +1,33 @@ +use std::ops::Deref; + +trait PointerFamily { + type Pointer<T>: Deref<Target = T>; +} + +struct RcFamily; + +impl PointerFamily for RcFamily { + type Pointer<T> = dyn Deref<Target = T>; + //~^ ERROR the size for values of type `(dyn Deref<Target = T> + 'static)` cannot be known at compilation time +} + +enum Node<T, P: PointerFamily> { + Cons(T, P::Pointer<Node<T, P>>), + Nil, +} + +type RcNode<T> = Node<T, RcFamily>; + +impl<T, P: PointerFamily> Node<T, P> +where + P::Pointer<Node<T, P>>: Sized, +{ + fn new() -> P::Pointer<Self> { + todo!() + } +} + +fn main() { + let mut list = RcNode::<i32>::new(); + //~^ ERROR the size for values of type `Node<i32, RcFamily>` cannot be known at compilation time +} diff --git a/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.stderr b/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.stderr new file mode 100644 index 00000000000..3a973d356dc --- /dev/null +++ b/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.stderr @@ -0,0 +1,52 @@ +error[E0277]: the size for values of type `(dyn Deref<Target = T> + 'static)` cannot be known at compilation time + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:10:23 + | +LL | type Pointer<T> = dyn Deref<Target = T>; + | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Deref<Target = T> + 'static)` +note: required by a bound in `PointerFamily::Pointer` + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:4:5 + | +LL | type Pointer<T>: Deref<Target = T>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `PointerFamily::Pointer` +help: consider relaxing the implicit `Sized` restriction + | +LL | type Pointer<T>: Deref<Target = T> + ?Sized; + | ++++++++ + +error[E0599]: the size for values of type `Node<i32, RcFamily>` cannot be known at compilation time + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:31:35 + | +LL | enum Node<T, P: PointerFamily> { + | ------------------------------ + | | + | variant or associated item `new` not found for this enum + | doesn't satisfy `Node<i32, RcFamily>: Sized` +... +LL | let mut list = RcNode::<i32>::new(); + | ^^^ doesn't have a size known at compile-time + --> $SRC_DIR/core/src/ops/deref.rs:LL:COL + | + = note: doesn't satisfy `_: Sized` + | +note: trait bound `Node<i32, RcFamily>: Sized` was not satisfied + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:4:18 + | +LL | type Pointer<T>: Deref<Target = T>; + | ------- ^ unsatisfied trait bound introduced here +note: trait bound `(dyn Deref<Target = Node<i32, RcFamily>> + 'static): Sized` was not satisfied + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:23:29 + | +LL | impl<T, P: PointerFamily> Node<T, P> + | ---------- +LL | where +LL | P::Pointer<Node<T, P>>: Sized, + | ^^^^^ unsatisfied trait bound introduced here +note: the trait `Sized` must be implemented + --> $SRC_DIR/core/src/marker.rs:LL:COL + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0599. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/moves/move-fn-self-receiver.stderr b/tests/ui/moves/move-fn-self-receiver.stderr index 462deacbe8d..17f48f5f7bf 100644 --- a/tests/ui/moves/move-fn-self-receiver.stderr +++ b/tests/ui/moves/move-fn-self-receiver.stderr @@ -55,10 +55,15 @@ note: `Foo::use_box_self` takes ownership of the receiver `self`, which moves `b | LL | fn use_box_self(self: Box<Self>) {} | ^^^^ -help: you could `clone` the value and consume it, if the `Box<Foo>: Clone` trait bound could be satisfied +help: you could `clone` the value and consume it, if the `Foo: Clone` trait bound could be satisfied | LL | boxed_foo.clone().use_box_self(); | ++++++++ +help: consider annotating `Foo` with `#[derive(Clone)]` + | +LL + #[derive(Clone)] +LL | struct Foo; + | error[E0382]: use of moved value: `pin_box_foo` --> $DIR/move-fn-self-receiver.rs:46:5 @@ -75,10 +80,15 @@ note: `Foo::use_pin_box_self` takes ownership of the receiver `self`, which move | LL | fn use_pin_box_self(self: Pin<Box<Self>>) {} | ^^^^ -help: you could `clone` the value and consume it, if the `Box<Foo>: Clone` trait bound could be satisfied +help: you could `clone` the value and consume it, if the `Foo: Clone` trait bound could be satisfied | LL | pin_box_foo.clone().use_pin_box_self(); | ++++++++ +help: consider annotating `Foo` with `#[derive(Clone)]` + | +LL + #[derive(Clone)] +LL | struct Foo; + | error[E0505]: cannot move out of `mut_foo` because it is borrowed --> $DIR/move-fn-self-receiver.rs:50:5 diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.fixed b/tests/ui/parser/attribute/attr-unquoted-ident.fixed new file mode 100644 index 00000000000..6cdf22f7ec0 --- /dev/null +++ b/tests/ui/parser/attribute/attr-unquoted-ident.fixed @@ -0,0 +1,15 @@ +// compile-flags: -Zdeduplicate-diagnostics=yes +// run-rustfix + +fn main() { + #[cfg(key="foo")] + //~^ ERROR expected unsuffixed literal, found `foo` + //~| HELP surround the identifier with quotation marks to parse it as a string + println!(); + #[cfg(key="bar")] + println!(); + #[cfg(key="foo bar baz")] + //~^ ERROR expected unsuffixed literal, found `foo` + //~| HELP surround the identifier with quotation marks to parse it as a string + println!(); +} diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.rs b/tests/ui/parser/attribute/attr-unquoted-ident.rs new file mode 100644 index 00000000000..75af015c9fe --- /dev/null +++ b/tests/ui/parser/attribute/attr-unquoted-ident.rs @@ -0,0 +1,15 @@ +// compile-flags: -Zdeduplicate-diagnostics=yes +// run-rustfix + +fn main() { + #[cfg(key=foo)] + //~^ ERROR expected unsuffixed literal, found `foo` + //~| HELP surround the identifier with quotation marks to parse it as a string + println!(); + #[cfg(key="bar")] + println!(); + #[cfg(key=foo bar baz)] + //~^ ERROR expected unsuffixed literal, found `foo` + //~| HELP surround the identifier with quotation marks to parse it as a string + println!(); +} diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.stderr b/tests/ui/parser/attribute/attr-unquoted-ident.stderr new file mode 100644 index 00000000000..bc028f39be6 --- /dev/null +++ b/tests/ui/parser/attribute/attr-unquoted-ident.stderr @@ -0,0 +1,24 @@ +error: expected unsuffixed literal, found `foo` + --> $DIR/attr-unquoted-ident.rs:5:15 + | +LL | #[cfg(key=foo)] + | ^^^ + | +help: surround the identifier with quotation marks to parse it as a string + | +LL | #[cfg(key="foo")] + | + + + +error: expected unsuffixed literal, found `foo` + --> $DIR/attr-unquoted-ident.rs:11:15 + | +LL | #[cfg(key=foo bar baz)] + | ^^^ + | +help: surround the identifier with quotation marks to parse it as a string + | +LL | #[cfg(key="foo bar baz")] + | + + + +error: aborting due to 2 previous errors + |
