Skip to content

Commit ecf2f68

Browse files
committed
Tweak output of to_pretty_impl_header involving only anon lifetimes
Do not print `impl<> Foo for &Bar`.
1 parent c587fd4 commit ecf2f68

File tree

3 files changed

+18
-24
lines changed

3 files changed

+18
-24
lines changed

compiler/rustc_trait_selection/src/traits/specialize/mod.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -472,17 +472,11 @@ pub(crate) fn to_pretty_impl_header(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Opti
472472
let mut types_without_default_bounds = FxIndexSet::default();
473473
let sized_trait = tcx.lang_items().sized_trait();
474474

475-
if !args.is_empty() {
475+
let arg_names = args.iter().map(|k| k.to_string()).filter(|k| k != "'_").collect::<Vec<_>>();
476+
if !arg_names.is_empty() {
476477
types_without_default_bounds.extend(args.types());
477478
w.push('<');
478-
w.push_str(
479-
&args
480-
.iter()
481-
.map(|k| k.to_string())
482-
.filter(|k| k != "'_")
483-
.collect::<Vec<_>>()
484-
.join(", "),
485-
);
479+
w.push_str(&arg_names.join(", "));
486480
w.push('>');
487481
}
488482

tests/ui/inference/issue-72616.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LL | if String::from("a") == "a".try_into().unwrap() {}
2323
| ^^^^^^^^
2424
|
2525
= note: multiple `impl`s satisfying `_: TryFrom<&str>` found in the following crates: `core`, `std`:
26-
- impl<> TryFrom<&str> for std::sys_common::net::LookupHost;
26+
- impl TryFrom<&str> for std::sys_common::net::LookupHost;
2727
- impl<T, U> TryFrom<U> for T
2828
where U: Into<T>;
2929
= note: required for `&str` to implement `TryInto<_>`

tests/ui/inference/issue-72690.stderr

+14-14
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ LL | String::from("x".as_ref());
55
| ^^^^^^ cannot infer type for reference `&_`
66
|
77
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
8-
- impl<> From<&String> for String;
9-
- impl<> From<&str> for String;
8+
- impl From<&String> for String;
9+
- impl From<&str> for String;
1010

1111
error[E0283]: type annotations needed
1212
--> $DIR/issue-72690.rs:7:22
@@ -74,8 +74,8 @@ LL | String::from("x".as_ref());
7474
| ^^^^^^ cannot infer type for reference `&_`
7575
|
7676
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
77-
- impl<> From<&String> for String;
78-
- impl<> From<&str> for String;
77+
- impl From<&String> for String;
78+
- impl From<&str> for String;
7979

8080
error[E0283]: type annotations needed
8181
--> $DIR/issue-72690.rs:21:22
@@ -100,8 +100,8 @@ LL | String::from("x".as_ref());
100100
| ^^^^^^ cannot infer type for reference `&_`
101101
|
102102
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
103-
- impl<> From<&String> for String;
104-
- impl<> From<&str> for String;
103+
- impl From<&String> for String;
104+
- impl From<&str> for String;
105105

106106
error[E0283]: type annotations needed
107107
--> $DIR/issue-72690.rs:28:22
@@ -126,8 +126,8 @@ LL | String::from("x".as_ref());
126126
| ^^^^^^ cannot infer type for reference `&_`
127127
|
128128
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
129-
- impl<> From<&String> for String;
130-
- impl<> From<&str> for String;
129+
- impl From<&String> for String;
130+
- impl From<&str> for String;
131131

132132
error[E0283]: type annotations needed
133133
--> $DIR/issue-72690.rs:37:22
@@ -152,8 +152,8 @@ LL | String::from("x".as_ref());
152152
| ^^^^^^ cannot infer type for reference `&_`
153153
|
154154
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
155-
- impl<> From<&String> for String;
156-
- impl<> From<&str> for String;
155+
- impl From<&String> for String;
156+
- impl From<&str> for String;
157157

158158
error[E0283]: type annotations needed
159159
--> $DIR/issue-72690.rs:46:22
@@ -178,8 +178,8 @@ LL | String::from("x".as_ref());
178178
| ^^^^^^ cannot infer type for reference `&_`
179179
|
180180
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
181-
- impl<> From<&String> for String;
182-
- impl<> From<&str> for String;
181+
- impl From<&String> for String;
182+
- impl From<&str> for String;
183183

184184
error[E0283]: type annotations needed
185185
--> $DIR/issue-72690.rs:53:22
@@ -204,8 +204,8 @@ LL | String::from("x".as_ref());
204204
| ^^^^^^ cannot infer type for reference `&_`
205205
|
206206
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
207-
- impl<> From<&String> for String;
208-
- impl<> From<&str> for String;
207+
- impl From<&String> for String;
208+
- impl From<&str> for String;
209209

210210
error[E0283]: type annotations needed
211211
--> $DIR/issue-72690.rs:62:22

0 commit comments

Comments
 (0)