Skip to content

rustc: Don't call type_error_message() with ty_err as the expected type #6427

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 1 commit into from
May 12, 2013

Conversation

catamorphism
Copy link
Contributor

r? @nikomatsakis In #6319, several people mentioned they ran into a "computing
fictitious type" ICE in trans. This turns out to be because some
of my recent changes to typeck::check::_match resulted in type errors
getting reported with ty_err as the expected type, which meant the errors
were suppressed, and typechecking incorrectly succeeded (since the errors
weren't recorded).

Changed the error messages in these cases not to use an expected type at all,
rather, printing out a string describing the type that was expected (which is
what the code originally did). The result is a bit repetitive and the
proliferation of error-reporting functions in typeck::infer is a bit annoying,
but I thought it was important to fix this now; more cleanup can happen later.

In rust-lang#6319, several people mentioned they ran into a "computing
fictitious type" ICE in trans. This turns out to be because some
of my recent changes to typeck::check::_match resulted in type errors
getting reported with ty_err as the expected type, which meant the errors
were suppressed, and typechecking incorrectly succeeded (since the errors
weren't recorded).

Changed the error messages in these cases not to use an expected type at all,
rather, printing out a string describing the type that was expected (which is
what the code originally did). The result is a bit repetitive and the
proliferation of error-reporting functions in typeck::infer is a bit annoying,
but I thought it was important to fix this now; more cleanup can happen later.
@nikomatsakis
Copy link
Contributor

I confess I don't really understand the effect of this change, but as you say I think we ought to fix it first, ask questions later. Clearly I have to read into this business of suppressing errors based on the expected type a bit more.

@catamorphism
Copy link
Contributor Author

@nikomatsakis The basic issue isn't that complicated, I just didn't explain it well. The error-reporting functions currently accept an expected type and an actual type, and suppress the error if either is ty_err. But the pattern-match-checking code is top-down, so there's no expected type to use. So in my last commit to this code, I synthesized an expected type based on the structure of the pattern and the actual types of the sub-patterns. This usually didn't work because the pattern-match-checking code would check the sub-patterns with ty_err as an expected type once an error was detected -- so then, reporting an error for the parent pattern, the expected type would be ty_err and no error would be reported. But, ty_err would get written into the type context, causing the trans error that we saw later.

Hopefully that's clearer...

bors added a commit that referenced this pull request May 12, 2013
r? @nikomatsakis In #6319, several people mentioned they ran into a "computing
fictitious type" ICE in trans. This turns out to be because some
of my recent changes to typeck::check::_match resulted in type errors
getting reported with ty_err as the expected type, which meant the errors
were suppressed, and typechecking incorrectly succeeded (since the errors
weren't recorded).

Changed the error messages in these cases not to use an expected type at all,
rather, printing out a string describing the type that was expected (which is
what the code originally did). The result is a bit repetitive and the
proliferation of error-reporting functions in typeck::infer is a bit annoying,
but I thought it was important to fix this now; more cleanup can happen later.
@bors bors closed this May 12, 2013
@bors bors merged commit cdb52c0 into rust-lang:incoming May 12, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 25, 2021
… r=flip1995

Change unnecessary_wraps to pedantic

changelog: Change unnecessary_wraps to pedantic

There seems to be enough evidence that this lint is not wanted as warn-by-default. Attempted before at rust-lang#6380. False positives at rust-lang#6721 and rust-lang#6427. Actually requested to change the category at rust-lang#6726.

Closes rust-lang#6726
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants