Skip to content

Commit

Permalink
Unrolled build for rust-lang#119184
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#119184 - Rajveer100:branch-for-issue-118752, r=davidtwco

Switch from using `//~ERROR` annotations with `--error-format` to `error-pattern`

Fixes rust-lang#118752

As noticed by ```@jyn514``` while working on a patch, tests failed due to `//~ERROR` annotations used in combination with the older `--error-format` which is now `error-pattern`.
  • Loading branch information
rust-timer committed Jan 4, 2024
2 parents 090d5ea + af44e71 commit 8a7ca2d
Show file tree
Hide file tree
Showing 22 changed files with 664 additions and 651 deletions.
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use once_cell::sync::Lazy;
use regex::Regex;
use tracing::*;

#[derive(Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum ErrorKind {
Help,
Error,
Expand Down
26 changes: 16 additions & 10 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3977,23 +3977,29 @@ impl<'test> TestCx<'test> {
proc_res.status,
self.props.error_patterns
);
if !explicit && self.config.compare_mode.is_none() {
let check_patterns = should_run == WillExecute::No
&& (!self.props.error_patterns.is_empty()
|| !self.props.regex_error_patterns.is_empty());

let check_patterns = should_run == WillExecute::No
&& (!self.props.error_patterns.is_empty()
|| !self.props.regex_error_patterns.is_empty());
if !explicit && self.config.compare_mode.is_none() {
let check_annotations = !check_patterns || !expected_errors.is_empty();

if check_patterns {
// "// error-pattern" comments
let output_to_check = self.get_output(&proc_res);
self.check_all_error_patterns(&output_to_check, &proc_res, pm);
}

if check_annotations {
// "//~ERROR comments"
self.check_expected_errors(expected_errors, &proc_res);
}
} else if explicit && !expected_errors.is_empty() {
let msg = format!(
"line {}: cannot combine `--error-format` with {} annotations; use `error-pattern` instead",
expected_errors[0].line_num,
expected_errors[0].kind.unwrap_or(ErrorKind::Error),
);
self.fatal(&msg);
}
if check_patterns {
// "// error-pattern" comments
let output_to_check = self.get_output(&proc_res);
self.check_all_error_patterns(&output_to_check, &proc_res, pm);
}

if self.props.run_rustfix && self.config.compare_mode.is_none() {
Expand Down
3 changes: 2 additions & 1 deletion tests/rustdoc-ui/issues/issue-81662-shortness.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// compile-flags:--test --error-format=short
// check-stdout
// error-pattern:cannot find function `foo` in this scope
// normalize-stdout-test: "tests/rustdoc-ui/issues" -> "$$DIR"
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
// failure-status: 101

/// ```rust
/// foo();
/// ```
//~^^ ERROR cannot find function `foo` in this scope
fn foo() {
println!("Hello, world!");
}
8 changes: 4 additions & 4 deletions tests/rustdoc-ui/issues/issue-81662-shortness.stdout
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

running 1 test
test $DIR/issue-81662-shortness.rs - foo (line 6) ... FAILED
test $DIR/issue-81662-shortness.rs - foo (line 8) ... FAILED

failures:

---- $DIR/issue-81662-shortness.rs - foo (line 6) stdout ----
$DIR/issue-81662-shortness.rs:7:1: error[E0425]: cannot find function `foo` in this scope
---- $DIR/issue-81662-shortness.rs - foo (line 8) stdout ----
$DIR/issue-81662-shortness.rs:9:1: error[E0425]: cannot find function `foo` in this scope
error: aborting due to 1 previous error
Couldn't compile the test.

failures:
$DIR/issue-81662-shortness.rs - foo (line 6)
$DIR/issue-81662-shortness.rs - foo (line 8)

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME

3 changes: 2 additions & 1 deletion tests/ui/annotate-snippet/missing-type.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// compile-flags: --error-format human-annotate-rs -Z unstable-options
// error-pattern:cannot find type `Iter` in this scope

pub fn main() {
let x: Iter; //~ ERROR cannot find type `Iter` in this scope
let x: Iter;
}
2 changes: 1 addition & 1 deletion tests/ui/annotate-snippet/missing-type.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0412]: cannot find type `Iter` in this scope
--> $DIR/missing-type.rs:4:12
--> $DIR/missing-type.rs:5:12
|
LL | let x: Iter;
| ^^^^ not found in this scope
Expand Down
15 changes: 8 additions & 7 deletions tests/ui/annotate-snippet/multispan.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// aux-build:multispan.rs
// error-pattern:hello to you, too!
// compile-flags: --error-format human-annotate-rs -Z unstable-options

#![feature(proc_macro_hygiene)]
Expand All @@ -12,17 +13,17 @@ fn main() {
hello!();

// Exactly one 'hi'.
hello!(hi); //~ ERROR hello to you, too!
hello!(hi);

// Now two, back to back.
hello!(hi hi); //~ ERROR hello to you, too!
hello!(hi hi);

// Now three, back to back.
hello!(hi hi hi); //~ ERROR hello to you, too!
hello!(hi hi hi);

// Now several, with spacing.
hello!(hi hey hi yo hi beep beep hi hi); //~ ERROR hello to you, too!
hello!(hi there, hi how are you? hi... hi.); //~ ERROR hello to you, too!
hello!(whoah. hi di hi di ho); //~ ERROR hello to you, too!
hello!(hi good hi and good bye); //~ ERROR hello to you, too!
hello!(hi hey hi yo hi beep beep hi hi);
hello!(hi there, hi how are you? hi... hi.);
hello!(whoah. hi di hi di ho);
hello!(hi good hi and good bye);
}
14 changes: 7 additions & 7 deletions tests/ui/annotate-snippet/multispan.stderr
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
error: hello to you, too!
--> $DIR/multispan.rs:15:5
--> $DIR/multispan.rs:16:5
|
LL | hello!(hi);
| ^^^^^^^^^^
|
error: hello to you, too!
--> $DIR/multispan.rs:18:5
--> $DIR/multispan.rs:19:5
|
LL | hello!(hi hi);
| ^^^^^^^^^^^^^
|
error: hello to you, too!
--> $DIR/multispan.rs:21:5
--> $DIR/multispan.rs:22:5
|
LL | hello!(hi hi hi);
| ^^^^^^^^^^^^^^^^
|
error: hello to you, too!
--> $DIR/multispan.rs:24:5
--> $DIR/multispan.rs:25:5
|
LL | hello!(hi hey hi yo hi beep beep hi hi);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
error: hello to you, too!
--> $DIR/multispan.rs:25:5
--> $DIR/multispan.rs:26:5
|
LL | hello!(hi there, hi how are you? hi... hi.);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
error: hello to you, too!
--> $DIR/multispan.rs:26:5
--> $DIR/multispan.rs:27:5
|
LL | hello!(whoah. hi di hi di ho);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
error: hello to you, too!
--> $DIR/multispan.rs:27:5
--> $DIR/multispan.rs:28:5
|
LL | hello!(hi good hi and good bye);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/diagnostic-width/flag-json.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// compile-flags: --diagnostic-width=20 --error-format=json
// error-pattern:expected `()`, found integer

// This test checks that `-Z output-width` effects the JSON error output by restricting it to an
// arbitrarily low value so that the effect is visible.

fn main() {
let _: () = 42;
//~^ ERROR arguments to this function are incorrect
}
4 changes: 2 additions & 2 deletions tests/ui/diagnostic-width/flag-json.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ This error occurs when an expression was used in a place where the compiler
expected an expression of a different type. It can occur in several cases, the
most common being when calling a function and passing an argument which has a
different type than the matching type in the function declaration.
"},"level":"error","spans":[{"file_name":"$DIR/flag-json.rs","byte_start":243,"byte_end":245,"line_start":7,"line_end":7,"column_start":17,"column_end":19,"is_primary":true,"text":[{"text":" let _: () = 42;","highlight_start":17,"highlight_end":19}],"label":"expected `()`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/flag-json.rs","byte_start":238,"byte_end":240,"line_start":7,"line_end":7,"column_start":12,"column_end":14,"is_primary":false,"text":[{"text":" let _: () = 42;","highlight_start":12,"highlight_end":14}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0308]: mismatched types
--> $DIR/flag-json.rs:7:17
"},"level":"error","spans":[{"file_name":"$DIR/flag-json.rs","byte_start":289,"byte_end":291,"line_start":8,"line_end":8,"column_start":17,"column_end":19,"is_primary":true,"text":[{"text":" let _: () = 42;","highlight_start":17,"highlight_end":19}],"label":"expected `()`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/flag-json.rs","byte_start":284,"byte_end":286,"line_start":8,"line_end":8,"column_start":12,"column_end":14,"is_primary":false,"text":[{"text":" let _: () = 42;","highlight_start":12,"highlight_end":14}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0308]: mismatched types
--> $DIR/flag-json.rs:8:17
|
LL | ..._: () = 42;
| -- ^^ expected `()`, found integer
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/lint/unused_parens_json_suggestion.fixed
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// compile-flags: --error-format json
// error-pattern:unnecessary parentheses
// run-rustfix

// The output for humans should just highlight the whole span without showing
Expand All @@ -13,7 +14,7 @@
fn main() {
// We want to suggest the properly-balanced expression `1 / (2 + 3)`, not
// the malformed `1 / (2 + 3`
let _a = 1 / (2 + 3); //~ERROR unnecessary parentheses
let _a = 1 / (2 + 3);
f();
}

Expand Down
3 changes: 2 additions & 1 deletion tests/ui/lint/unused_parens_json_suggestion.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// compile-flags: --error-format json
// error-pattern:unnecessary parentheses
// run-rustfix

// The output for humans should just highlight the whole span without showing
Expand All @@ -13,7 +14,7 @@
fn main() {
// We want to suggest the properly-balanced expression `1 / (2 + 3)`, not
// the malformed `1 / (2 + 3`
let _a = (1 / (2 + 3)); //~ERROR unnecessary parentheses
let _a = (1 / (2 + 3));
f();
}

Expand Down
6 changes: 3 additions & 3 deletions tests/ui/lint/unused_parens_json_suggestion.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{"$message_type":"diagnostic","message":"unnecessary parentheses around assigned value","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":577,"byte_end":578,"line_start":16,"line_end":16,"column_start":14,"column_end":15,"is_primary":true,"text":[{"text":" let _a = (1 / (2 + 3));
--> $DIR/unused_parens_json_suggestion.rs:16:14
{"$message_type":"diagnostic","message":"unnecessary parentheses around assigned value","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":618,"byte_end":619,"line_start":17,"line_end":17,"column_start":14,"column_end":15,"is_primary":true,"text":[{"text":" let _a = (1 / (2 + 3));","highlight_start":14,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":630,"byte_end":631,"line_start":17,"line_end":17,"column_start":26,"column_end":27,"is_primary":true,"text":[{"text":" let _a = (1 / (2 + 3));","highlight_start":26,"highlight_end":27}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"the lint level is defined here","code":null,"level":"note","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":436,"byte_end":449,"line_start":11,"line_end":11,"column_start":9,"column_end":22,"is_primary":true,"text":[{"text":"#![deny(unused_parens)]","highlight_start":9,"highlight_end":22}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"remove these parentheses","code":null,"level":"help","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":618,"byte_end":619,"line_start":17,"line_end":17,"column_start":14,"column_end":15,"is_primary":true,"text":[{"text":" let _a = (1 / (2 + 3));","highlight_start":14,"highlight_end":15}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null},{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":630,"byte_end":631,"line_start":17,"line_end":17,"column_start":26,"column_end":27,"is_primary":true,"text":[{"text":" let _a = (1 / (2 + 3));","highlight_start":26,"highlight_end":27}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error: unnecessary parentheses around assigned value
--> $DIR/unused_parens_json_suggestion.rs:17:14
|
LL | let _a = (1 / (2 + 3));
| ^ ^
|
note: the lint level is defined here
--> $DIR/unused_parens_json_suggestion.rs:10:9
--> $DIR/unused_parens_json_suggestion.rs:11:9
|
LL | #![deny(unused_parens)]
| ^^^^^^^^^^^^^
Expand Down
17 changes: 9 additions & 8 deletions tests/ui/lint/unused_parens_remove_json_suggestion.fixed
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// compile-flags: --error-format json
// error-pattern:unnecessary parentheses
// run-rustfix

// The output for humans should just highlight the whole span without showing
Expand All @@ -14,7 +15,7 @@ fn main() {

let _b = false;

if _b { //~ ERROR unnecessary parentheses
if _b {
println!("hello");
}

Expand All @@ -25,29 +26,29 @@ fn main() {
fn f() -> bool {
let c = false;

if c { //~ ERROR unnecessary parentheses
if c {
println!("next");
}

if c { //~ ERROR unnecessary parentheses
if c {
println!("prev");
}

while false && true {
if c { //~ ERROR unnecessary parentheses
if c {
println!("norm");
}

}

while true && false { //~ ERROR unnecessary parentheses
for _ in 0 .. 3 { //~ ERROR unnecessary parentheses
while true && false {
for _ in 0 .. 3 {
println!("e~")
}
}

for _ in 0 .. 3 { //~ ERROR unnecessary parentheses
while true && false { //~ ERROR unnecessary parentheses
for _ in 0 .. 3 {
while true && false {
println!("e~")
}
}
Expand Down
17 changes: 9 additions & 8 deletions tests/ui/lint/unused_parens_remove_json_suggestion.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// compile-flags: --error-format json
// error-pattern:unnecessary parentheses
// run-rustfix

// The output for humans should just highlight the whole span without showing
Expand All @@ -14,7 +15,7 @@ fn main() {

let _b = false;

if (_b) { //~ ERROR unnecessary parentheses
if (_b) {
println!("hello");
}

Expand All @@ -25,29 +26,29 @@ fn main() {
fn f() -> bool {
let c = false;

if(c) { //~ ERROR unnecessary parentheses
if(c) {
println!("next");
}

if (c){ //~ ERROR unnecessary parentheses
if (c){
println!("prev");
}

while (false && true){
if (c) { //~ ERROR unnecessary parentheses
if (c) {
println!("norm");
}

}

while(true && false) { //~ ERROR unnecessary parentheses
for _ in (0 .. 3){ //~ ERROR unnecessary parentheses
while(true && false) {
for _ in (0 .. 3){
println!("e~")
}
}

for _ in (0 .. 3) { //~ ERROR unnecessary parentheses
while (true && false) { //~ ERROR unnecessary parentheses
for _ in (0 .. 3) {
while (true && false) {
println!("e~")
}
}
Expand Down

0 comments on commit 8a7ca2d

Please sign in to comment.