From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/typeof/issue-100183.rs | 6 ++++++ tests/ui/typeof/issue-100183.stderr | 14 ++++++++++++++ tests/ui/typeof/issue-29184.rs | 3 +++ tests/ui/typeof/issue-29184.stderr | 14 ++++++++++++++ tests/ui/typeof/issue-42060.rs | 11 +++++++++++ tests/ui/typeof/issue-42060.stderr | 32 ++++++++++++++++++++++++++++++++ tests/ui/typeof/type_mismatch.rs | 9 +++++++++ tests/ui/typeof/type_mismatch.stderr | 28 ++++++++++++++++++++++++++++ 8 files changed, 117 insertions(+) create mode 100644 tests/ui/typeof/issue-100183.rs create mode 100644 tests/ui/typeof/issue-100183.stderr create mode 100644 tests/ui/typeof/issue-29184.rs create mode 100644 tests/ui/typeof/issue-29184.stderr create mode 100644 tests/ui/typeof/issue-42060.rs create mode 100644 tests/ui/typeof/issue-42060.stderr create mode 100644 tests/ui/typeof/type_mismatch.rs create mode 100644 tests/ui/typeof/type_mismatch.stderr (limited to 'tests/ui/typeof') diff --git a/tests/ui/typeof/issue-100183.rs b/tests/ui/typeof/issue-100183.rs new file mode 100644 index 000000000..13e9493ea --- /dev/null +++ b/tests/ui/typeof/issue-100183.rs @@ -0,0 +1,6 @@ +struct Struct { + y: (typeof("hey"),), + //~^ ERROR `typeof` is a reserved keyword but unimplemented +} + +fn main() {} diff --git a/tests/ui/typeof/issue-100183.stderr b/tests/ui/typeof/issue-100183.stderr new file mode 100644 index 000000000..01d3079b2 --- /dev/null +++ b/tests/ui/typeof/issue-100183.stderr @@ -0,0 +1,14 @@ +error[E0516]: `typeof` is a reserved keyword but unimplemented + --> $DIR/issue-100183.rs:2:9 + | +LL | y: (typeof("hey"),), + | ^^^^^^^^^^^^^ reserved keyword + | +help: consider replacing `typeof(...)` with an actual type + | +LL | y: (&'static str,), + | ~~~~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0516`. diff --git a/tests/ui/typeof/issue-29184.rs b/tests/ui/typeof/issue-29184.rs new file mode 100644 index 000000000..c77e364c3 --- /dev/null +++ b/tests/ui/typeof/issue-29184.rs @@ -0,0 +1,3 @@ +fn main() { + let x: typeof(92) = 92; //~ ERROR `typeof` is a reserved keyword +} diff --git a/tests/ui/typeof/issue-29184.stderr b/tests/ui/typeof/issue-29184.stderr new file mode 100644 index 000000000..75b6c64f2 --- /dev/null +++ b/tests/ui/typeof/issue-29184.stderr @@ -0,0 +1,14 @@ +error[E0516]: `typeof` is a reserved keyword but unimplemented + --> $DIR/issue-29184.rs:2:12 + | +LL | let x: typeof(92) = 92; + | ^^^^^^^^^^ reserved keyword + | +help: consider replacing `typeof(...)` with an actual type + | +LL | let x: i32 = 92; + | ~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0516`. diff --git a/tests/ui/typeof/issue-42060.rs b/tests/ui/typeof/issue-42060.rs new file mode 100644 index 000000000..1740b2383 --- /dev/null +++ b/tests/ui/typeof/issue-42060.rs @@ -0,0 +1,11 @@ +fn main() { + let thing = (); + let other: typeof(thing) = thing; //~ ERROR attempt to use a non-constant value in a constant + //~^ ERROR `typeof` is a reserved keyword but unimplemented [E0516] +} + +fn f(){ + let q = 1; + ::N //~ ERROR attempt to use a non-constant value in a constant + //~^ ERROR `typeof` is a reserved keyword but unimplemented [E0516] +} diff --git a/tests/ui/typeof/issue-42060.stderr b/tests/ui/typeof/issue-42060.stderr new file mode 100644 index 000000000..effcbe4d7 --- /dev/null +++ b/tests/ui/typeof/issue-42060.stderr @@ -0,0 +1,32 @@ +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/issue-42060.rs:3:23 + | +LL | let thing = (); + | --------- help: consider using `const` instead of `let`: `const thing` +LL | let other: typeof(thing) = thing; + | ^^^^^ non-constant value + +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/issue-42060.rs:9:13 + | +LL | let q = 1; + | ----- help: consider using `const` instead of `let`: `const q` +LL | ::N + | ^ non-constant value + +error[E0516]: `typeof` is a reserved keyword but unimplemented + --> $DIR/issue-42060.rs:3:16 + | +LL | let other: typeof(thing) = thing; + | ^^^^^^^^^^^^^ reserved keyword + +error[E0516]: `typeof` is a reserved keyword but unimplemented + --> $DIR/issue-42060.rs:9:6 + | +LL | ::N + | ^^^^^^^^^ reserved keyword + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0435, E0516. +For more information about an error, try `rustc --explain E0435`. diff --git a/tests/ui/typeof/type_mismatch.rs b/tests/ui/typeof/type_mismatch.rs new file mode 100644 index 000000000..3f8339fa5 --- /dev/null +++ b/tests/ui/typeof/type_mismatch.rs @@ -0,0 +1,9 @@ +// Test that using typeof results in the correct type mismatch errors instead of always assuming +// `usize`, in addition to the pre-existing "typeof is reserved and unimplemented" error +fn main() { + const a: u8 = 1; + let b: typeof(a) = 1i8; + //~^ ERROR `typeof` is a reserved keyword but unimplemented + //~| ERROR mismatched types + //~| expected `u8`, found `i8` +} diff --git a/tests/ui/typeof/type_mismatch.stderr b/tests/ui/typeof/type_mismatch.stderr new file mode 100644 index 000000000..e75214cd3 --- /dev/null +++ b/tests/ui/typeof/type_mismatch.stderr @@ -0,0 +1,28 @@ +error[E0516]: `typeof` is a reserved keyword but unimplemented + --> $DIR/type_mismatch.rs:5:12 + | +LL | let b: typeof(a) = 1i8; + | ^^^^^^^^^ reserved keyword + | +help: consider replacing `typeof(...)` with an actual type + | +LL | let b: u8 = 1i8; + | ~~ + +error[E0308]: mismatched types + --> $DIR/type_mismatch.rs:5:24 + | +LL | let b: typeof(a) = 1i8; + | --------- ^^^ expected `u8`, found `i8` + | | + | expected due to this + | +help: change the type of the numeric literal from `i8` to `u8` + | +LL | let b: typeof(a) = 1u8; + | ~~ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0308, E0516. +For more information about an error, try `rustc --explain E0308`. -- cgit v1.2.3