Skip to content

Actually taint InferCtxt when a fulfillment error is emitted #126620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Only check locally for reported errors
  • Loading branch information
oli-obk committed Jun 18, 2024
commit a183989e88f2154770de1afd860bffb387c4b525
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
}

fn report_error(&self, p: impl Into<ty::GenericArg<'tcx>>) -> ErrorGuaranteed {
if let Some(guar) = self.fcx.dcx().has_errors() {
if let Some(guar) = self.fcx.tainted_by_errors() {
guar
} else {
self.fcx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ fn main() {
//~| ERROR cannot find type `T` in this scope
//~| ERROR const and type arguments are not allowed on builtin type `str`
//~| ERROR expected unit struct, unit variant or constant, found associated function `str<
//~| ERROR type annotations needed
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ error[E0533]: expected unit struct, unit variant or constant, found associated f
LL | let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a unit struct, unit variant or constant

error: aborting due to 4 previous errors
error[E0282]: type annotations needed
--> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:31
|
LL | let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes;
| ^^^^^^^^^^^^^^^^^^
|
help: consider giving this pattern a type
|
LL | let str::<{fn str() { let str::T>>::as_bytes: /* Type */; }}, T>::as_bytes;
| ++++++++++++

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0109, E0412, E0533.
Some errors have detailed explanations: E0109, E0282, E0412, E0533.
For more information about an error, try `rustc --explain E0109`.
2 changes: 2 additions & 0 deletions tests/ui/wf/conflicting-impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ struct Ty;
impl TryFrom<Ty> for u8 {
type Error = Ty;
fn try_from(_: Ty) -> Result<Self, Self::Error> {
//~^ ERROR type annotations needed
loop {}
}
}
Expand All @@ -13,6 +14,7 @@ impl TryFrom<Ty> for u8 {
//~^ ERROR conflicting implementations of trait
type Error = Ty;
fn try_from(_: Ty) -> Result<Self, Self::Error> {
//~^ ERROR type annotations needed
loop {}
}
}
Expand Down
27 changes: 24 additions & 3 deletions tests/ui/wf/conflicting-impls.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
error[E0119]: conflicting implementations of trait `TryFrom<Ty>` for type `u8`
--> $DIR/conflicting-impls.rs:12:1
--> $DIR/conflicting-impls.rs:13:1
|
LL | impl TryFrom<Ty> for u8 {
| ----------------------- first implementation here
...
LL | impl TryFrom<Ty> for u8 {
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8`

error: aborting due to 1 previous error
error[E0282]: type annotations needed
--> $DIR/conflicting-impls.rs:7:53
|
LL | fn try_from(_: Ty) -> Result<Self, Self::Error> {
| _____________________________________________________^
LL | |
LL | | loop {}
LL | | }
| |_____^ cannot infer type for enum `Result<u8, _>`

error[E0282]: type annotations needed
--> $DIR/conflicting-impls.rs:16:53
|
LL | fn try_from(_: Ty) -> Result<Self, Self::Error> {
| _____________________________________________________^
LL | |
LL | | loop {}
LL | | }
| |_____^ cannot infer type for enum `Result<u8, _>`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0119`.
Some errors have detailed explanations: E0119, E0282.
For more information about an error, try `rustc --explain E0119`.