Skip to content

Commit ee657f8

Browse files
authored
Unrolled build for rust-lang#134798
Rollup merge of rust-lang#134798 - compiler-errors:err-auto, r=jackh726 Make `ty::Error` implement all auto traits I have no idea what's up with the crashes test I fixed--I really don't want to look into it since it has to do something with borrowck and multiple layers of opaques. I think the underlying idea of allowing error types to implement all auto traits is justified though. Fixes rust-lang#134796 Fixes rust-lang#131050 r? lcnr
2 parents e5f0d6f + f349d72 commit ee657f8

File tree

5 files changed

+45
-2
lines changed

5 files changed

+45
-2
lines changed

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
819819
candidates.vec.push(AutoImplCandidate)
820820
}
821821
}
822-
ty::Error(_) => {} // do not add an auto trait impl for `ty::Error` for now.
822+
ty::Error(_) => {
823+
candidates.vec.push(AutoImplCandidate);
824+
}
823825
}
824826
}
825827
}

tests/ui/consts/error-is-freeze.rs

+14
Original file line numberDiff line numberDiff 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() {}
+14
Original file line numberDiff line numberDiff 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<UndefinedType>,
5+
| ^^^^^^^^^^^^^ not found in this scope
6+
|
7+
help: you might be missing a type parameter
8+
|
9+
LL | struct MyStruct<UndefinedType> {
10+
| +++++++++++++++
11+
12+
error: aborting due to 1 previous error
13+
14+
For more information about this error, try `rustc --explain E0412`.

tests/crashes/131050.rs tests/ui/impl-trait/auto-trait-contains-err.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
//@ known-bug: #131050
21
//@ compile-flags: --edition=2021
32

43
use std::future::Future;
54

65
fn invalid_future() -> impl Future {}
6+
//~^ ERROR `()` is not a future
77

88
fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
99
async { &|| async { invalid_future().await } }
@@ -21,3 +21,5 @@ where
2121
R: Send,
2222
{
2323
}
24+
25+
fn main() {}
Original file line numberDiff line numberDiff 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`.

0 commit comments

Comments
 (0)