Split detecting unconstructible pub structs into a new lint from dead_code#128389
Split detecting unconstructible pub structs into a new lint from dead_code#128389mu001999 wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
r? @nnethercote rustbot has assigned @nnethercote. Use |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
wired failure: 🤔is there any other way to manually restart gh jobs other than push new? |
compiler/rustc_passes/src/dead.rs
Outdated
| let lint = if tcx.visibility(first_item.def_id).is_public() | ||
| && matches!(tcx.def_kind(first_item.def_id), DefKind::Struct) | ||
| { | ||
| UNCONSTRUCTIBLE_PUB_STRUCT | ||
| } else { | ||
| DEAD_CODE | ||
| }; |
There was a problem hiding this comment.
It seems very sketchy that this depends on first_item. Doesn't this suppress dead_code if a pub ADT comes first in the list?
There was a problem hiding this comment.
It seems very sketchy that this depends on
first_item. Doesn't this suppressdead_codeif a pub ADT comes first in the list?
No, we will only have one pub struct there. Because this function will only be called by warn_dead_code for struct.
This comment has been minimized.
This comment has been minimized.
|
I will assign to @compiler-errors because he has already started reviewing. |
|
This PR has the side-effect of now suppressing |
|
@compiler-errors updated and use |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #128404) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Let's reintroduce this lint later. I will leave it up to you, but this is probably best closed. @rustbot author |
#125572 detects never constructed pub structs, but introduces some regressions (#126169 and #128272).
This does not fix the regressions but just split the detection into a new lint, #127104 and #128329 try to fix them.
I don't know if it is late or not for this PR. But this could at least provide a way to help silence the lint separately for current or potential future regressions.