Skip to content

Commit 748476d

Browse files
Print the path of an RPITIT in RTN
1 parent b0d4553 commit 748476d

File tree

5 files changed

+75
-2
lines changed

5 files changed

+75
-2
lines changed

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

+11
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,17 @@ pub trait PrettyPrinter<'tcx>:
11231123
}
11241124
}
11251125

1126+
if self.tcx().features().return_type_notation
1127+
&& let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, .. }) = self.tcx().opt_rpitit_info(def_id)
1128+
&& let ty::Alias(_, alias_ty) = self.tcx().fn_sig(fn_def_id).skip_binder().output().skip_binder().kind()
1129+
&& alias_ty.def_id == def_id
1130+
{
1131+
let num_args = self.tcx().generics_of(fn_def_id).count();
1132+
write!(self, " {{ ")?;
1133+
self = self.print_def_path(fn_def_id, &args[..num_args])?;
1134+
write!(self, "() }}")?;
1135+
}
1136+
11261137
Ok(self)
11271138
}
11281139

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<(), ()>>`
16+
= help: within `impl Future<Output = Result<(), ()>>`, the trait `Send` is not implemented for `impl Future<Output = Result<(), ()>> { <T as Foo>::method() }`
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<(), ()>>`, 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,27 @@
1+
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/normalizing-self-auto-trait-issue-109924.rs:8: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]: `impl Future<Output = ()> { <_ as Foo>::bar() }` cannot be sent between threads safely
11+
--> $DIR/normalizing-self-auto-trait-issue-109924.rs:23:11
12+
|
13+
LL | build(Bar);
14+
| ----- ^^^ `impl Future<Output = ()> { <_ as Foo>::bar() }` cannot be sent between threads safely
15+
| |
16+
| required by a bound introduced by this call
17+
|
18+
= help: the trait `for<'a> Send` is not implemented for `impl Future<Output = ()> { <_ as Foo>::bar() }`
19+
note: required by a bound in `build`
20+
--> $DIR/normalizing-self-auto-trait-issue-109924.rs:20:39
21+
|
22+
LL | fn build<T>(_: T) where T: Foo<bar(): Send> {}
23+
| ^^^^ required by this bound in `build`
24+
25+
error: aborting due to previous error; 1 warning emitted
26+
27+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/normalizing-self-auto-trait-issue-109924.rs:8: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+
warning: 1 warning emitted
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// revisions: current next
2+
//[current] known-bug: #109924
3+
//[next] check-pass
4+
//[next] compile-flags: -Ztrait-solver=next
5+
// edition:2021
6+
7+
#![feature(async_fn_in_trait)]
8+
#![feature(return_type_notation)]
9+
//[next]~^ WARN the feature `return_type_notation` is incomplete
10+
11+
trait Foo {
12+
async fn bar(&self);
13+
}
14+
15+
struct Bar;
16+
impl Foo for Bar {
17+
async fn bar(&self) {}
18+
}
19+
20+
fn build<T>(_: T) where T: Foo<bar(): Send> {}
21+
22+
fn main() {
23+
build(Bar);
24+
}

0 commit comments

Comments
 (0)