Change ui tests to work whether or not rust-src is installed

This commit is contained in:
David Tolnay 2020-09-04 23:36:25 -07:00
parent 663d835689
commit 04b91d7646
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
8 changed files with 57 additions and 58 deletions

View File

@ -1,9 +0,0 @@
use thiserror::Error;
#[derive(Error, Debug)]
pub enum MyError {
First,
Second,
}
fn main() {}

View File

@ -1,8 +0,0 @@
error[E0277]: `MyError` doesn't implement `std::fmt::Display`
--> $DIR/missing-display.rs:4:1
|
4 | pub enum MyError {
| ^^^^^^^^^^^^^^^^ `MyError` cannot be formatted with the default formatter
|
= help: the trait `std::fmt::Display` is not implemented for `MyError`
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead

View File

@ -1,10 +1,12 @@
use std::thread::Thread;
use thiserror::Error;
#[derive(Debug)]
struct NoDisplay;
#[derive(Error, Debug)]
#[error("thread: {thread}")]
pub struct Error {
thread: Thread,
thread: NoDisplay,
}
fn main() {}

View File

@ -1,9 +1,12 @@
error[E0599]: no method named `as_display` found for reference `&Thread` in the current scope
--> $DIR/no-display.rs:5:9
|
5 | #[error("thread: {thread}")]
| ^^^^^^^^^^^^^^^^^^ method not found in `&Thread`
|
= note: the method `as_display` exists but the following trait bounds were not satisfied:
`Thread: std::fmt::Display`
which is required by `&Thread: DisplayAsDisplay`
error[E0599]: no method named `as_display` found for reference `&NoDisplay` in the current scope
--> $DIR/no-display.rs:7:9
|
4 | struct NoDisplay;
| ----------------- doesn't satisfy `NoDisplay: std::fmt::Display`
...
7 | #[error("thread: {thread}")]
| ^^^^^^^^^^^^^^^^^^ method not found in `&NoDisplay`
|
= note: the method `as_display` exists but the following trait bounds were not satisfied:
`NoDisplay: std::fmt::Display`
which is required by `&NoDisplay: DisplayAsDisplay`

View File

@ -1,10 +1,13 @@
use thiserror::Error;
#[derive(Debug)]
pub struct NotError;
#[derive(Error, Debug)]
#[error("...")]
pub enum ErrorEnum {
Broken {
source: String,
source: NotError,
},
}

View File

@ -1,15 +1,17 @@
error[E0599]: no method named `as_dyn_error` found for reference `&String` in the current scope
--> $DIR/source-enum-not-error.rs:7:9
|
7 | source: String,
| ^^^^^^ method not found in `&String`
|
= note: the method `as_dyn_error` exists but the following trait bounds were not satisfied:
`String: std::error::Error`
which is required by `String: AsDynError`
`&String: std::error::Error`
which is required by `&String: AsDynError`
`str: Sized`
which is required by `str: AsDynError`
`str: std::error::Error`
which is required by `str: AsDynError`
error[E0599]: no method named `as_dyn_error` found for reference `&NotError` in the current scope
--> $DIR/source-enum-not-error.rs:10:9
|
4 | pub struct NotError;
| --------------------
| |
| doesn't satisfy `NotError: AsDynError`
| doesn't satisfy `NotError: std::error::Error`
...
10 | source: NotError,
| ^^^^^^ method not found in `&NotError`
|
= note: the method `as_dyn_error` exists but the following trait bounds were not satisfied:
`NotError: std::error::Error`
which is required by `NotError: AsDynError`
`&NotError: std::error::Error`
which is required by `&NotError: AsDynError`

View File

@ -1,9 +1,12 @@
use thiserror::Error;
#[derive(Debug)]
struct NotError;
#[derive(Error, Debug)]
#[error("...")]
pub struct ErrorStruct {
source: String,
source: NotError,
}
fn main() {}

View File

@ -1,13 +1,16 @@
error[E0599]: no method named `as_dyn_error` found for struct `String` in the current scope
--> $DIR/source-struct-not-error.rs:6:5
|
6 | source: String,
| ^^^^^^ method not found in `String`
|
= note: the method `as_dyn_error` exists but the following trait bounds were not satisfied:
`String: std::error::Error`
which is required by `String: AsDynError`
`str: Sized`
which is required by `str: AsDynError`
`str: std::error::Error`
which is required by `str: AsDynError`
error[E0599]: no method named `as_dyn_error` found for struct `NotError` in the current scope
--> $DIR/source-struct-not-error.rs:9:5
|
4 | struct NotError;
| ----------------
| |
| method `as_dyn_error` not found for this
| doesn't satisfy `NotError: AsDynError`
| doesn't satisfy `NotError: std::error::Error`
...
9 | source: NotError,
| ^^^^^^ method not found in `NotError`
|
= note: the method `as_dyn_error` exists but the following trait bounds were not satisfied:
`NotError: std::error::Error`
which is required by `NotError: AsDynError`