Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make type_of for RPITITs GAT on traits return a ty::Error if no default provided #113461

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions compiler/rustc_hir_analysis/src/collect/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,11 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<Ty
..
}) => {
if in_trait && !tcx.defaultness(owner).has_value() {
span_bug!(
return ty::EarlyBinder::bind(Ty::new_error_with_message(
tcx,
tcx.def_span(def_id),
"tried to get type of this RPITIT with no definition"
);
"tried to get type of this RPITIT with no definition",
));
}
opaque::find_opaque_ty_constraints_for_rpit(tcx, def_id, owner)
}
Expand Down
19 changes: 19 additions & 0 deletions tests/ui/impl-trait/in-trait/missing-type-parameter.current.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error: cannot check whether the hidden type of opaque type satisfies auto traits
--> $DIR/missing-type-parameter.rs:9:17
|
LL | fn bar() -> Wrapper<impl Sized>;
| ^^^^^^^^^^^^^^^^^^^
|
note: opaque type is declared here
--> $DIR/missing-type-parameter.rs:9:25
|
LL | fn bar() -> Wrapper<impl Sized>;
| ^^^^^^^^^^
note: required by a bound in `Wrapper`
--> $DIR/missing-type-parameter.rs:6:19
|
LL | struct Wrapper<G: Send>(G);
| ^^^^ required by this bound in `Wrapper`

error: aborting due to previous error

19 changes: 19 additions & 0 deletions tests/ui/impl-trait/in-trait/missing-type-parameter.next.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error: cannot check whether the hidden type of opaque type satisfies auto traits
--> $DIR/missing-type-parameter.rs:9:17
|
LL | fn bar() -> Wrapper<impl Sized>;
| ^^^^^^^^^^^^^^^^^^^
|
note: opaque type is declared here
--> $DIR/missing-type-parameter.rs:9:25
|
LL | fn bar() -> Wrapper<impl Sized>;
| ^^^^^^^^^^
note: required by a bound in `Wrapper`
--> $DIR/missing-type-parameter.rs:6:19
|
LL | struct Wrapper<G: Send>(G);
| ^^^^ required by this bound in `Wrapper`

error: aborting due to previous error

13 changes: 13 additions & 0 deletions tests/ui/impl-trait/in-trait/missing-type-parameter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
// revisions: current next

#![feature(return_position_impl_trait_in_trait)]

struct Wrapper<G: Send>(G);

trait Foo {
fn bar() -> Wrapper<impl Sized>;
//~^ ERROR: cannot check whether the hidden type of opaque type satisfies auto traits
}

fn main() {}