-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add JSON error-format UI test expectations
This checks in a baseline so that it's easy to see the diff when we change the output in a subsequent commit. These examples are from and for #53934.
- Loading branch information
1 parent
2596bc1
commit 3e41c8d
Showing
4 changed files
with
326 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// compile-flags: --error-format pretty-json -Zunstable-options | ||
|
||
struct Point { x: isize, y: isize } | ||
|
||
fn main() { | ||
let p = Point { x: 1, y: 2 }; | ||
let Point { .., y, } = p; | ||
} |
126 changes: 126 additions & 0 deletions
126
src/test/ui/json_error_format/issue-53934-multiple-parts.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
{ | ||
"message": "expected `}`, found `,`", | ||
"code": null, | ||
"level": "error", | ||
"spans": [ | ||
{ | ||
"file_name": "$DIR/issue-53934-multiple-parts.rs", | ||
"byte_start": 166, | ||
"byte_end": 167, | ||
"line_start": 7, | ||
"line_end": 7, | ||
"column_start": 19, | ||
"column_end": 20, | ||
"is_primary": true, | ||
"text": [ | ||
{ | ||
"text": " let Point { .., y, } = p;", | ||
"highlight_start": 19, | ||
"highlight_end": 20 | ||
} | ||
], | ||
"label": "expected `}`", | ||
"suggested_replacement": null, | ||
"suggestion_applicability": null, | ||
"expansion": null | ||
}, | ||
{ | ||
"file_name": "$DIR/issue-53934-multiple-parts.rs", | ||
"byte_start": 164, | ||
"byte_end": 167, | ||
"line_start": 7, | ||
"line_end": 7, | ||
"column_start": 17, | ||
"column_end": 20, | ||
"is_primary": false, | ||
"text": [ | ||
{ | ||
"text": " let Point { .., y, } = p;", | ||
"highlight_start": 17, | ||
"highlight_end": 20 | ||
} | ||
], | ||
"label": "`..` must be at the end and cannot have a trailing comma", | ||
"suggested_replacement": null, | ||
"suggestion_applicability": null, | ||
"expansion": null | ||
} | ||
], | ||
"children": [ | ||
{ | ||
"message": "move the `..` to the end of the field list", | ||
"code": null, | ||
"level": "help", | ||
"spans": [ | ||
{ | ||
"file_name": "$DIR/issue-53934-multiple-parts.rs", | ||
"byte_start": 164, | ||
"byte_end": 168, | ||
"line_start": 7, | ||
"line_end": 7, | ||
"column_start": 17, | ||
"column_end": 21, | ||
"is_primary": true, | ||
"text": [ | ||
{ | ||
"text": " let Point { .., y, } = p;", | ||
"highlight_start": 17, | ||
"highlight_end": 21 | ||
} | ||
], | ||
"label": null, | ||
"suggested_replacement": "", | ||
"suggestion_applicability": "MachineApplicable", | ||
"expansion": null | ||
}, | ||
{ | ||
"file_name": "$DIR/issue-53934-multiple-parts.rs", | ||
"byte_start": 171, | ||
"byte_end": 172, | ||
"line_start": 7, | ||
"line_end": 7, | ||
"column_start": 24, | ||
"column_end": 25, | ||
"is_primary": true, | ||
"text": [ | ||
{ | ||
"text": " let Point { .., y, } = p;", | ||
"highlight_start": 24, | ||
"highlight_end": 25 | ||
} | ||
], | ||
"label": null, | ||
"suggested_replacement": ".. }", | ||
"suggestion_applicability": "MachineApplicable", | ||
"expansion": null | ||
} | ||
], | ||
"children": [], | ||
"rendered": null | ||
} | ||
], | ||
"rendered": "error: expected `}`, found `,` | ||
--> $DIR/issue-53934-multiple-parts.rs:7:19 | ||
| | ||
LL | let Point { .., y, } = p; | ||
| --^ | ||
| | | | ||
| | expected `}` | ||
| `..` must be at the end and cannot have a trailing comma | ||
help: move the `..` to the end of the field list | ||
| | ||
LL | let Point { y, .. } = p; | ||
| -- ^^^^ | ||
|
||
" | ||
} | ||
{ | ||
"message": "aborting due to previous error", | ||
"code": null, | ||
"level": "error", | ||
"spans": [], | ||
"children": [], | ||
"rendered": "error: aborting due to previous error | ||
|
||
" | ||
} |
7 changes: 7 additions & 0 deletions
7
src/test/ui/json_error_format/issue-53934-multiple-substitutions.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// compile-flags: --error-format pretty-json -Zunstable-options | ||
|
||
fn main() { | ||
let xs = vec![String::from("foo")]; | ||
let d: &Display = &xs; | ||
println!("{}", d); | ||
} |
185 changes: 185 additions & 0 deletions
185
src/test/ui/json_error_format/issue-53934-multiple-substitutions.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
{ | ||
"message": "cannot find type `Display` in this scope", | ||
"code": { | ||
"code": "E0412", | ||
"explanation": " | ||
The type name used is not in scope. | ||
|
||
Erroneous code examples: | ||
|
||
```compile_fail,E0412 | ||
impl Something {} // error: type name `Something` is not in scope | ||
|
||
// or: | ||
|
||
trait Foo { | ||
fn bar(N); // error: type name `N` is not in scope | ||
} | ||
|
||
// or: | ||
|
||
fn foo(x: T) {} // type name `T` is not in scope | ||
``` | ||
|
||
To fix this error, please verify you didn't misspell the type name, you did | ||
declare it or imported it into the scope. Examples: | ||
|
||
``` | ||
struct Something; | ||
|
||
impl Something {} // ok! | ||
|
||
// or: | ||
|
||
trait Foo { | ||
type N; | ||
|
||
fn bar(_: Self::N); // ok! | ||
} | ||
|
||
// or: | ||
|
||
fn foo<T>(x: T) {} // ok! | ||
``` | ||
|
||
Another case that causes this error is when a type is imported into a parent | ||
module. To fix this, you can follow the suggestion and use File directly or | ||
`use super::File;` which will import the types from the parent namespace. An | ||
example that causes this error is below: | ||
|
||
```compile_fail,E0412 | ||
use std::fs::File; | ||
|
||
mod foo { | ||
fn some_function(f: File) {} | ||
} | ||
``` | ||
|
||
``` | ||
use std::fs::File; | ||
|
||
mod foo { | ||
// either | ||
use super::File; | ||
// or | ||
// use std::fs::File; | ||
fn foo(f: File) {} | ||
} | ||
# fn main() {} // don't insert it for us; that'll break imports | ||
``` | ||
" | ||
}, | ||
"level": "error", | ||
"spans": [ | ||
{ | ||
"file_name": "$DIR/issue-53934-multiple-substitutions.rs", | ||
"byte_start": 129, | ||
"byte_end": 136, | ||
"line_start": 5, | ||
"line_end": 5, | ||
"column_start": 13, | ||
"column_end": 20, | ||
"is_primary": true, | ||
"text": [ | ||
{ | ||
"text": " let d: &Display = &xs;", | ||
"highlight_start": 13, | ||
"highlight_end": 20 | ||
} | ||
], | ||
"label": "not found in this scope", | ||
"suggested_replacement": null, | ||
"suggestion_applicability": null, | ||
"expansion": null | ||
} | ||
], | ||
"children": [ | ||
{ | ||
"message": "possible candidates are found in other modules, you can import them into scope", | ||
"code": null, | ||
"level": "help", | ||
"spans": [ | ||
{ | ||
"file_name": "$DIR/issue-53934-multiple-substitutions.rs", | ||
"byte_start": 65, | ||
"byte_end": 65, | ||
"line_start": 3, | ||
"line_end": 3, | ||
"column_start": 1, | ||
"column_end": 1, | ||
"is_primary": true, | ||
"text": [ | ||
{ | ||
"text": "fn main() {", | ||
"highlight_start": 1, | ||
"highlight_end": 1 | ||
} | ||
], | ||
"label": null, | ||
"suggested_replacement": "use std::fmt::Display; | ||
|
||
", | ||
"suggestion_applicability": "Unspecified", | ||
"expansion": null | ||
}, | ||
{ | ||
"file_name": "$DIR/issue-53934-multiple-substitutions.rs", | ||
"byte_start": 65, | ||
"byte_end": 65, | ||
"line_start": 3, | ||
"line_end": 3, | ||
"column_start": 1, | ||
"column_end": 1, | ||
"is_primary": true, | ||
"text": [ | ||
{ | ||
"text": "fn main() {", | ||
"highlight_start": 1, | ||
"highlight_end": 1 | ||
} | ||
], | ||
"label": null, | ||
"suggested_replacement": "use std::path::Display; | ||
|
||
", | ||
"suggestion_applicability": "Unspecified", | ||
"expansion": null | ||
} | ||
], | ||
"children": [], | ||
"rendered": null | ||
} | ||
], | ||
"rendered": "error[E0412]: cannot find type `Display` in this scope | ||
--> $DIR/issue-53934-multiple-substitutions.rs:5:13 | ||
| | ||
LL | let d: &Display = &xs; | ||
| ^^^^^^^ not found in this scope | ||
help: possible candidates are found in other modules, you can import them into scope | ||
| | ||
LL | use std::fmt::Display; | ||
| | ||
LL | use std::path::Display; | ||
| | ||
|
||
" | ||
} | ||
{ | ||
"message": "aborting due to previous error", | ||
"code": null, | ||
"level": "error", | ||
"spans": [], | ||
"children": [], | ||
"rendered": "error: aborting due to previous error | ||
|
||
" | ||
} | ||
{ | ||
"message": "For more information about this error, try `rustc --explain E0412`.", | ||
"code": null, | ||
"level": "", | ||
"spans": [], | ||
"children": [], | ||
"rendered": "For more information about this error, try `rustc --explain E0412`. | ||
" | ||
} |