Skip to content

Commit b400bde

Browse files
committed
Shorten type in note
1 parent df2a35e commit b400bde

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

compiler/rustc_hir_analysis/src/collect/type_of.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use rustc_hir::intravisit;
55
use rustc_hir::intravisit::Visitor;
66
use rustc_hir::{HirId, Node};
77
use rustc_middle::hir::nested_filter;
8+
use rustc_middle::ty::print::with_forced_trimmed_paths;
89
use rustc_middle::ty::subst::InternalSubsts;
910
use rustc_middle::ty::util::IntTypeExt;
1011
use rustc_middle::ty::{self, DefIdTree, Ty, TyCtxt, TypeFolder, TypeSuperFoldable, TypeVisitable};
@@ -907,10 +908,10 @@ fn infer_placeholder_type<'a>(
907908
Applicability::MachineApplicable,
908909
);
909910
} else {
910-
err.span_note(
911+
with_forced_trimmed_paths!(err.span_note(
911912
tcx.hir().body(body_id).value.span,
912-
&format!("however, the inferred type `{}` cannot be named", ty),
913-
);
913+
&format!("however, the inferred type `{ty}` cannot be named"),
914+
));
914915
}
915916
}
916917

@@ -931,10 +932,10 @@ fn infer_placeholder_type<'a>(
931932
Applicability::MaybeIncorrect,
932933
);
933934
} else {
934-
diag.span_note(
935+
with_forced_trimmed_paths!(diag.span_note(
935936
tcx.hir().body(body_id).value.span,
936-
&format!("however, the inferred type `{}` cannot be named", ty),
937-
);
937+
&format!("however, the inferred type `{ty}` cannot be named"),
938+
));
938939
}
939940
}
940941

src/test/ui/suggestions/unnamable-types.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
1919
LL | const C: _ = || 42;
2020
| ^ not allowed in type signatures
2121
|
22-
note: however, the inferred type `[closure@$DIR/unnamable-types.rs:17:14: 17:16]` cannot be named
22+
note: however, the inferred type `[[email protected]:17:14]` cannot be named
2323
--> $DIR/unnamable-types.rs:17:14
2424
|
2525
LL | const C: _ = || 42;
@@ -31,7 +31,7 @@ error: missing type for `const` item
3131
LL | const D = S { t: { let i = 0; move || -> i32 { i } } };
3232
| ^
3333
|
34-
note: however, the inferred type `S<[closure@$DIR/unnamable-types.rs:23:31: 23:45]>` cannot be named
34+
note: however, the inferred type `S<[[email protected]:23:31]>` cannot be named
3535
--> $DIR/unnamable-types.rs:23:11
3636
|
3737
LL | const D = S { t: { let i = 0; move || -> i32 { i } } };

src/test/ui/typeck/typeck_type_placeholder_item.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
443443
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
444444
| ^ not allowed in type signatures
445445
|
446-
note: however, the inferred type `Map<Filter<std::ops::Range<i32>, [closure@$DIR/typeck_type_placeholder_item.rs:229:29: 229:32]>, [closure@$DIR/typeck_type_placeholder_item.rs:229:49: 229:52]>` cannot be named
446+
note: however, the inferred type `Map<Filter<Range<i32>, [closure@typeck_type_placeholder_item.rs:229:29]>, [closure@typeck_type_placeholder_item.rs:229:49]>` cannot be named
447447
--> $DIR/typeck_type_placeholder_item.rs:229:14
448448
|
449449
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);

0 commit comments

Comments
 (0)