-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Avoid unwrap diag.code directly in note_and_explain_type_err #125774
Conversation
rustbot has assigned @petrochenkov. Use |
r? types |
compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe this is the correct fix for the issue.
I think the correct fix here would be to just stop unwrapping here and more gracefully handle the case where the diagnostic has no error code:
Though it would be most thorough to first explain why we're calling the |
@compiler-errors how about the new change? I added a boolean to check the type is used as the type of a constant, which is forbidden. |
This still seems like not the correct approach. What is wrong with the approach that I suggested in #125774 (comment)? |
@compiler-errors I tried this when I first touched this issue, it works indeed. But after skimming through the call logic, I just think we shouldn't call
But I agree that current approach is enough. |
This comment has been minimized.
This comment has been minimized.
@bors r+ rollup |
…iaskrgr Rollup of 4 pull requests Successful merges: - rust-lang#125635 (Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup) - rust-lang#125774 (Avoid unwrap diag.code directly in note_and_explain_type_err) - rust-lang#125786 (Fold item bounds before proving them in `check_type_bounds` in new solver) - rust-lang#125790 (Don't recompute `tail` in `lower_stmts`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#125774 - mu001999-contrib:fix/125757, r=compiler-errors Avoid unwrap diag.code directly in note_and_explain_type_err <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r? <reviewer name> --> Fixes rust-lang#125757
Fixes #125757