Skip to content

Commit 07a230b

Browse files
committed
Do not assert >1 RPITITs on collect_return_position_impl_trait_in_trait_tys
1 parent c4c84df commit 07a230b

File tree

4 files changed

+45
-5
lines changed

4 files changed

+45
-5
lines changed

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -669,11 +669,13 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
669669
)
670670
.fold_with(&mut collector);
671671

672-
debug_assert_ne!(
673-
collector.types.len(),
674-
0,
675-
"expect >1 RPITITs in call to `collect_return_position_impl_trait_in_trait_tys`"
676-
);
672+
if !unnormalized_trait_sig.output().references_error() {
673+
debug_assert_ne!(
674+
collector.types.len(),
675+
0,
676+
"expect >1 RPITITs in call to `collect_return_position_impl_trait_in_trait_tys`"
677+
);
678+
}
677679

678680
let trait_sig = ocx.normalize(&norm_cause, param_env, unnormalized_trait_sig);
679681
trait_sig.error_reported()?;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0412]: cannot find type `Missing` in this scope
2+
--> $DIR/return-not-existing-type-wrapping-rpitit.rs:10:25
3+
|
4+
LL | fn bar() -> Wrapper<Missing<impl Sized>>;
5+
| ^^^^^^^ not found in this scope
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0412`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0412]: cannot find type `Missing` in this scope
2+
--> $DIR/return-not-existing-type-wrapping-rpitit.rs:10:25
3+
|
4+
LL | fn bar() -> Wrapper<Missing<impl Sized>>;
5+
| ^^^^^^^ not found in this scope
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0412`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// edition:2021
2+
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
3+
// revisions: current next
4+
5+
#![feature(return_position_impl_trait_in_trait)]
6+
7+
struct Wrapper<T>(T);
8+
9+
trait Foo {
10+
fn bar() -> Wrapper<Missing<impl Sized>>;
11+
//~^ ERROR: cannot find type `Missing` in this scope [E0412]
12+
}
13+
14+
impl Foo for () {
15+
fn bar() -> Wrapper<i32> {
16+
Wrapper(0)
17+
}
18+
}
19+
20+
fn main() {}

0 commit comments

Comments
 (0)