Make ty::Error implement auto traits
This commit is contained in:
parent
409998c4e8
commit
f349d720e7
5 changed files with 45 additions and 2 deletions
|
@ -819,7 +819,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
candidates.vec.push(AutoImplCandidate)
|
candidates.vec.push(AutoImplCandidate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::Error(_) => {} // do not add an auto trait impl for `ty::Error` for now.
|
ty::Error(_) => {
|
||||||
|
candidates.vec.push(AutoImplCandidate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
tests/ui/consts/error-is-freeze.rs
Normal file
14
tests/ui/consts/error-is-freeze.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// Make sure we treat the error type as freeze to suppress useless errors.
|
||||||
|
|
||||||
|
struct MyStruct {
|
||||||
|
foo: Option<UndefinedType>,
|
||||||
|
//~^ ERROR cannot find type `UndefinedType` in this scope
|
||||||
|
}
|
||||||
|
impl MyStruct {
|
||||||
|
pub const EMPTY_REF: &'static Self = &Self::EMPTY;
|
||||||
|
pub const EMPTY: Self = Self {
|
||||||
|
foo: None,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
14
tests/ui/consts/error-is-freeze.stderr
Normal file
14
tests/ui/consts/error-is-freeze.stderr
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
error[E0412]: cannot find type `UndefinedType` in this scope
|
||||||
|
--> $DIR/error-is-freeze.rs:4:17
|
||||||
|
|
|
||||||
|
LL | foo: Option<UndefinedType>,
|
||||||
|
| ^^^^^^^^^^^^^ not found in this scope
|
||||||
|
|
|
||||||
|
help: you might be missing a type parameter
|
||||||
|
|
|
||||||
|
LL | struct MyStruct<UndefinedType> {
|
||||||
|
| +++++++++++++++
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0412`.
|
|
@ -1,9 +1,9 @@
|
||||||
//@ known-bug: #131050
|
|
||||||
//@ compile-flags: --edition=2021
|
//@ compile-flags: --edition=2021
|
||||||
|
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
fn invalid_future() -> impl Future {}
|
fn invalid_future() -> impl Future {}
|
||||||
|
//~^ ERROR `()` is not a future
|
||||||
|
|
||||||
fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
|
fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
|
||||||
async { &|| async { invalid_future().await } }
|
async { &|| async { invalid_future().await } }
|
||||||
|
@ -21,3 +21,5 @@ where
|
||||||
R: Send,
|
R: Send,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
11
tests/ui/impl-trait/auto-trait-contains-err.stderr
Normal file
11
tests/ui/impl-trait/auto-trait-contains-err.stderr
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
error[E0277]: `()` is not a future
|
||||||
|
--> $DIR/auto-trait-contains-err.rs:5:24
|
||||||
|
|
|
||||||
|
LL | fn invalid_future() -> impl Future {}
|
||||||
|
| ^^^^^^^^^^^ `()` is not a future
|
||||||
|
|
|
||||||
|
= help: the trait `Future` is not implemented for `()`
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0277`.
|
Loading…
Add table
Add a link
Reference in a new issue