diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/codemap_tests | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/codemap_tests')
32 files changed, 480 insertions, 0 deletions
diff --git a/tests/ui/codemap_tests/bad-format-args.rs b/tests/ui/codemap_tests/bad-format-args.rs new file mode 100644 index 000000000..e89a45a84 --- /dev/null +++ b/tests/ui/codemap_tests/bad-format-args.rs @@ -0,0 +1,5 @@ +fn main() { + format!(); //~ ERROR requires at least a format string argument + format!("" 1); //~ ERROR expected `,`, found `1` + format!("", 1 1); //~ ERROR expected one of +} diff --git a/tests/ui/codemap_tests/bad-format-args.stderr b/tests/ui/codemap_tests/bad-format-args.stderr new file mode 100644 index 000000000..8f79beaa9 --- /dev/null +++ b/tests/ui/codemap_tests/bad-format-args.stderr @@ -0,0 +1,22 @@ +error: requires at least a format string argument + --> $DIR/bad-format-args.rs:2:5 + | +LL | format!(); + | ^^^^^^^^^ + | + = note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: expected `,`, found `1` + --> $DIR/bad-format-args.rs:3:16 + | +LL | format!("" 1); + | ^ expected `,` + +error: expected one of `,`, `.`, `?`, or an operator, found `1` + --> $DIR/bad-format-args.rs:4:19 + | +LL | format!("", 1 1); + | ^ expected one of `,`, `.`, `?`, or an operator + +error: aborting due to 3 previous errors + diff --git a/tests/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.rs b/tests/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.rs new file mode 100644 index 000000000..414acfd84 --- /dev/null +++ b/tests/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.rs @@ -0,0 +1,6 @@ +#![allow(dead_code)] + +trait C {} +impl dyn C { fn f() {} } //~ ERROR duplicate +impl dyn C { fn f() {} } +fn main() { } diff --git a/tests/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr b/tests/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr new file mode 100644 index 000000000..2c1c3c2dc --- /dev/null +++ b/tests/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr @@ -0,0 +1,11 @@ +error[E0592]: duplicate definitions with name `f` + --> $DIR/coherence-overlapping-inherent-impl-trait.rs:4:14 + | +LL | impl dyn C { fn f() {} } + | ^^^^^^ duplicate definitions for `f` +LL | impl dyn C { fn f() {} } + | ------ other definition for `f` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0592`. diff --git a/tests/ui/codemap_tests/empty_span.rs b/tests/ui/codemap_tests/empty_span.rs new file mode 100644 index 000000000..7753e2ece --- /dev/null +++ b/tests/ui/codemap_tests/empty_span.rs @@ -0,0 +1,8 @@ +#![feature(negative_impls)] +fn main() { + struct Foo; + + impl !Sync for Foo {} + + unsafe impl Send for &'static Foo { } //~ ERROR cross-crate traits with a default impl +} diff --git a/tests/ui/codemap_tests/empty_span.stderr b/tests/ui/codemap_tests/empty_span.stderr new file mode 100644 index 000000000..e36f59ee5 --- /dev/null +++ b/tests/ui/codemap_tests/empty_span.stderr @@ -0,0 +1,9 @@ +error[E0321]: cross-crate traits with a default impl, like `Send`, can only be implemented for a struct/enum type, not `&'static Foo` + --> $DIR/empty_span.rs:7:5 + | +LL | unsafe impl Send for &'static Foo { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0321`. diff --git a/tests/ui/codemap_tests/huge_multispan_highlight.rs b/tests/ui/codemap_tests/huge_multispan_highlight.rs new file mode 100644 index 000000000..623c59081 --- /dev/null +++ b/tests/ui/codemap_tests/huge_multispan_highlight.rs @@ -0,0 +1,91 @@ +fn main() { + let x = "foo"; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + let y = &mut x; //~ ERROR cannot borrow +} diff --git a/tests/ui/codemap_tests/huge_multispan_highlight.stderr b/tests/ui/codemap_tests/huge_multispan_highlight.stderr new file mode 100644 index 000000000..9f8ce3b61 --- /dev/null +++ b/tests/ui/codemap_tests/huge_multispan_highlight.stderr @@ -0,0 +1,14 @@ +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/huge_multispan_highlight.rs:90:13 + | +LL | let y = &mut x; + | ^^^^^^ cannot borrow as mutable + | +help: consider changing this to be mutable + | +LL | let mut x = "foo"; + | +++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/tests/ui/codemap_tests/issue-11715.rs b/tests/ui/codemap_tests/issue-11715.rs new file mode 100644 index 000000000..617d57ff7 --- /dev/null +++ b/tests/ui/codemap_tests/issue-11715.rs @@ -0,0 +1,11 @@ +#![feature(rustc_attrs)] +fn main() { #![rustc_error] // rust-lang/rust#49855 + let mut x = "foo"; + let y = &mut x; + let z = &mut x; //~ ERROR cannot borrow + z.use_mut(); + y.use_mut(); +} + +trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } } +impl<T> Fake for T { } diff --git a/tests/ui/codemap_tests/issue-11715.stderr b/tests/ui/codemap_tests/issue-11715.stderr new file mode 100644 index 000000000..a6b2b2e50 --- /dev/null +++ b/tests/ui/codemap_tests/issue-11715.stderr @@ -0,0 +1,14 @@ +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/issue-11715.rs:5:13 + | +LL | let y = &mut x; + | ------ first mutable borrow occurs here +LL | let z = &mut x; + | ^^^^^^ second mutable borrow occurs here +LL | z.use_mut(); +LL | y.use_mut(); + | ----------- first borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/codemap_tests/issue-28308.rs b/tests/ui/codemap_tests/issue-28308.rs new file mode 100644 index 000000000..81493f8c4 --- /dev/null +++ b/tests/ui/codemap_tests/issue-28308.rs @@ -0,0 +1,4 @@ +fn main() { + assert!("foo"); + //~^ ERROR cannot apply unary operator `!` +} diff --git a/tests/ui/codemap_tests/issue-28308.stderr b/tests/ui/codemap_tests/issue-28308.stderr new file mode 100644 index 000000000..7daa0510c --- /dev/null +++ b/tests/ui/codemap_tests/issue-28308.stderr @@ -0,0 +1,11 @@ +error[E0600]: cannot apply unary operator `!` to type `&'static str` + --> $DIR/issue-28308.rs:2:5 + | +LL | assert!("foo"); + | ^^^^^^^^^^^^^^ cannot apply unary operator `!` + | + = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0600`. diff --git a/tests/ui/codemap_tests/one_line.rs b/tests/ui/codemap_tests/one_line.rs new file mode 100644 index 000000000..bb36813db --- /dev/null +++ b/tests/ui/codemap_tests/one_line.rs @@ -0,0 +1,4 @@ +fn main() { + let mut v = vec![Some("foo"), Some("bar")]; + v.push(v.pop().unwrap()); //~ ERROR cannot borrow +} diff --git a/tests/ui/codemap_tests/one_line.stderr b/tests/ui/codemap_tests/one_line.stderr new file mode 100644 index 000000000..6fe6e2613 --- /dev/null +++ b/tests/ui/codemap_tests/one_line.stderr @@ -0,0 +1,24 @@ +error[E0499]: cannot borrow `v` as mutable more than once at a time + --> $DIR/one_line.rs:3:12 + | +LL | v.push(v.pop().unwrap()); + | -------^^^^^^^---------- + | | | | + | | | second mutable borrow occurs here + | | first borrow later used by call + | first mutable borrow occurs here + | +help: try adding a local storing this argument... + --> $DIR/one_line.rs:3:12 + | +LL | v.push(v.pop().unwrap()); + | ^^^^^^^ +help: ...and then using that local as the argument to this call + --> $DIR/one_line.rs:3:5 + | +LL | v.push(v.pop().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/codemap_tests/overlapping_inherent_impls.rs b/tests/ui/codemap_tests/overlapping_inherent_impls.rs new file mode 100644 index 000000000..66af21226 --- /dev/null +++ b/tests/ui/codemap_tests/overlapping_inherent_impls.rs @@ -0,0 +1,36 @@ +// Test that you cannot define items with the same name in overlapping inherent +// impl blocks. + +#![allow(unused)] + +struct Foo; + +impl Foo { + fn id() {} //~ ERROR duplicate definitions +} + +impl Foo { + fn id() {} +} + +struct Bar<T>(T); + +impl<T> Bar<T> { + fn bar(&self) {} //~ ERROR duplicate definitions +} + +impl Bar<u32> { + fn bar(&self) {} +} + +struct Baz<T>(T); + +impl<T: Copy> Baz<T> { + fn baz(&self) {} //~ ERROR duplicate definitions +} + +impl<T> Baz<Vec<T>> { + fn baz(&self) {} +} + +fn main() {} diff --git a/tests/ui/codemap_tests/overlapping_inherent_impls.stderr b/tests/ui/codemap_tests/overlapping_inherent_impls.stderr new file mode 100644 index 000000000..6fca12e18 --- /dev/null +++ b/tests/ui/codemap_tests/overlapping_inherent_impls.stderr @@ -0,0 +1,32 @@ +error[E0592]: duplicate definitions with name `id` + --> $DIR/overlapping_inherent_impls.rs:9:5 + | +LL | fn id() {} + | ^^^^^^^ duplicate definitions for `id` +... +LL | fn id() {} + | ------- other definition for `id` + +error[E0592]: duplicate definitions with name `bar` + --> $DIR/overlapping_inherent_impls.rs:19:5 + | +LL | fn bar(&self) {} + | ^^^^^^^^^^^^^ duplicate definitions for `bar` +... +LL | fn bar(&self) {} + | ------------- other definition for `bar` + +error[E0592]: duplicate definitions with name `baz` + --> $DIR/overlapping_inherent_impls.rs:29:5 + | +LL | fn baz(&self) {} + | ^^^^^^^^^^^^^ duplicate definitions for `baz` +... +LL | fn baz(&self) {} + | ------------- other definition for `baz` + | + = note: upstream crates may add a new impl of trait `std::marker::Copy` for type `std::vec::Vec<_>` in future versions + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0592`. diff --git a/tests/ui/codemap_tests/tab.rs b/tests/ui/codemap_tests/tab.rs new file mode 100644 index 000000000..64569f2e7 --- /dev/null +++ b/tests/ui/codemap_tests/tab.rs @@ -0,0 +1,9 @@ +// ignore-tidy-tab + +fn main() { + bar; //~ ERROR cannot find value `bar` +} + +fn foo() { + "bar boo" //~ ERROR mismatched types +} diff --git a/tests/ui/codemap_tests/tab.stderr b/tests/ui/codemap_tests/tab.stderr new file mode 100644 index 000000000..c3f19d20d --- /dev/null +++ b/tests/ui/codemap_tests/tab.stderr @@ -0,0 +1,18 @@ +error[E0425]: cannot find value `bar` in this scope + --> $DIR/tab.rs:4:2 + | +LL | bar; + | ^^^ not found in this scope + +error[E0308]: mismatched types + --> $DIR/tab.rs:8:2 + | +LL | fn foo() { + | - help: try adding a return type: `-> &'static str` +LL | "bar boo" + | ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `&str` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0308, E0425. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/codemap_tests/tab_2.rs b/tests/ui/codemap_tests/tab_2.rs new file mode 100644 index 000000000..644697c32 --- /dev/null +++ b/tests/ui/codemap_tests/tab_2.rs @@ -0,0 +1,5 @@ +// ignore-tidy-tab + +fn main() { + """; //~ ERROR unterminated double quote +} diff --git a/tests/ui/codemap_tests/tab_2.stderr b/tests/ui/codemap_tests/tab_2.stderr new file mode 100644 index 000000000..0bfdc3ac2 --- /dev/null +++ b/tests/ui/codemap_tests/tab_2.stderr @@ -0,0 +1,11 @@ +error[E0765]: unterminated double quote string + --> $DIR/tab_2.rs:4:7 + | +LL | """; + | ___________________^ +LL | | } + | |__^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0765`. diff --git a/tests/ui/codemap_tests/tab_3.rs b/tests/ui/codemap_tests/tab_3.rs new file mode 100644 index 000000000..58b034d0f --- /dev/null +++ b/tests/ui/codemap_tests/tab_3.rs @@ -0,0 +1,9 @@ +// ignore-tidy-tab + +fn main() { + let some_vec = vec!["hi"]; + some_vec.into_iter(); + { + println!("{:?}", some_vec); //~ ERROR borrow of moved + } +} diff --git a/tests/ui/codemap_tests/tab_3.stderr b/tests/ui/codemap_tests/tab_3.stderr new file mode 100644 index 000000000..17bea2f36 --- /dev/null +++ b/tests/ui/codemap_tests/tab_3.stderr @@ -0,0 +1,22 @@ +error[E0382]: borrow of moved value: `some_vec` + --> $DIR/tab_3.rs:7:20 + | +LL | let some_vec = vec!["hi"]; + | -------- move occurs because `some_vec` has type `Vec<&str>`, which does not implement the `Copy` trait +LL | some_vec.into_iter(); + | ----------- `some_vec` moved due to this method call +LL | { +LL | println!("{:?}", some_vec); + | ^^^^^^^^ value borrowed here after move + | +note: `into_iter` takes ownership of the receiver `self`, which moves `some_vec` + --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: you can `clone` the value and consume it, but this might not be your desired behavior + | +LL | some_vec.clone().into_iter(); + | ++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/codemap_tests/two_files.rs b/tests/ui/codemap_tests/two_files.rs new file mode 100644 index 000000000..71d97d3c2 --- /dev/null +++ b/tests/ui/codemap_tests/two_files.rs @@ -0,0 +1,7 @@ +include!("two_files_data.rs"); + +struct Baz { } + +impl Bar for Baz { } //~ ERROR expected trait, found type alias + +fn main() { } diff --git a/tests/ui/codemap_tests/two_files.stderr b/tests/ui/codemap_tests/two_files.stderr new file mode 100644 index 000000000..2eb3fd567 --- /dev/null +++ b/tests/ui/codemap_tests/two_files.stderr @@ -0,0 +1,15 @@ +error[E0404]: expected trait, found type alias `Bar` + --> $DIR/two_files.rs:5:6 + | +LL | impl Bar for Baz { } + | ^^^ type aliases cannot be used as traits + | +help: you might have meant to use `#![feature(trait_alias)]` instead of a `type` alias + --> $DIR/two_files_data.rs:5:1 + | +LL | trait Bar = dyn Foo; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0404`. diff --git a/tests/ui/codemap_tests/two_files_data.rs b/tests/ui/codemap_tests/two_files_data.rs new file mode 100644 index 000000000..b4d2f5d3c --- /dev/null +++ b/tests/ui/codemap_tests/two_files_data.rs @@ -0,0 +1,5 @@ +// ignore-test + +trait Foo { } + +type Bar = dyn Foo; diff --git a/tests/ui/codemap_tests/unicode.expanded.stdout b/tests/ui/codemap_tests/unicode.expanded.stdout new file mode 100644 index 000000000..d14bb42b2 --- /dev/null +++ b/tests/ui/codemap_tests/unicode.expanded.stdout @@ -0,0 +1,13 @@ +#![feature(prelude_import)] +#![no_std] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +// revisions: normal expanded +//[expanded] check-pass +//[expanded]compile-flags: -Zunpretty=expanded + +extern "路濫狼á́́" fn foo() {} + +fn main() {} diff --git a/tests/ui/codemap_tests/unicode.normal.stderr b/tests/ui/codemap_tests/unicode.normal.stderr new file mode 100644 index 000000000..05ceb6910 --- /dev/null +++ b/tests/ui/codemap_tests/unicode.normal.stderr @@ -0,0 +1,11 @@ +error[E0703]: invalid ABI: found `路濫狼á́́` + --> $DIR/unicode.rs:5:8 + | +LL | extern "路濫狼á́́" fn foo() {} + | ^^^^^^^^^ invalid ABI + | + = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions. + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0703`. diff --git a/tests/ui/codemap_tests/unicode.rs b/tests/ui/codemap_tests/unicode.rs new file mode 100644 index 000000000..4df9a5270 --- /dev/null +++ b/tests/ui/codemap_tests/unicode.rs @@ -0,0 +1,7 @@ +// revisions: normal expanded +//[expanded] check-pass +//[expanded]compile-flags: -Zunpretty=expanded + +extern "路濫狼á́́" fn foo() {} //[normal]~ ERROR invalid ABI + +fn main() { } diff --git a/tests/ui/codemap_tests/unicode_2.rs b/tests/ui/codemap_tests/unicode_2.rs new file mode 100644 index 000000000..3301e7a18 --- /dev/null +++ b/tests/ui/codemap_tests/unicode_2.rs @@ -0,0 +1,5 @@ +fn main() { + let _ = ("a̐éö̲", 0u7); //~ ERROR invalid width + let _ = ("아あ", 1i42); //~ ERROR invalid width + let _ = a̐é; //~ ERROR cannot find +} diff --git a/tests/ui/codemap_tests/unicode_2.stderr b/tests/ui/codemap_tests/unicode_2.stderr new file mode 100644 index 000000000..19aae1d3c --- /dev/null +++ b/tests/ui/codemap_tests/unicode_2.stderr @@ -0,0 +1,25 @@ +error[E0425]: cannot find value `a̐é` in this scope + --> $DIR/unicode_2.rs:4:13 + | +LL | let _ = a̐é; + | ^^ not found in this scope + +error: invalid width `7` for integer literal + --> $DIR/unicode_2.rs:2:25 + | +LL | let _ = ("a̐éö̲", 0u7); + | ^^^ + | + = help: valid widths are 8, 16, 32, 64 and 128 + +error: invalid width `42` for integer literal + --> $DIR/unicode_2.rs:3:20 + | +LL | let _ = ("아あ", 1i42); + | ^^^^ + | + = help: valid widths are 8, 16, 32, 64 and 128 + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/codemap_tests/unicode_3.rs b/tests/ui/codemap_tests/unicode_3.rs new file mode 100644 index 000000000..34582de45 --- /dev/null +++ b/tests/ui/codemap_tests/unicode_3.rs @@ -0,0 +1,6 @@ +// check-pass + +fn main() { + let s = "ZͨA͑ͦ͒͋ͤ͑̚L̄͑͋Ĝͨͥ̿͒̽̈́Oͥ͛ͭ!̏"; while true { break; } //~ WARNING while_true + println!("{}", s); +} diff --git a/tests/ui/codemap_tests/unicode_3.stderr b/tests/ui/codemap_tests/unicode_3.stderr new file mode 100644 index 000000000..a35ed99d8 --- /dev/null +++ b/tests/ui/codemap_tests/unicode_3.stderr @@ -0,0 +1,10 @@ +warning: denote infinite loops with `loop { ... }` + --> $DIR/unicode_3.rs:4:45 + | +LL | let s = "ZͨA͑ͦ͒͋ͤ͑̚L̄͑͋Ĝͨͥ̿͒̽̈́Oͥ͛ͭ!̏"; while true { break; } + | ^^^^^^^^^^ help: use `loop` + | + = note: `#[warn(while_true)]` on by default + +warning: 1 warning emitted + |