Skip to content

Commit b84e2b7

Browse files
Put the dots back
1 parent 3de0a7c commit b84e2b7

File tree

5 files changed

+114
-8
lines changed

5 files changed

+114
-8
lines changed

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -1214,11 +1214,14 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
12141214
&& let ty::Alias(_, alias_ty) =
12151215
self.tcx().fn_sig(fn_def_id).skip_binder().output().skip_binder().kind()
12161216
&& alias_ty.def_id == def_id
1217+
&& let generics = self.tcx().generics_of(fn_def_id)
1218+
// FIXME(return_type_notation): We only support lifetime params for now.
1219+
&& generics.own_params.iter().all(|param| matches!(param.kind, ty::GenericParamDefKind::Lifetime))
12171220
{
1218-
let num_args = self.tcx().generics_of(fn_def_id).count();
1221+
let num_args = generics.count();
12191222
write!(self, " {{ ")?;
12201223
self.print_def_path(fn_def_id, &args[..num_args])?;
1221-
write!(self, "() }}")?;
1224+
write!(self, "(..) }}")?;
12221225
}
12231226

12241227
Ok(())

tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ error: future cannot be sent between threads safely
1313
LL | is_send(foo::<T>());
1414
| ^^^^^^^^^^ future returned by `foo` is not `Send`
1515
|
16-
= help: within `impl Future<Output = Result<(), ()>>`, the trait `Send` is not implemented for `impl Future<Output = Result<(), ()>> { <T as Foo>::method() }`, which is required by `impl Future<Output = Result<(), ()>>: Send`
16+
= help: within `impl Future<Output = Result<(), ()>>`, the trait `Send` is not implemented for `impl Future<Output = Result<(), ()>> { <T as Foo>::method(..) }`, which is required by `impl Future<Output = Result<(), ()>>: Send`
1717
note: future is not `Send` as it awaits another future which is not `Send`
1818
--> $DIR/basic.rs:13:5
1919
|
2020
LL | T::method().await?;
21-
| ^^^^^^^^^^^ await occurs here on type `impl Future<Output = Result<(), ()>> { <T as Foo>::method() }`, which is not `Send`
21+
| ^^^^^^^^^^^ await occurs here on type `impl Future<Output = Result<(), ()>> { <T as Foo>::method(..) }`, which is not `Send`
2222
note: required by a bound in `is_send`
2323
--> $DIR/basic.rs:17:20
2424
|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#![feature(return_type_notation)]
2+
//~^ WARN the feature `return_type_notation` is incomplete
3+
4+
trait Trait {}
5+
fn needs_trait(_: impl Trait) {}
6+
7+
trait Assoc {
8+
fn method() -> impl Sized;
9+
fn method_with_lt() -> impl Sized;
10+
fn method_with_ty<T>() -> impl Sized;
11+
fn method_with_ct<const N: usize>() -> impl Sized;
12+
}
13+
14+
fn foo<T: Assoc>(t: T) {
15+
needs_trait(T::method());
16+
//~^ ERROR the trait bound
17+
needs_trait(T::method_with_lt());
18+
//~^ ERROR the trait bound
19+
needs_trait(T::method_with_ty());
20+
//~^ ERROR the trait bound
21+
needs_trait(T::method_with_ct());
22+
//~^ ERROR the trait bound
23+
}
24+
25+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/display.rs:1:12
3+
|
4+
LL | #![feature(return_type_notation)]
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error[E0277]: the trait bound `impl Sized { <T as Assoc>::method(..) }: Trait` is not satisfied
11+
--> $DIR/display.rs:15:17
12+
|
13+
LL | needs_trait(T::method());
14+
| ----------- ^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Sized { <T as Assoc>::method(..) }`
15+
| |
16+
| required by a bound introduced by this call
17+
|
18+
note: required by a bound in `needs_trait`
19+
--> $DIR/display.rs:5:24
20+
|
21+
LL | fn needs_trait(_: impl Trait) {}
22+
| ^^^^^ required by this bound in `needs_trait`
23+
24+
error[E0277]: the trait bound `impl Sized { <T as Assoc>::method_with_lt(..) }: Trait` is not satisfied
25+
--> $DIR/display.rs:17:17
26+
|
27+
LL | needs_trait(T::method_with_lt());
28+
| ----------- ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Sized { <T as Assoc>::method_with_lt(..) }`
29+
| |
30+
| required by a bound introduced by this call
31+
|
32+
note: required by a bound in `needs_trait`
33+
--> $DIR/display.rs:5:24
34+
|
35+
LL | fn needs_trait(_: impl Trait) {}
36+
| ^^^^^ required by this bound in `needs_trait`
37+
38+
error[E0277]: the trait bound `impl Sized: Trait` is not satisfied
39+
--> $DIR/display.rs:19:17
40+
|
41+
LL | needs_trait(T::method_with_ty());
42+
| ----------- ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Sized`
43+
| |
44+
| required by a bound introduced by this call
45+
|
46+
help: this trait has no implementations, consider adding one
47+
--> $DIR/display.rs:4:1
48+
|
49+
LL | trait Trait {}
50+
| ^^^^^^^^^^^
51+
note: required by a bound in `needs_trait`
52+
--> $DIR/display.rs:5:24
53+
|
54+
LL | fn needs_trait(_: impl Trait) {}
55+
| ^^^^^ required by this bound in `needs_trait`
56+
57+
error[E0277]: the trait bound `impl Sized: Trait` is not satisfied
58+
--> $DIR/display.rs:21:17
59+
|
60+
LL | needs_trait(T::method_with_ct());
61+
| ----------- ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Sized`
62+
| |
63+
| required by a bound introduced by this call
64+
|
65+
help: this trait has no implementations, consider adding one
66+
--> $DIR/display.rs:4:1
67+
|
68+
LL | trait Trait {}
69+
| ^^^^^^^^^^^
70+
note: required by a bound in `needs_trait`
71+
--> $DIR/display.rs:5:24
72+
|
73+
LL | fn needs_trait(_: impl Trait) {}
74+
| ^^^^^ required by this bound in `needs_trait`
75+
76+
error: aborting due to 4 previous errors; 1 warning emitted
77+
78+
For more information about this error, try `rustc --explain E0277`.

tests/ui/async-await/return-type-notation/issue-110963-early.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ LL | | }
1818
LL | | });
1919
| |______^ implementation of `Send` is not general enough
2020
|
21-
= note: `Send` would have to be implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'0>() }`, for any two lifetimes `'0` and `'1`...
22-
= note: ...but `Send` is actually implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'2>() }`, for some specific lifetime `'2`
21+
= note: `Send` would have to be implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'0>(..) }`, for any two lifetimes `'0` and `'1`...
22+
= note: ...but `Send` is actually implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'2>(..) }`, for some specific lifetime `'2`
2323

2424
error: implementation of `Send` is not general enough
2525
--> $DIR/issue-110963-early.rs:14:5
@@ -32,8 +32,8 @@ LL | | }
3232
LL | | });
3333
| |______^ implementation of `Send` is not general enough
3434
|
35-
= note: `Send` would have to be implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'0>() }`, for any two lifetimes `'0` and `'1`...
36-
= note: ...but `Send` is actually implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'2>() }`, for some specific lifetime `'2`
35+
= note: `Send` would have to be implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'0>(..) }`, for any two lifetimes `'0` and `'1`...
36+
= note: ...but `Send` is actually implemented for the type `impl Future<Output = bool> { <HC as HealthCheck>::check<'2>(..) }`, for some specific lifetime `'2`
3737
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3838

3939
error: aborting due to 2 previous errors; 1 warning emitted

0 commit comments

Comments
 (0)