Make ty::Error implement auto traits · rust-lang/rust@f349d72 (original) (raw)

File tree

5 files changed

lines changed

5 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -819,7 +819,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
819 819 candidates.vec.push(AutoImplCandidate)
820 820 }
821 821 }
822 - ty::Error(_) => {} // do not add an auto trait impl for `ty::Error` for now.
822 + ty::Error(_) => {
823 + candidates.vec.push(AutoImplCandidate);
824 +}
823 825 }
824 826 }
825 827 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
1 +// Make sure we treat the error type as freeze to suppress useless errors.
2 +
3 +struct MyStruct {
4 +foo: Option<UndefinedType>,
5 +//~^ ERROR cannot find type `UndefinedType` in this scope
6 +}
7 +impl MyStruct {
8 +pub const EMPTY_REF: &'static Self = &Self::EMPTY;
9 +pub const EMPTY: Self = Self {
10 +foo: None,
11 +};
12 +}
13 +
14 +fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
1 +error[E0412]: cannot find type `UndefinedType` in this scope
2 + --> $DIR/error-is-freeze.rs:4:17
3 + |
4 +LL | foo: Option,
5 + | ^^^^^^^^^^^^^ not found in this scope
6 + |
7 +help: you might be missing a type parameter
8 + |
9 +LL | struct MyStruct {
10 + | +++++++++++++++
11 +
12 +error: aborting due to 1 previous error
13 +
14 +For more information about this error, try `rustc --explain E0412`.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
1 -//@ known-bug: #131050
2 1 //@ compile-flags: --edition=2021
3 2
4 3 use std::future::Future;
5 4
6 5 fn invalid_future() -> impl Future {}
6 +//~^ ERROR `()` is not a future
7 7
8 8 fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
9 9 async { &|
@@ -21,3 +21,5 @@ where
21 21 R: Send,
22 22 {
23 23 }
24 +
25 +fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
1 +error[E0277]: `()` is not a future
2 + --> $DIR/auto-trait-contains-err.rs:5:24
3 + |
4 +LL | fn invalid_future() -> impl Future {}
5 + | ^^^^^^^^^^^ `()` is not a future
6 + |
7 + = help: the trait `Future` is not implemented for `()`
8 +
9 +error: aborting due to 1 previous error
10 +
11 +For more information about this error, try `rustc --explain E0277`.