Rollup merge of #140614 - yuk1ty:fix-invalid-module-name-visibility, r=davidtwco

Correct warning message in restricted visibility

Fixes #131220
This commit is contained in:
Guillaume Gomez
2025-05-07 18:19:05 +02:00
committed by GitHub
4 changed files with 57 additions and 2 deletions

View File

@@ -309,7 +309,10 @@ impl Visibility {
} else if restricted_id == tcx.parent_module_from_def_id(def_id).to_local_def_id() {
"pub(self)".to_string()
} else {
format!("pub({})", tcx.item_name(restricted_id.to_def_id()))
format!(
"pub(in crate{})",
tcx.def_path(restricted_id.to_def_id()).to_string_no_crate_verbose()
)
}
}
ty::Visibility::Public => "pub".to_string(),