Skip to content

Commit e2ccade

Browse files
authored
Unrolled build for rust-lang#139760
Rollup merge of rust-lang#139760 - petrochenkov:noerrpat2, r=jieyouxu UI tests: migrate remaining compile time `error-pattern`s to line annotations when possible There's a number of cases in which `error-pattern` is still necessary even for compile time checking. - It checks something that compiler writes directly into stderr as text, and not to the structured json output. This includes some stuff reported during compiler panics, and also diagnostics that happen very early, for example when parsing the command line. - It checks something that exists only in the full rendered diagnostic test, but not in its structured components, for example code fragments or output of `-Ztrack-diagnostics`. (The latter can probably be converted to structured form though.) This is continuation of rust-lang#139137. r? `@jieyouxu`
2 parents f836ae4 + 93bee07 commit e2ccade

File tree

66 files changed

+321
-293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+321
-293
lines changed

Diff for: tests/incremental/const-generic-type-cycle.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//
44
//@ compile-flags: -Zincremental-ignore-spans
55
//@ revisions: cpass cfail
6-
//@ error-pattern: cycle detected when computing type of `Bar::N`
76

87
#![feature(trait_alias)]
98
#![crate_type="lib"]
@@ -13,5 +12,9 @@ trait Bar<const N: usize> {}
1312

1413
#[cfg(cfail)]
1514
trait Bar<const N: dyn BB> {}
15+
//[cfail]~^ ERROR cycle detected when computing type of `Bar::N`
16+
//[cfail]~| ERROR cycle detected when computing type of `Bar::N`
17+
//[cfail]~| ERROR cycle detected when computing type of `Bar::N`
18+
//[cfail]~| ERROR `(dyn Bar<{ 2 + 1 }> + 'static)` is forbidden as the type of a const generic parameter
1619

1720
trait BB = Bar<{ 2 + 1 }>;

Diff for: tests/incremental/delayed_span_bug.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//@ revisions: cfail1 cfail2
22
//@ should-ice
3-
//@ error-pattern: delayed bug triggered by #[rustc_delayed_bug_from_inside_query]
43

54
#![feature(rustc_attrs)]
65

76
#[rustc_delayed_bug_from_inside_query]
8-
fn main() {}
7+
fn main() {} //~ ERROR delayed bug triggered by #[rustc_delayed_bug_from_inside_query]

Diff for: tests/incremental/link_order/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ aux-build:my_lib.rs
2-
//@ error-pattern: error: linking with
32
//@ revisions:cfail1 cfail2
43
//@ compile-flags:-Z query-dep-graph
54

@@ -10,3 +9,5 @@
109
extern crate my_lib;
1110

1211
fn main() {}
12+
13+
//~? ERROR linking with

Diff for: tests/rustdoc-ui/deprecated-attrs.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ compile-flags: --passes unknown-pass
2-
//@ error-pattern: the `passes` flag no longer functions
32

43
#![doc(no_default_passes)]
54
//~^ ERROR unknown `doc` attribute `no_default_passes`

Diff for: tests/rustdoc-ui/deprecated-attrs.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: the `passes` flag no longer functions
44
= help: you may want to use --document-private-items
55

66
error: unknown `doc` attribute `no_default_passes`
7-
--> $DIR/deprecated-attrs.rs:4:8
7+
--> $DIR/deprecated-attrs.rs:3:8
88
|
99
LL | #![doc(no_default_passes)]
1010
| ^^^^^^^^^^^^^^^^^ no longer functions
@@ -15,7 +15,7 @@ LL | #![doc(no_default_passes)]
1515
= note: `#[deny(invalid_doc_attributes)]` on by default
1616

1717
error: unknown `doc` attribute `passes`
18-
--> $DIR/deprecated-attrs.rs:11:8
18+
--> $DIR/deprecated-attrs.rs:10:8
1919
|
2020
LL | #![doc(passes = "collapse-docs unindent-comments")]
2121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no longer functions
@@ -25,7 +25,7 @@ LL | #![doc(passes = "collapse-docs unindent-comments")]
2525
= note: `doc(passes)` is now a no-op
2626

2727
error: unknown `doc` attribute `plugins`
28-
--> $DIR/deprecated-attrs.rs:17:8
28+
--> $DIR/deprecated-attrs.rs:16:8
2929
|
3030
LL | #![doc(plugins = "xxx")]
3131
| ^^^^^^^^^^^^^^^ no longer functions

Diff for: tests/rustdoc-ui/invalid-theme-name.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
//@ compile-flags:--theme {{src-base}}/invalid-theme-name.rs
2-
//@ error-pattern: must have a .css extension
32

43
//~? ERROR invalid argument: "$DIR/invalid-theme-name.rs"
4+
//~? HELP must have a .css extension

Diff for: tests/ui-fulldeps/missing-rustc-driver-error.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
// Test that we get the following hint when trying to use a compiler crate without rustc_driver.
2-
//@ error-pattern: try adding `extern crate rustc_driver;` at the top level of this crate
3-
//@ compile-flags: --emit link --error-format=human
2+
//@ compile-flags: --emit link
43
//@ normalize-stderr: ".*crate .* required.*\n\n" -> ""
54
//@ normalize-stderr: "aborting due to [0-9]+" -> "aborting due to NUMBER"
5+
//@ dont-require-annotations: ERROR
66

77
#![feature(rustc_private)]
88

99
extern crate rustc_serialize;
1010

1111
fn main() {}
12+
13+
//~? HELP try adding `extern crate rustc_driver;` at the top level of this crate
14+
//~? HELP try adding `extern crate rustc_driver;` at the top level of this crate
15+
//~? HELP try adding `extern crate rustc_driver;` at the top level of this crate

Diff for: tests/ui/abi/fixed_x18.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Behavior on aarch64 is tested by tests/codegen/fixed-x18.rs.
33
//
44
//@ revisions: x64 i686 arm riscv32 riscv64
5-
//@ error-pattern: the `-Zfixed-x18` flag is not supported
65
//@ dont-check-compiler-stderr
76
//
87
//@ compile-flags: -Zfixed-x18

Diff for: tests/ui/associated-types/issue-36499.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//@ error-pattern: aborting due to 1 previous error
2-
31
fn main() {
42
2 + +2; //~ ERROR leading `+` is not supported
53
}

Diff for: tests/ui/associated-types/issue-36499.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: leading `+` is not supported
2-
--> $DIR/issue-36499.rs:4:9
2+
--> $DIR/issue-36499.rs:2:9
33
|
44
LL | 2 + +2;
55
| ^ unexpected `+`

Diff for: tests/ui/check-cfg/cargo-feature.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//@ [none]compile-flags: --check-cfg=cfg(feature,values())
1111
//@ [some]compile-flags: --check-cfg=cfg(feature,values("bitcode"))
1212
//@ [some]compile-flags: --check-cfg=cfg(CONFIG_NVME,values("y"))
13-
//@ [none]error-pattern:Cargo.toml
13+
//@ dont-require-annotations: HELP
1414

1515
#[cfg(feature = "serde")]
1616
//~^ WARNING unexpected `cfg` condition value
@@ -27,6 +27,7 @@ fn tokio() {}
2727
#[cfg(CONFIG_NVME = "m")]
2828
//[none]~^ WARNING unexpected `cfg` condition name
2929
//[some]~^^ WARNING unexpected `cfg` condition value
30+
//[none]~| HELP Cargo.toml
3031
fn tokio() {}
3132

3233
fn main() {}

Diff for: tests/ui/codegen/empty-static-libs-issue-108825.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
44
//@ compile-flags: -Cpanic=abort --print=native-static-libs
55
//@ build-pass
6-
//@ error-pattern: note: native-static-libs:
76
//@ dont-check-compiler-stderr (libcore links `/defaultlib:msvcrt` or `/defaultlib:libcmt` on MSVC)
87
//@ ignore-pass (the note is emitted later in the compilation pipeline, needs build)
98

@@ -14,3 +13,6 @@
1413
fn panic(_info: &core::panic::PanicInfo) -> ! {
1514
loop {}
1615
}
16+
17+
//~? NOTE native-static-libs:
18+
//~? NOTE Link against the following native artifacts when linking against this static library
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
//@ compile-flags: --error-format=human --cfg a(b=c)
2-
//@ error-pattern: invalid `--cfg` argument: `a(b=c)` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\")
1+
//@ compile-flags: --cfg a(b=c)
2+
33
fn main() {}
4+
5+
//~? ERROR invalid `--cfg` argument: `a(b=c)` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\")
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
//@ compile-flags: --error-format=human --cfg a{b}
2-
//@ error-pattern: invalid `--cfg` argument: `a{b}` (expected `key` or `key="value"`)
1+
//@ compile-flags: --cfg a{b}
2+
33
fn main() {}
4+
5+
//~? ERROR invalid `--cfg` argument: `a{b}` (expected `key` or `key="value"`)
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
//@ compile-flags: --error-format=human --cfg a(b)
2-
//@ error-pattern: invalid `--cfg` argument: `a(b)` (expected `key` or `key="value"`)
1+
//@ compile-flags: --cfg a(b)
2+
33
fn main() {}
4+
5+
//~? ERROR invalid `--cfg` argument: `a(b)` (expected `key` or `key="value"`)
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
//@ compile-flags: --error-format=human --cfg a{
2-
//@ error-pattern: invalid `--cfg` argument: `a{` (expected `key` or `key="value"`)
1+
//@ compile-flags: --cfg a{
2+
33
fn main() {}
4+
5+
//~? ERROR invalid `--cfg` argument: `a{` (expected `key` or `key="value"`)
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
//@ compile-flags: --error-format=human --cfg )
2-
//@ error-pattern: invalid `--cfg` argument: `)` (expected `key` or `key="value"`)
1+
//@ compile-flags: --cfg )
2+
33
fn main() {}
4+
5+
//~? ERROR invalid `--cfg` argument: `)` (expected `key` or `key="value"`)
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Test for missing quotes around value, issue #66450.
2-
//@ compile-flags: --error-format=human --cfg key=value
3-
//@ error-pattern: invalid `--cfg` argument: `key=value` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\")
2+
//@ compile-flags: --cfg key=value
3+
44
fn main() {}
5+
6+
//~? ERROR invalid `--cfg` argument: `key=value` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\")
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Tests that empty source_maps don't ICE (#23301)
22

3-
//@ compile-flags: --error-format=human --cfg ""
4-
5-
//@ error-pattern: invalid `--cfg` argument: `""` (expected `key` or `key="value"`)
3+
//@ compile-flags: --cfg ""
64

75
pub fn main() {
86
}
7+
8+
//~? ERROR invalid `--cfg` argument: `""` (expected `key` or `key="value"`)

Diff for: tests/ui/consts/miri_unleashed/drop.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ compile-flags: -Zunleash-the-miri-inside-of-you
2-
//@ error-pattern: calling non-const function `<Vec<i32> as Drop>::drop`
32

43
use std::mem::ManuallyDrop;
54

@@ -15,5 +14,7 @@ static TEST_OK: () = {
1514
static TEST_BAD: () = {
1615
let _v: Vec<i32> = Vec::new();
1716
}; //~ ERROR could not evaluate static initializer
17+
//~| NOTE calling non-const function `<Vec<i32> as Drop>::drop`
18+
//~| NOTE inside `std::ptr::drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))`
1819

1920
//~? WARN skipping const checks

Diff for: tests/ui/consts/miri_unleashed/drop.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: could not evaluate static initializer
2-
--> $DIR/drop.rs:17:1
2+
--> $DIR/drop.rs:16:1
33
|
44
LL | };
55
| ^ calling non-const function `<Vec<i32> as Drop>::drop`
@@ -10,7 +10,7 @@ note: inside `std::ptr::drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))`
1010
warning: skipping const checks
1111
|
1212
help: skipping check that does not even have a feature gate
13-
--> $DIR/drop.rs:16:9
13+
--> $DIR/drop.rs:15:9
1414
|
1515
LL | let _v: Vec<i32> = Vec::new();
1616
| ^^

Diff for: tests/ui/debuginfo/dwarf-versions.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//@[zero] compile-flags: -Zdwarf-version=0
77

88
//@[one] compile-flags: -Zdwarf-version=1
9-
//@[one] error-pattern: requested DWARF version 1 is not supported
109

1110
//@[two] compile-flags: -Zdwarf-version=2
1211
//@[two] check-pass

Diff for: tests/ui/error-codes/E0152-duplicate-lang-items.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
//!
44
//! Issue: <https://github.com/rust-lang/rust/issues/31788>
55
6-
//@ error-pattern: first defined in crate `std`
76
//@ normalize-stderr: "loaded from .*libstd-.*.rlib" -> "loaded from SYSROOT/libstd-*.rlib"
7+
//@ dont-require-annotations: NOTE
8+
89
#![feature(lang_items)]
910

1011
extern crate core;
@@ -14,6 +15,7 @@ use core::panic::PanicInfo;
1415
#[lang = "panic_impl"]
1516
fn panic_impl(info: &PanicInfo) -> ! {
1617
//~^ ERROR: found duplicate lang item `panic_impl`
18+
//~| NOTE first defined in crate `std`
1719
loop {}
1820
}
1921

Diff for: tests/ui/error-codes/E0152-duplicate-lang-items.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
error[E0152]: found duplicate lang item `panic_impl`
2-
--> $DIR/E0152-duplicate-lang-items.rs:15:1
2+
--> $DIR/E0152-duplicate-lang-items.rs:16:1
33
|
44
LL | / fn panic_impl(info: &PanicInfo) -> ! {
55
LL | |
6+
LL | |
67
LL | | loop {}
78
LL | | }
89
| |_^

Diff for: tests/ui/error-codes/E0602.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//@ compile-flags:-D bogus
22
//@ check-pass
3-
4-
//@ error-pattern:requested on the command line with `-D bogus`
5-
//@ error-pattern:`#[warn(unknown_lints)]` on by default
3+
//@ dont-require-annotations: NOTE
64

75
fn main() {}
86

97
//~? WARN unknown lint: `bogus`
108
//~? WARN unknown lint: `bogus`
119
//~? WARN unknown lint: `bogus`
10+
//~? NOTE requested on the command line with `-D bogus`
11+
//~? NOTE `#[warn(unknown_lints)]` on by default

Diff for: tests/ui/extern-flag/invalid-crate-name-dashed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ compile-flags: --extern=my-awesome-library=libawesome.rlib
2-
//@ error-pattern: consider replacing the dashes with underscores: `my_awesome_library`
32

43
// In a sense, this is a regression test for issue #113035. We no longer suggest
54
// `pub use my-awesome-library::*;` (sic!) as we outright ban this crate name.
@@ -9,3 +8,4 @@ pub use my_awesome_library::*;
98
fn main() {}
109

1110
//~? ERROR crate name `my-awesome-library` passed to `--extern` is not a valid ASCII identifier
11+
//~? HELP consider replacing the dashes with underscores: `my_awesome_library`

Diff for: tests/ui/issues/issue-37131.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//~ ERROR can't find crate for `std`
2+
//~| NOTE target may not be installed
3+
//~| NOTE can't find crate
24
// Tests that compiling for a target which is not installed will result in a helpful
35
// error message.
46

57
//@ compile-flags: --target=thumbv6m-none-eabi
68
//@ ignore-arm
79
//@ needs-llvm-components: arm
810

9-
//@ error-pattern:target may not be installed
1011
fn main() { }

Diff for: tests/ui/layout/unknown-when-no-type-parameter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#![feature(trivial_bounds)]
22

3-
//@ error-pattern: the type `<() as Project>::Assoc` has an unknown layout
4-
53
trait Project {
64
type Assoc;
75
}
86

97
fn foo() where (): Project {
108
[(); size_of::<<() as Project>::Assoc>()]; //~ ERROR evaluation of constant value failed
9+
//~| NOTE the type `<() as Project>::Assoc` has an unknown layout
10+
//~| NOTE inside `std::mem::size_of::<<() as Project>::Assoc>`
1111
}
1212

1313
fn main() {}

Diff for: tests/ui/layout/unknown-when-no-type-parameter.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: evaluation of constant value failed
2-
--> $DIR/unknown-when-no-type-parameter.rs:10:10
2+
--> $DIR/unknown-when-no-type-parameter.rs:8:10
33
|
44
LL | [(); size_of::<<() as Project>::Assoc>()];
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `<() as Project>::Assoc` has an unknown layout

Diff for: tests/ui/link-native-libs/suggest-libname-only-1.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//@ build-fail
22
//@ compile-flags: --crate-type rlib
3-
//@ error-pattern: only provide the library name `foo`, not the full filename
43

54
#[link(name = "libfoo.a", kind = "static")]
65
extern { } //~ WARN extern declarations without an explicit ABI are deprecated
6+
//~| HELP explicitly specify the "C" ABI
77

88
pub fn main() { }
99

1010
//~? ERROR could not find native static library `libfoo.a`
11+
//~? HELP only provide the library name `foo`, not the full filename

Diff for: tests/ui/link-native-libs/suggest-libname-only-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: extern declarations without an explicit ABI are deprecated
2-
--> $DIR/suggest-libname-only-1.rs:6:1
2+
--> $DIR/suggest-libname-only-1.rs:5:1
33
|
44
LL | extern { }
55
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`

Diff for: tests/ui/link-native-libs/suggest-libname-only-2.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//@ build-fail
22
//@ compile-flags: --crate-type rlib
3-
//@ error-pattern: only provide the library name `bar`, not the full filename
43

54
#[link(name = "bar.lib", kind = "static")]
65
extern { } //~ WARN extern declarations without an explicit ABI are deprecated
6+
//~| HELP explicitly specify the "C" ABI
77

88
pub fn main() { }
99

1010
//~? ERROR could not find native static library `bar.lib`
11+
//~? HELP only provide the library name `bar`, not the full filename

Diff for: tests/ui/link-native-libs/suggest-libname-only-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: extern declarations without an explicit ABI are deprecated
2-
--> $DIR/suggest-libname-only-2.rs:6:1
2+
--> $DIR/suggest-libname-only-2.rs:5:1
33
|
44
LL | extern { }
55
| ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`

Diff for: tests/ui/lint/cli-unknown-force-warn.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
//@ check-pass
55
//@ compile-flags: --force-warn foo-qux
6-
7-
//@ error-pattern: requested on the command line with `--force-warn foo_qux`
8-
//@ error-pattern: `#[warn(unknown_lints)]` on by default
6+
//@ dont-require-annotations: NOTE
97

108
fn main() {}
119

1210
//~? WARN unknown lint: `foo_qux`
1311
//~? WARN unknown lint: `foo_qux`
1412
//~? WARN unknown lint: `foo_qux`
13+
//~? NOTE requested on the command line with `--force-warn foo_qux`
14+
//~? NOTE `#[warn(unknown_lints)]` on by default

0 commit comments

Comments
 (0)