diff options
Diffstat (limited to 'src/test')
9 files changed, 127 insertions, 2 deletions
diff --git a/src/test/ui/lint/lint-uppercase-variables.rs b/src/test/ui/lint/lint-uppercase-variables.rs index 86a39502a81..a98b4f2fd44 100644 --- a/src/test/ui/lint/lint-uppercase-variables.rs +++ b/src/test/ui/lint/lint-uppercase-variables.rs @@ -25,6 +25,16 @@ fn main() { //~^^^ WARN unused variable: `Foo` } + let Foo = foo::Foo::Foo; + //~^ ERROR variable `Foo` should have a snake case name + //~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo` + //~^^^ WARN unused variable: `Foo` + + fn in_param(Foo: foo::Foo) {} + //~^ ERROR variable `Foo` should have a snake case name + //~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo` + //~^^^ WARN unused variable: `Foo` + test(1); let _ = Something { X: 0 }; diff --git a/src/test/ui/lint/lint-uppercase-variables.stderr b/src/test/ui/lint/lint-uppercase-variables.stderr index b937832ac62..a38f3e7626b 100644 --- a/src/test/ui/lint/lint-uppercase-variables.stderr +++ b/src/test/ui/lint/lint-uppercase-variables.stderr @@ -6,6 +6,18 @@ LL | Foo => {} | = note: `#[warn(bindings_with_variant_name)]` on by default +warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo` + --> $DIR/lint-uppercase-variables.rs:28:9 + | +LL | let Foo = foo::Foo::Foo; + | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo` + +warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo` + --> $DIR/lint-uppercase-variables.rs:33:17 + | +LL | fn in_param(Foo: foo::Foo) {} + | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo` + warning: unused variable: `Foo` --> $DIR/lint-uppercase-variables.rs:22:9 | @@ -19,6 +31,18 @@ LL | #![warn(unused)] | ^^^^^^ = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]` +warning: unused variable: `Foo` + --> $DIR/lint-uppercase-variables.rs:28:9 + | +LL | let Foo = foo::Foo::Foo; + | ^^^ help: consider prefixing with an underscore: `_Foo` + +warning: unused variable: `Foo` + --> $DIR/lint-uppercase-variables.rs:33:17 + | +LL | fn in_param(Foo: foo::Foo) {} + | ^^^ help: consider prefixing with an underscore: `_Foo` + error: structure field `X` should have a snake case name --> $DIR/lint-uppercase-variables.rs:10:5 | @@ -49,6 +73,18 @@ error: variable `Foo` should have a snake case name LL | Foo => {} | ^^^ help: convert the identifier to snake case (notice the capitalization): `foo` -error: aborting due to 4 previous errors +error: variable `Foo` should have a snake case name + --> $DIR/lint-uppercase-variables.rs:28:9 + | +LL | let Foo = foo::Foo::Foo; + | ^^^ help: convert the identifier to snake case (notice the capitalization): `foo` + +error: variable `Foo` should have a snake case name + --> $DIR/lint-uppercase-variables.rs:33:17 + | +LL | fn in_param(Foo: foo::Foo) {} + | ^^^ help: convert the identifier to snake case (notice the capitalization): `foo` + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0170`. diff --git a/src/test/ui/pattern/issue-68393-let-pat-assoc-constant.rs b/src/test/ui/pattern/issue-68393-let-pat-assoc-constant.rs new file mode 100644 index 00000000000..95ead6b5d4a --- /dev/null +++ b/src/test/ui/pattern/issue-68393-let-pat-assoc-constant.rs @@ -0,0 +1,26 @@ +pub enum EFoo { + A, +} + +pub trait Foo { + const X: EFoo; +} + +struct Abc; + +impl Foo for Abc { + const X: EFoo = EFoo::A; +} + +struct Def; +impl Foo for Def { + const X: EFoo = EFoo::A; +} + +pub fn test<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) { + //~^ ERROR associated consts cannot be referenced in patterns + let A::X = arg; + //~^ ERROR associated consts cannot be referenced in patterns +} + +fn main() {} diff --git a/src/test/ui/pattern/issue-68393-let-pat-assoc-constant.stderr b/src/test/ui/pattern/issue-68393-let-pat-assoc-constant.stderr new file mode 100644 index 00000000000..54ecc24981f --- /dev/null +++ b/src/test/ui/pattern/issue-68393-let-pat-assoc-constant.stderr @@ -0,0 +1,15 @@ +error[E0158]: associated consts cannot be referenced in patterns + --> $DIR/issue-68393-let-pat-assoc-constant.rs:20:40 + | +LL | pub fn test<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) { + | ^^^^ + +error[E0158]: associated consts cannot be referenced in patterns + --> $DIR/issue-68393-let-pat-assoc-constant.rs:22:9 + | +LL | let A::X = arg; + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0158`. diff --git a/src/test/ui/pattern/issue-68394-let-pat-runtime-value.rs b/src/test/ui/pattern/issue-68394-let-pat-runtime-value.rs new file mode 100644 index 00000000000..f10a7f2d8a5 --- /dev/null +++ b/src/test/ui/pattern/issue-68394-let-pat-runtime-value.rs @@ -0,0 +1,5 @@ +fn main() { + let x = 255u8; + let 0u8..=x = 0; + //~^ ERROR runtime values cannot be referenced in patterns +} diff --git a/src/test/ui/pattern/issue-68394-let-pat-runtime-value.stderr b/src/test/ui/pattern/issue-68394-let-pat-runtime-value.stderr new file mode 100644 index 00000000000..c1508bd71ff --- /dev/null +++ b/src/test/ui/pattern/issue-68394-let-pat-runtime-value.stderr @@ -0,0 +1,9 @@ +error[E0080]: runtime values cannot be referenced in patterns + --> $DIR/issue-68394-let-pat-runtime-value.rs:3:15 + | +LL | let 0u8..=x = 0; + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/pattern/issue-68396-let-float-bug.rs b/src/test/ui/pattern/issue-68396-let-float-bug.rs new file mode 100644 index 00000000000..afc599a4b22 --- /dev/null +++ b/src/test/ui/pattern/issue-68396-let-float-bug.rs @@ -0,0 +1,7 @@ +fn main() { + let 1234567890123456789012345678901234567890e-340: f64 = 0.0; + //~^ ERROR could not evaluate float literal (see issue #31407) + + fn param(1234567890123456789012345678901234567890e-340: f64) {} + //~^ ERROR could not evaluate float literal (see issue #31407) +} diff --git a/src/test/ui/pattern/issue-68396-let-float-bug.stderr b/src/test/ui/pattern/issue-68396-let-float-bug.stderr new file mode 100644 index 00000000000..618aa4b5021 --- /dev/null +++ b/src/test/ui/pattern/issue-68396-let-float-bug.stderr @@ -0,0 +1,15 @@ +error[E0080]: could not evaluate float literal (see issue #31407) + --> $DIR/issue-68396-let-float-bug.rs:2:9 + | +LL | let 1234567890123456789012345678901234567890e-340: f64 = 0.0; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0080]: could not evaluate float literal (see issue #31407) + --> $DIR/issue-68396-let-float-bug.rs:5:14 + | +LL | fn param(1234567890123456789012345678901234567890e-340: f64) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/pattern/usefulness/struct-pattern-match-useless.stderr b/src/test/ui/pattern/usefulness/struct-pattern-match-useless.stderr index 5b0c9305448..0115fc081a9 100644 --- a/src/test/ui/pattern/usefulness/struct-pattern-match-useless.stderr +++ b/src/test/ui/pattern/usefulness/struct-pattern-match-useless.stderr @@ -1,8 +1,10 @@ error: unreachable pattern --> $DIR/struct-pattern-match-useless.rs:12:9 | +LL | Foo { x: _x, y: _y } => (), + | -------------------- matches any value LL | Foo { .. } => () - | ^^^^^^^^^^ + | ^^^^^^^^^^ unreachable pattern | note: lint level defined here --> $DIR/struct-pattern-match-useless.rs:1:9 |
