Skip to content
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

Fix adt_const_params leaking {type error} in error msg #131038

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

onkoe
Copy link
Contributor

@onkoe onkoe commented Sep 29, 2024

Fixes the confusing diagnostic described in #118179. (users would see {type error} in some situations, which is pretty weird)

Fixes #118179.

adt_const_params tracking issue: #95174

@rustbot
Copy link
Collaborator

rustbot commented Sep 29, 2024

r? @wesleywiser

rustbot has assigned @wesleywiser.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 29, 2024
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label Sep 29, 2024
Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also squash this into one commit.

compiler/rustc_middle/src/ty/sty.rs Outdated Show resolved Hide resolved
compiler/rustc_hir_analysis/src/check/wfcheck.rs Outdated Show resolved Hide resolved
compiler/rustc_hir_analysis/src/check/wfcheck.rs Outdated Show resolved Hide resolved
Comment on lines 966 to 968
if ty.references_error() {
return Ok(());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this should just return Err(ErrorGuaranteed) here, rather than Ok(()), I think.

You can use the alternative error_reported function which is like references_error, but returns a Result<(), ErrorGuaranteed> for ease of ? operator:

Suggested change
if ty.references_error() {
return Ok(());
}
ty.error_reported()?;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense! I guess it kinda depends on if we're checking if the parameters are well-formed, or if it's all well-formed... while checking the const parameters.

Tests don't seem to mind either way, and there are no docs for any of these methods, so I'll go with this. 😄

(by the way, is there any reason behind the lack of docs on most rustc modules/items? would well-researched docs be appreciated?)

avoid `{type error}` being leaked in user-facing messages,
particularly when using the `adt_const_params` feature
@onkoe onkoe force-pushed the fix/adt_const_params_leak_118179 branch from 081a8a8 to c5598d6 Compare September 30, 2024 04:41
@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 30, 2024

📌 Commit c5598d6 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 30, 2024
};

diag.note("the only supported types are integers, `bool` and `char`");
diag.note("the only supported types are integers, `bool`, and `char`");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comma before and looks wrong to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's called the oxford comma.

Copy link
Contributor

@klensy klensy Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, okay, looking at *.stderr there used both cases with and w\o comma with enumerations.

One more wtf styling case. Probably exist somewhere in rust style guide for errors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found only 2 mentions: rust-lang/rustc-dev-guide#1087 (comment), rust-lang/rustc-dev-guide#1139 (comment); should be added to the guide?

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 30, 2024
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#131023 (Copy correct path to clipboard for modules/keywords/primitives)
 - rust-lang#131035 (Preserve brackets around if-lets and skip while-lets)
 - rust-lang#131038 (Fix `adt_const_params` leaking `{type error}` in error msg)
 - rust-lang#131053 (Improve `--print=check-cfg` documentation)
 - rust-lang#131056 (enable compiler fingerprint logs in verbose mode)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5df1123 into rust-lang:master Sep 30, 2024
6 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 30, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 30, 2024
Rollup merge of rust-lang#131038 - onkoe:fix/adt_const_params_leak_118179, r=compiler-errors

Fix `adt_const_params` leaking `{type error}` in error msg

Fixes the confusing diagnostic described in rust-lang#118179. (users would see `{type error}` in some situations, which is pretty weird)

`adt_const_params` tracking issue: rust-lang#95174
onkoe pushed a commit to onkoe/rustc-dev-guide that referenced this pull request Oct 8, 2024
we encountered this in rust-lang/rust#131038

kinda felt like an unspoken rule so here's a more concrete
clarification.
tshepang pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Nov 5, 2024
we encountered this in rust-lang/rust#131038

kinda felt like an unspoken rule so here's a more concrete
clarification.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

adt_const_params feature gate error leaks {type error} (TyKind::Error)
7 participants