Skip to content

Commit

Permalink
Unrolled build for rust-lang#134798
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rust-timer authored Dec 27, 2024
2 parents e5f0d6f + f349d72 commit ee657f8
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
candidates.vec.push(AutoImplCandidate)
}
}
ty::Error(_) => {} // do not add an auto trait impl for `ty::Error` for now.
ty::Error(_) => {
candidates.vec.push(AutoImplCandidate);
}
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/consts/error-is-freeze.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 14 additions & 0 deletions tests/ui/consts/error-is-freeze.stderr
Original file line number Diff line number Diff line change
@@ -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`.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//@ known-bug: #131050
//@ compile-flags: --edition=2021

use std::future::Future;

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

fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
async { &|| async { invalid_future().await } }
Expand All @@ -21,3 +21,5 @@ where
R: Send,
{
}

fn main() {}
11 changes: 11 additions & 0 deletions tests/ui/impl-trait/auto-trait-contains-err.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit ee657f8

Please sign in to comment.