-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Suppress wrapper suggestion when expected and actual ty are the same adt and the variant is unresolved #145361
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
+56
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
…adt and the variant is unresolved Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
r=me when CI is green @bors delegate+ |
✌️ @xizheyin, you can now approve this pull request! If @compiler-errors told you to " |
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Aug 14, 2025
Suppress wrapper suggestion when expected and actual ty are the same adt and the variant is unresolved Fixes rust-lang#145294 I initially tried the desired suggestion in this issue, but since that suggestion occurs in the expected type, it is inappropriate to suggest for expected expressions (see other suggest methods in the same file). I believe that suppressing the incorrect suggestion is the more appropriate choice here. I opted for a slightly more general approach: when the expected type and actual type are the same ADT (e.g., both are Result in this example), we assume that code tend to compare the internal generic parameters(i.e. `Option<&str>` vs `Option<String>`, instead of `E = _` vs `Result<Option<String>>>`). When `E` is an unresolved infer type in the expected type (`_` in this example), we should not wrapp the actual type. Two commits show the difference. r? compiler
bors
added a commit
that referenced
this pull request
Aug 14, 2025
Rollup of 13 pull requests Successful merges: - #122661 (Change the desugaring of `assert!` for better error output) - #142372 (Improve `--remap-path-prefix` documentation) - #143075 (compiler: Allow `extern "interrupt" fn() -> !`) - #145005 (strip prefix of temporary file names when it exceeds filesystem name length limit) - #145065 (resolve: Introduce `RibKind::Block`) - #145120 (llvm: Accept new LLVM lifetime format) - #145189 (Weekly `cargo update`) - #145261 (Improve tracing in bootstrap) - #145266 (Reduce some queries around associated items) - #145299 (doc test: fix mpsc.rs try_send doc test) - #145331 (Make std use the edition 2024 prelude) - #145353 (bootstrap: Fix jemalloc 64K page support for aarch64 tools) - #145361 (Suppress wrapper suggestion when expected and actual ty are the same adt and the variant is unresolved) Failed merges: - #145324 (Rename and document `ONLY_HOSTS` in bootstrap) - #145372 (resolve: Miscellaneous cleanups) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
that referenced
this pull request
Aug 14, 2025
Rollup of 13 pull requests Successful merges: - #122661 (Change the desugaring of `assert!` for better error output) - #142372 (Improve `--remap-path-prefix` documentation) - #143075 (compiler: Allow `extern "interrupt" fn() -> !`) - #145005 (strip prefix of temporary file names when it exceeds filesystem name length limit) - #145065 (resolve: Introduce `RibKind::Block`) - #145120 (llvm: Accept new LLVM lifetime format) - #145189 (Weekly `cargo update`) - #145261 (Improve tracing in bootstrap) - #145266 (Reduce some queries around associated items) - #145299 (doc test: fix mpsc.rs try_send doc test) - #145331 (Make std use the edition 2024 prelude) - #145353 (bootstrap: Fix jemalloc 64K page support for aarch64 tools) - #145361 (Suppress wrapper suggestion when expected and actual ty are the same adt and the variant is unresolved) Failed merges: - #145324 (Rename and document `ONLY_HOSTS` in bootstrap) - #145372 (resolve: Miscellaneous cleanups) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
that referenced
this pull request
Aug 14, 2025
Rollup of 13 pull requests Successful merges: - #140434 (rustdoc: Allow multiple references to a single footnote) - #142372 (Improve `--remap-path-prefix` documentation) - #142741 (Fix unsoundness in some tests) - #144515 (Implement `ptr_cast_array`) - #144727 (Add tracing to resolve-related functions) - #144959 (fix(unicode-table-generator): fix duplicated unique indices) - #145179 (Avoid abbreviating "numerator" as "numer", to allow catching typo "numer" elsewhere) - #145250 (Add regression test for a former ICE involving helper attributes containing interpolated tokens) - #145266 (Reduce some queries around associated items) - #145299 (doc test: fix mpsc.rs try_send doc test) - #145323 (Port the `#[linkage]` attribute to the new attribute system) - #145361 (Suppress wrapper suggestion when expected and actual ty are the same adt and the variant is unresolved) - #145372 (resolve: Miscellaneous cleanups) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
that referenced
this pull request
Aug 14, 2025
Rollup merge of #145361 - xizheyin:145294, r=compiler-errors Suppress wrapper suggestion when expected and actual ty are the same adt and the variant is unresolved Fixes #145294 I initially tried the desired suggestion in this issue, but since that suggestion occurs in the expected type, it is inappropriate to suggest for expected expressions (see other suggest methods in the same file). I believe that suppressing the incorrect suggestion is the more appropriate choice here. I opted for a slightly more general approach: when the expected type and actual type are the same ADT (e.g., both are Result in this example), we assume that code tend to compare the internal generic parameters(i.e. `Option<&str>` vs `Option<String>`, instead of `E = _` vs `Result<Option<String>>>`). When `E` is an unresolved infer type in the expected type (`_` in this example), we should not wrapp the actual type. Two commits show the difference. r? compiler
github-actions bot
pushed a commit
to rust-lang/miri
that referenced
this pull request
Aug 15, 2025
Rollup of 13 pull requests Successful merges: - rust-lang/rust#140434 (rustdoc: Allow multiple references to a single footnote) - rust-lang/rust#142372 (Improve `--remap-path-prefix` documentation) - rust-lang/rust#142741 (Fix unsoundness in some tests) - rust-lang/rust#144515 (Implement `ptr_cast_array`) - rust-lang/rust#144727 (Add tracing to resolve-related functions) - rust-lang/rust#144959 (fix(unicode-table-generator): fix duplicated unique indices) - rust-lang/rust#145179 (Avoid abbreviating "numerator" as "numer", to allow catching typo "numer" elsewhere) - rust-lang/rust#145250 (Add regression test for a former ICE involving helper attributes containing interpolated tokens) - rust-lang/rust#145266 (Reduce some queries around associated items) - rust-lang/rust#145299 (doc test: fix mpsc.rs try_send doc test) - rust-lang/rust#145323 (Port the `#[linkage]` attribute to the new attribute system) - rust-lang/rust#145361 (Suppress wrapper suggestion when expected and actual ty are the same adt and the variant is unresolved) - rust-lang/rust#145372 (resolve: Miscellaneous cleanups) r? `@ghost` `@rustbot` modify labels: rollup
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #145294
I initially tried the desired suggestion in this issue, but since that suggestion occurs in the expected type, it is inappropriate to suggest for expected expressions (see other suggest methods in the same file). I believe that suppressing the incorrect suggestion is the more appropriate choice here.
I opted for a slightly more general approach: when the expected type and actual type are the same ADT (e.g., both are Result in this example), we assume that code tend to compare the internal generic parameters(i.e.
Option<&str>
vsOption<String>
, instead ofE = _
vsResult<Option<String>>>
). WhenE
is an unresolved infer type in the expected type (_
in this example), we should not wrapp the actual type.Two commits show the difference.
r? compiler