Skip to content

Commit

Permalink
Rollup merge of rust-lang#132084 - compiler-errors:param-env-with-err…
Browse files Browse the repository at this point in the history
…, r=lcnr,estebank

Consider param-env candidates even if they have errors

I added this logic in rust-lang#106309, but frankly I don't know why -- the logic was a very large hammer. It seems like recent changes to error tainting has made that no longer necessary.

Ideally we'd rework the way we handle error reporting in all of candidate assembly to be a bit more responsible; we're just suppressing candidates all willy-nilly and it leads to mysterious *other* errors cropping up, like the one that rust-lang#132082 originally wanted to fix.

**N.B.** This has the side-effect of turning a failed resolution like `where Missing: Sized` into a trivial where clause that matches all types, but also I don't think it really matters?

I'm putting this up as an alternative to rust-lang#132082, since that PR doesn't address the case when one desugars the APIT into a regular type param.

r? lcnr vibeck
  • Loading branch information
matthiaskrgr authored Oct 24, 2024
2 parents 9655858 + d8dc31f commit 0470728
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
.param_env
.caller_bounds()
.iter()
.filter(|p| !p.references_error())
.filter_map(|p| p.as_trait_clause())
// Micro-optimization: filter out predicates relating to different traits.
.filter(|p| p.def_id() == stack.obligation.predicate.def_id())
Expand Down
28 changes: 0 additions & 28 deletions tests/crashes/110630.rs

This file was deleted.

27 changes: 0 additions & 27 deletions tests/crashes/115808.rs

This file was deleted.

32 changes: 0 additions & 32 deletions tests/crashes/121052.rs

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui/async-await/in-trait/unconstrained-impl-region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ impl<'a> Actor for () {
//~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
type Message = &'a ();
async fn on_mount(self, _: impl Inbox<&'a ()>) {}
//~^ ERROR the trait bound `impl Inbox<&'a ()>: Inbox<&'a ()>` is not satisfied
}

fn main() {}
17 changes: 2 additions & 15 deletions tests/ui/async-await/in-trait/unconstrained-impl-region.stderr
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
error[E0277]: the trait bound `impl Inbox<&'a ()>: Inbox<&'a ()>` is not satisfied
--> $DIR/unconstrained-impl-region.rs:16:5
|
LL | async fn on_mount(self, _: impl Inbox<&'a ()>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Inbox<&'a ()>` is not implemented for `impl Inbox<&'a ()>`
|
note: required by a bound in `<() as Actor>::on_mount`
--> $DIR/unconstrained-impl-region.rs:16:37
|
LL | async fn on_mount(self, _: impl Inbox<&'a ()>) {}
| ^^^^^^^^^^^^^ required by this bound in `<() as Actor>::on_mount`

error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
--> $DIR/unconstrained-impl-region.rs:13:6
|
LL | impl<'a> Actor for () {
| ^^ unconstrained lifetime parameter

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

Some errors have detailed explanations: E0207, E0277.
For more information about an error, try `rustc --explain E0207`.
For more information about this error, try `rustc --explain E0207`.
10 changes: 10 additions & 0 deletions tests/ui/traits/error-reporting/apit-with-bad-path.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Ensure that we don't emit an E0270 for "`impl AsRef<Path>: AsRef<Path>` not satisfied".

fn foo(filename: impl AsRef<Path>) {
//~^ ERROR cannot find type `Path` in this scope
std::fs::write(filename, "hello").unwrap();
}

fn main() {
foo("/tmp/hello");
}
14 changes: 14 additions & 0 deletions tests/ui/traits/error-reporting/apit-with-bad-path.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0412]: cannot find type `Path` in this scope
--> $DIR/apit-with-bad-path.rs:3:29
|
LL | fn foo(filename: impl AsRef<Path>) {
| ^^^^ not found in this scope
|
help: consider importing this struct
|
LL + use std::path::Path;
|

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0412`.
10 changes: 10 additions & 0 deletions tests/ui/traits/error-reporting/where-clause-with-bad-path.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Ensure that we don't emit an E0270 for "`impl AsRef<Path>: AsRef<Path>` not satisfied".

fn foo<T: AsRef<Path>>(filename: T) {
//~^ ERROR cannot find type `Path` in this scope
std::fs::write(filename, "hello").unwrap();
}

fn main() {
foo("/tmp/hello");
}
14 changes: 14 additions & 0 deletions tests/ui/traits/error-reporting/where-clause-with-bad-path.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0412]: cannot find type `Path` in this scope
--> $DIR/where-clause-with-bad-path.rs:3:17
|
LL | fn foo<T: AsRef<Path>>(filename: T) {
| ^^^^ not found in this scope
|
help: consider importing this struct
|
LL + use std::path::Path;
|

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0412`.

0 comments on commit 0470728

Please sign in to comment.