Skip to content

Commit 6397fa3

Browse files
committed
Revert rendering of short ty::Instance to use Value NS
1 parent 017dc15 commit 6397fa3

34 files changed

+51
-39
lines changed

compiler/rustc_middle/src/ty/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxIndexMap;
77
use rustc_errors::{
88
Applicability, Diag, DiagArgValue, IntoDiagArg, into_diag_arg_using_display, listify, pluralize,
99
};
10-
use rustc_hir::def::DefKind;
10+
use rustc_hir::def::{DefKind, Namespace};
1111
use rustc_hir::def_id::DefId;
1212
use rustc_hir::{self as hir, AmbigArg, LangItem, PredicateOrigin, WherePredicateKind};
1313
use rustc_span::{BytePos, Span};
@@ -31,7 +31,7 @@ impl IntoDiagArg for Ty<'_> {
3131
impl IntoDiagArg for Instance<'_> {
3232
fn into_diag_arg(self, path: &mut Option<std::path::PathBuf>) -> rustc_errors::DiagArgValue {
3333
ty::tls::with(|tcx| {
34-
let instance = tcx.short_string(self, path);
34+
let instance = tcx.short_string_namespace(self, path, Namespace::ValueNS);
3535
rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(instance))
3636
})
3737
}

compiler/rustc_middle/src/ty/error.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,27 @@ impl<'tcx> TyCtxt<'tcx> {
248248
short
249249
}
250250

251+
pub fn short_string<T>(self, p: T, path: &mut Option<PathBuf>) -> String
252+
where
253+
T: Copy + Hash + for<'a, 'b> Lift<TyCtxt<'b>, Lifted: Print<'b, FmtPrinter<'a, 'b>>>,
254+
{
255+
self.short_string_namespace(p, path, hir::def::Namespace::TypeNS)
256+
}
257+
251258
/// When calling this after a `Diag` is constructed, the preferred way of doing so is
252259
/// `tcx.short_string(ty, diag.long_ty_path())`. The diagnostic itself is the one that keeps
253260
/// the existence of a "long type" anywhere in the diagnostic, so the note telling the user
254261
/// where we wrote the file to is only printed once.
255-
pub fn short_string<T>(self, p: T, path: &mut Option<PathBuf>) -> String
262+
pub fn short_string_namespace<T>(
263+
self,
264+
p: T,
265+
path: &mut Option<PathBuf>,
266+
namespace: hir::def::Namespace,
267+
) -> String
256268
where
257269
T: Copy + Hash + for<'a, 'b> Lift<TyCtxt<'b>, Lifted: Print<'b, FmtPrinter<'a, 'b>>>,
258270
{
259-
let regular = FmtPrinter::print_string(self, hir::def::Namespace::TypeNS, |cx| {
271+
let regular = FmtPrinter::print_string(self, namespace, |cx| {
260272
self.lift(p).expect("could not lift for printing").print(cx)
261273
})
262274
.expect("could not write to `String`");

tests/ui/async-await/async-closures/post-mono-higher-ranked-hang-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: reached the recursion limit while instantiating `recur<{async closure@$DIR/post-mono-higher-ranked-hang-2.rs:13:24: 13:32}>`
1+
error: reached the recursion limit while instantiating `recur::<{async closure@$DIR/post-mono-higher-ranked-hang-2.rs:13:24: 13:32}>`
22
--> $DIR/post-mono-higher-ranked-hang-2.rs:13:17
33
|
44
LL | let _ = recur(&async || {

tests/ui/async-await/async-closures/post-mono-higher-ranked-hang.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: reached the recursion limit while instantiating `ToChain<'_, '_>::perm_pairs<{async closure@$DIR/post-mono-higher-ranked-hang.rs:43:45: 43:67}>`
1+
error: reached the recursion limit while instantiating `ToChain::<'_, '_>::perm_pairs::<{async closure@$DIR/post-mono-higher-ranked-hang.rs:43:45: 43:67}>`
22
--> $DIR/post-mono-higher-ranked-hang.rs:43:21
33
|
44
LL | / self.perm_pairs(l, &mut async move |left_pair| {

tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: erroneous constant encountered
1010
LL | let _ = PrintName::<T>::VOID;
1111
| ^^^^^^^^^^^^^^^^^^^^
1212

13-
note: the above error was encountered while instantiating `fn f<()>`
13+
note: the above error was encountered while instantiating `fn f::<()>`
1414
--> $DIR/index-out-of-bounds-never-type.rs:20:5
1515
|
1616
LL | f::<()>();

tests/ui/consts/const-eval/issue-50814-2.normal.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ LL | &<A<T> as Foo<T>>::BAR
2424
|
2525
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2626

27-
note: the above error was encountered while instantiating `fn foo<()>`
27+
note: the above error was encountered while instantiating `fn foo::<()>`
2828
--> $DIR/issue-50814-2.rs:33:22
2929
|
3030
LL | println!("{:x}", foo::<()>() as *const usize as usize);

tests/ui/consts/const-eval/issue-50814.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ LL | &Sum::<U8, U8>::MAX
4040
|
4141
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
4242

43-
note: the above error was encountered while instantiating `fn foo<i32>`
43+
note: the above error was encountered while instantiating `fn foo::<i32>`
4444
--> $DIR/issue-50814.rs:27:5
4545
|
4646
LL | foo(0);

tests/ui/consts/const-eval/issue-85155.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LL | static_assert_imm1!(IMM1);
1212
|
1313
= note: this note originates in the macro `static_assert_imm1` (in Nightly builds, run with -Z macro-backtrace for more info)
1414

15-
note: the above error was encountered while instantiating `fn stdarch_intrinsic<2>`
15+
note: the above error was encountered while instantiating `fn stdarch_intrinsic::<2>`
1616
--> $DIR/issue-85155.rs:19:5
1717
|
1818
LL | post_monomorphization_error::stdarch_intrinsic::<2>();

tests/ui/consts/mono-reachable-invalid-const.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ LL | let val = Self::ASSERT;
1818
|
1919
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2020

21-
note: the above error was encountered while instantiating `fn Bar<0>::assert`
21+
note: the above error was encountered while instantiating `fn Bar::<0>::assert`
2222
--> $DIR/mono-reachable-invalid-const.rs:21:5
2323
|
2424
LL | Bar::<0>::assert();

tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: erroneous constant encountered
1010
LL | let _ = Fail::<T>::C;
1111
| ^^^^^^^^^^^^
1212

13-
note: the above error was encountered while instantiating `fn called<i32>`
13+
note: the above error was encountered while instantiating `fn called::<i32>`
1414
--> $DIR/collect-in-called-fn.rs:24:5
1515
|
1616
LL | called::<i32>();

0 commit comments

Comments
 (0)