Skip to content

Commit b6453a4

Browse files
committed
Trim more paths in obligation types
1 parent 92c1937 commit b6453a4

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -2683,7 +2683,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
26832683
// Don't print the tuple of capture types
26842684
'print: {
26852685
if !is_upvar_tys_infer_tuple {
2686-
let msg = format!("required because it appears within the type `{}`", ty);
2686+
let msg = with_forced_trimmed_paths!(format!(
2687+
"required because it appears within the type `{ty}`",
2688+
));
26872689
match ty.kind() {
26882690
ty::Adt(def, _) => match self.tcx.opt_item_ident(def.did()) {
26892691
Some(ident) => err.span_note(ident.span, &msg),
@@ -2724,7 +2726,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
27242726
let mut msg =
27252727
"required because it captures the following types: ".to_owned();
27262728
for ty in bound_tys.skip_binder() {
2727-
write!(msg, "`{}`, ", ty).unwrap();
2729+
with_forced_trimmed_paths!(write!(msg, "`{}`, ", ty).unwrap());
27282730
}
27292731
err.note(msg.trim_end_matches(", "))
27302732
}
@@ -2735,7 +2737,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
27352737
let kind = tcx.generator_kind(def_id).unwrap().descr();
27362738
err.span_note(
27372739
sp,
2738-
&format!("required because it's used within this {}", kind),
2740+
with_forced_trimmed_paths!(&format!(
2741+
"required because it's used within this {kind}",
2742+
)),
27392743
)
27402744
}
27412745
ty::Closure(def_id, _) => err.span_note(
@@ -2959,7 +2963,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
29592963
let expr_ty = with_forced_trimmed_paths!(self.ty_to_string(expr_ty));
29602964
err.span_label(
29612965
expr_span,
2962-
format!("return type was inferred to be `{expr_ty}` here"),
2966+
with_forced_trimmed_paths!(format!(
2967+
"return type was inferred to be `{expr_ty}` here",
2968+
)),
29632969
);
29642970
}
29652971
}

src/test/ui/function-pointer/unsized-ret.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LL | foo::<for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a), _>(None, (&()
2323
| required by a bound introduced by this call
2424
|
2525
= help: within `for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a)`, the trait `for<'a> Sized` is not implemented for `(dyn std::fmt::Display + 'a)`
26-
= note: required because it appears within the type `for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a)`
26+
= note: required because it appears within the type `for<'a> fn(&'a ()) -> (dyn Display + 'a)`
2727
note: required by a bound in `foo`
2828
--> $DIR/unsized-ret.rs:5:11
2929
|

src/test/ui/generator/print/generator-print-verbose-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ note: required because it's used within this generator
3535
|
3636
LL | || {
3737
| ^^
38-
note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[749a]::make_gen2::{opaque#0}), [std::sync::Arc<std::cell::RefCell<i32>>])`
38+
note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[749a]::make_gen2::{opaque#0}), [Arc<RefCell<i32>>])`
3939
--> $DIR/generator-print-verbose-1.rs:41:30
4040
|
4141
LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> {

src/test/ui/issues/issue-21763.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | foo::<HashMap<Rc<()>, Rc<()>>>();
77
= help: within `(Rc<()>, Rc<()>)`, the trait `Send` is not implemented for `Rc<()>`
88
= note: required because it appears within the type `(Rc<()>, Rc<()>)`
99
= note: required for `hashbrown::raw::RawTable<(Rc<()>, Rc<()>)>` to implement `Send`
10-
= note: required because it appears within the type `hashbrown::map::HashMap<Rc<()>, Rc<()>, RandomState>`
10+
= note: required because it appears within the type `HashMap<Rc<()>, Rc<()>, RandomState>`
1111
= note: required because it appears within the type `HashMap<Rc<()>, Rc<()>>`
1212
note: required by a bound in `foo`
1313
--> $DIR/issue-21763.rs:6:11

src/test/ui/traits/negative-impls/negated-auto-traits-error.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ LL | is_send((8, TestType));
5050
| required by a bound introduced by this call
5151
|
5252
= help: within `({integer}, dummy1c::TestType)`, the trait `Send` is not implemented for `dummy1c::TestType`
53-
= note: required because it appears within the type `({integer}, dummy1c::TestType)`
53+
= note: required because it appears within the type `({integer}, TestType)`
5454
note: required by a bound in `is_send`
5555
--> $DIR/negated-auto-traits-error.rs:16:15
5656
|
@@ -67,7 +67,7 @@ LL | is_send(Box::new(TestType));
6767
|
6868
= note: the trait bound `Unique<dummy2::TestType>: Send` is not satisfied
6969
= note: required for `Unique<dummy2::TestType>` to implement `Send`
70-
= note: required because it appears within the type `Box<dummy2::TestType>`
70+
= note: required because it appears within the type `Box<TestType>`
7171
note: required by a bound in `is_send`
7272
--> $DIR/negated-auto-traits-error.rs:16:15
7373
|
@@ -87,13 +87,13 @@ LL | is_send(Box::new(Outer2(TestType)));
8787
| required by a bound introduced by this call
8888
|
8989
= help: within `Outer2<dummy3::TestType>`, the trait `Send` is not implemented for `dummy3::TestType`
90-
note: required because it appears within the type `Outer2<dummy3::TestType>`
90+
note: required because it appears within the type `Outer2<TestType>`
9191
--> $DIR/negated-auto-traits-error.rs:12:8
9292
|
9393
LL | struct Outer2<T>(T);
9494
| ^^^^^^
9595
= note: required for `Unique<Outer2<dummy3::TestType>>` to implement `Send`
96-
= note: required because it appears within the type `Box<Outer2<dummy3::TestType>>`
96+
= note: required because it appears within the type `Box<Outer2<TestType>>`
9797
note: required by a bound in `is_send`
9898
--> $DIR/negated-auto-traits-error.rs:16:15
9999
|

0 commit comments

Comments
 (0)