Skip to content

Commit 566cdab

Browse files
committed
Clarify value_path_str_with_args.
The use of `print_value_path` means the value namespace is always used and the `guess_def_namespace` call is unnecessary. This commit removes the `guess_def_namespace` call and hard-codes `ValueNS`. It also changes the `print_value_path` to `print_def_path` for consistency with `def_path_str_with_args`.
1 parent 0f35336 commit 566cdab

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,8 +2131,6 @@ impl<'a, 'tcx> FmtPrinter<'a, 'tcx> {
21312131
}
21322132
}
21332133

2134-
// HACK(eddyb) get rid of `def_path_str` and/or pass `Namespace` explicitly always
2135-
// (but also some things just print a `DefId` generally so maybe we need this?)
21362134
fn guess_def_namespace(tcx: TyCtxt<'_>, def_id: DefId) -> Namespace {
21372135
match tcx.def_key(def_id).disambiguated_data.data {
21382136
DefPathData::TypeNs(..) | DefPathData::CrateRoot | DefPathData::OpaqueTy => {
@@ -2157,6 +2155,7 @@ impl<'t> TyCtxt<'t> {
21572155
self.def_path_str_with_args(def_id, &[])
21582156
}
21592157

2158+
/// For this one we determine the appropriate namespace for the `def_id`.
21602159
pub fn def_path_str_with_args(
21612160
self,
21622161
def_id: impl IntoQueryParam<DefId>,
@@ -2169,16 +2168,17 @@ impl<'t> TyCtxt<'t> {
21692168
FmtPrinter::print_string(self, ns, |p| p.print_def_path(def_id, args)).unwrap()
21702169
}
21712170

2171+
/// For this one we always use value namespace.
21722172
pub fn value_path_str_with_args(
21732173
self,
21742174
def_id: impl IntoQueryParam<DefId>,
21752175
args: &'t [GenericArg<'t>],
21762176
) -> String {
21772177
let def_id = def_id.into_query_param();
2178-
let ns = guess_def_namespace(self, def_id);
2178+
let ns = Namespace::ValueNS;
21792179
debug!("value_path_str: def_id={:?}, ns={:?}", def_id, ns);
21802180

2181-
FmtPrinter::print_string(self, ns, |p| p.print_value_path(def_id, args)).unwrap()
2181+
FmtPrinter::print_string(self, ns, |p| p.print_def_path(def_id, args)).unwrap()
21822182
}
21832183
}
21842184

0 commit comments

Comments
 (0)