Skip to content

Commit 8ede234

Browse files
authored
Rollup merge of #102597 - compiler-errors:issue-102571, r=davidtwco
Avoid ICE in printing RPITIT type Fixes #102571
2 parents cdd0ba8 + 90a8d67 commit 8ede234

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ pub trait PrettyPrinter<'tcx>:
927927
// unless we can find out what generator return type it comes from.
928928
let term = if let Some(ty) = term.skip_binder().ty()
929929
&& let ty::Projection(proj) = ty.kind()
930-
&& let assoc = tcx.associated_item(proj.item_def_id)
930+
&& let Some(assoc) = tcx.opt_associated_item(proj.item_def_id)
931931
&& assoc.trait_container(tcx) == tcx.lang_items().gen_trait()
932932
&& assoc.name == rustc_span::sym::Return
933933
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![feature(return_position_impl_trait_in_trait)]
2+
#![allow(incomplete_features)]
3+
4+
use std::fmt::Display;
5+
use std::ops::Deref;
6+
7+
trait Foo {
8+
fn bar(self) -> impl Deref<Target = impl Display + ?Sized>;
9+
}
10+
11+
struct A;
12+
13+
impl Foo for A {
14+
fn bar(self) -> &'static str {
15+
"Hello, world"
16+
}
17+
}
18+
19+
fn foo<T: Foo>(t: T) {
20+
let () = t.bar();
21+
//~^ ERROR mismatched types
22+
}
23+
24+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-102571.rs:20:9
3+
|
4+
LL | let () = t.bar();
5+
| ^^ ------- this expression has type `impl Deref<Target = impl std::fmt::Display + ?Sized>`
6+
| |
7+
| expected associated type, found `()`
8+
|
9+
= note: expected associated type `impl Deref<Target = impl std::fmt::Display + ?Sized>`
10+
found unit type `()`
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)