Rollup merge of #126276 - mu001999-contrib:dead/enhance, r=fee1-dead
Detect pub structs never constructed even though they impl pub trait with assoc constants Extend dead code analysis to impl items of pub assoc constants. <!-- 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> -->
This commit is contained in:
commit
306501044e
3 changed files with 80 additions and 2 deletions
|
@ -472,7 +472,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
|
|||
&& let ItemKind::Impl(impl_ref) =
|
||||
self.tcx.hir().expect_item(local_impl_id).kind
|
||||
{
|
||||
if matches!(trait_item.kind, hir::TraitItemKind::Fn(..))
|
||||
if !matches!(trait_item.kind, hir::TraitItemKind::Type(..))
|
||||
&& !ty_ref_to_pub_struct(self.tcx, impl_ref.self_ty)
|
||||
.ty_and_all_fields_are_public
|
||||
{
|
||||
|
@ -802,7 +802,7 @@ fn check_item<'tcx>(
|
|||
// And we access the Map here to get HirId from LocalDefId
|
||||
for local_def_id in local_def_ids {
|
||||
// check the function may construct Self
|
||||
let mut may_construct_self = true;
|
||||
let mut may_construct_self = false;
|
||||
if let Some(fn_sig) =
|
||||
tcx.hir().fn_sig_by_hir_id(tcx.local_def_id_to_hir_id(local_def_id))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue