Skip to content
Merged
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
9 changes: 4 additions & 5 deletions compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,10 @@ impl<'tcx> InherentCollect<'tcx> {
| ty::Closure(..)
| ty::CoroutineClosure(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Alias(ty::Free, _)
| ty::Bound(..)
| ty::Placeholder(_)
| ty::Infer(_) => {
| ty::CoroutineWitness(..) => {
Err(self.tcx.dcx().delayed_bug("cannot define inherent `impl` for closure types"))
}
ty::Alias(ty::Free, _) | ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) => {
bug!("unexpected impl self type of impl: {:?} {:?}", id, self_ty);
}
// We could bail out here, but that will silence other useful errors.
Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,12 @@ pub(crate) fn orphan_check_impl(
ty::Closure(..)
| ty::CoroutineClosure(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Bound(..)
| ty::Placeholder(..)
| ty::Infer(..) => {
| ty::CoroutineWitness(..) => {
return Err(tcx
.dcx()
.delayed_bug("cannot define inherent `impl` for closure types"));
}
ty::Bound(..) | ty::Placeholder(..) | ty::Infer(..) => {
let sp = tcx.def_span(impl_def_id);
span_bug!(sp, "weird self type for autotrait impl")
}
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/closures/impl-closure-147146.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
impl typeof(|| {}) {}
//~^ ERROR `typeof` is a reserved keyword but unimplemented

unsafe impl Send for typeof(|| {}) {}
//~^ ERROR `typeof` is a reserved keyword but unimplemented

fn main() {}
15 changes: 15 additions & 0 deletions tests/ui/closures/impl-closure-147146.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0516]: `typeof` is a reserved keyword but unimplemented
--> $DIR/impl-closure-147146.rs:1:6
|
LL | impl typeof(|| {}) {}
| ^^^^^^^^^^^^^ reserved keyword

error[E0516]: `typeof` is a reserved keyword but unimplemented
--> $DIR/impl-closure-147146.rs:4:22
|
LL | unsafe impl Send for typeof(|| {}) {}
| ^^^^^^^^^^^^^ reserved keyword

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0516`.
Loading