Skip to content

Commit d1fb1a3

Browse files
committed
remove typeof support
1 parent 4146079 commit d1fb1a3

File tree

26 files changed

+21
-251
lines changed

26 files changed

+21
-251
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,8 +2488,6 @@ pub enum TyKind {
24882488
ImplTrait(NodeId, #[visitable(extra = BoundKind::Impl)] GenericBounds),
24892489
/// No-op; kept solely so that we can pretty-print faithfully.
24902490
Paren(Box<Ty>),
2491-
/// Unused for now.
2492-
Typeof(AnonConst),
24932491
/// This means the type should be inferred instead of it having been
24942492
/// specified. This can appear anywhere in a type.
24952493
Infer,

compiler/rustc_ast/src/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ fn ident_can_begin_type(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool {
321321

322322
!ident_token.is_reserved_ident()
323323
|| ident_token.is_path_segment_keyword()
324-
|| [kw::Underscore, kw::For, kw::Impl, kw::Fn, kw::Unsafe, kw::Extern, kw::Typeof, kw::Dyn]
324+
|| [kw::Underscore, kw::For, kw::Impl, kw::Fn, kw::Unsafe, kw::Extern, kw::Dyn]
325325
.contains(&name)
326326
}
327327

compiler/rustc_ast/src/util/classify.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ fn type_trailing_braced_mac_call(mut ty: &ast::Ty) -> Option<&ast::MacCall> {
294294
| ast::TyKind::Never
295295
| ast::TyKind::Tup(..)
296296
| ast::TyKind::Paren(..)
297-
| ast::TyKind::Typeof(..)
298297
| ast::TyKind::Infer
299298
| ast::TyKind::ImplicitSelf
300299
| ast::TyKind::CVarArgs

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13611361
self.lower_ty(ty, itctx),
13621362
self.lower_array_length_to_const_arg(length),
13631363
),
1364-
TyKind::Typeof(expr) => hir::TyKind::Typeof(self.lower_anon_const_to_anon_const(expr)),
13651364
TyKind::TraitObject(bounds, kind) => {
13661365
let mut lifetime_bound = None;
13671366
let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| {

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,11 +1325,6 @@ impl<'a> State<'a> {
13251325
self.print_expr(&length.value, FixupContext::default());
13261326
self.word("]");
13271327
}
1328-
ast::TyKind::Typeof(e) => {
1329-
self.word("typeof(");
1330-
self.print_expr(&e.value, FixupContext::default());
1331-
self.word(")");
1332-
}
13331328
ast::TyKind::Infer => {
13341329
self.word("_");
13351330
}

compiler/rustc_error_codes/src/error_codes/E0516.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#### Note: this error code is no longer emitted by the compiler.
2+
13
The `typeof` keyword is currently reserved but unimplemented.
24

35
Erroneous code example:

compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,11 @@ impl<'tcx> InherentCollect<'tcx> {
195195
| ty::Closure(..)
196196
| ty::CoroutineClosure(..)
197197
| ty::Coroutine(..)
198-
| ty::CoroutineWitness(..) => {
199-
Err(self.tcx.dcx().delayed_bug("cannot define inherent `impl` for closure types"))
200-
}
201-
ty::Alias(ty::Free, _) | ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) => {
198+
| ty::CoroutineWitness(..)
199+
| ty::Alias(ty::Free, _)
200+
| ty::Bound(..)
201+
| ty::Placeholder(_)
202+
| ty::Infer(_) => {
202203
bug!("unexpected impl self type of impl: {:?} {:?}", id, self_ty);
203204
}
204205
// We could bail out here, but that will silence other useful errors.

compiler/rustc_hir_analysis/src/coherence/orphan.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,21 +217,19 @@ pub(crate) fn orphan_check_impl(
217217
| ty::Slice(..)
218218
| ty::RawPtr(..)
219219
| ty::Ref(..)
220-
| ty::FnDef(..)
221220
| ty::FnPtr(..)
222221
| ty::Never
223222
| ty::Tuple(..)
224223
| ty::UnsafeBinder(_) => (LocalImpl::Allow, NonlocalImpl::DisallowOther),
225224

226-
ty::Closure(..)
225+
ty::FnDef(..)
226+
| ty::Closure(..)
227227
| ty::CoroutineClosure(..)
228228
| ty::Coroutine(..)
229-
| ty::CoroutineWitness(..) => {
230-
return Err(tcx
231-
.dcx()
232-
.delayed_bug("cannot define inherent `impl` for closure types"));
233-
}
234-
ty::Bound(..) | ty::Placeholder(..) | ty::Infer(..) => {
229+
| ty::CoroutineWitness(..)
230+
| ty::Bound(..)
231+
| ty::Placeholder(..)
232+
| ty::Infer(..) => {
235233
let sp = tcx.def_span(impl_def_id);
236234
span_bug!(sp, "weird self type for autotrait impl")
237235
}

compiler/rustc_lint/src/unused.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,18 +1644,6 @@ impl EarlyLintPass for UnusedBraces {
16441644
);
16451645
}
16461646

1647-
ast::TyKind::Typeof(ref anon_const) => {
1648-
self.check_unused_delims_expr(
1649-
cx,
1650-
&anon_const.value,
1651-
UnusedDelimsCtx::AnonConst,
1652-
false,
1653-
None,
1654-
None,
1655-
false,
1656-
);
1657-
}
1658-
16591647
_ => {}
16601648
}
16611649
}

compiler/rustc_next_trait_solver/src/coherence.rs

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ where
336336
| ty::Uint(..)
337337
| ty::Float(..)
338338
| ty::Str
339-
| ty::FnDef(..)
340339
| ty::Pat(..)
341340
| ty::FnPtr(..)
342341
| ty::Array(..)
@@ -403,7 +402,6 @@ where
403402
// implement, so we don't use this behavior.
404403
// Addendum: Moreover, revealing the underlying type is likely to cause cycle
405404
// errors as we rely on coherence / the specialization graph during typeck.
406-
407405
self.found_non_local_ty(ty)
408406
}
409407
}
@@ -435,31 +433,14 @@ where
435433
}
436434
}
437435
ty::Error(_) => ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty)),
438-
ty::Closure(did, ..) => {
439-
if self.def_id_is_local(did) {
440-
ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty))
441-
} else {
442-
self.found_non_local_ty(ty)
443-
}
444-
}
445-
ty::CoroutineClosure(did, ..) => {
446-
if self.def_id_is_local(did) {
447-
ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty))
448-
} else {
449-
self.found_non_local_ty(ty)
450-
}
451-
}
452-
ty::Coroutine(did, ..) => {
453-
if self.def_id_is_local(did) {
454-
ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty))
455-
} else {
456-
self.found_non_local_ty(ty)
457-
}
436+
437+
ty::FnDef(..)
438+
| ty::Closure(..)
439+
| ty::CoroutineClosure(..)
440+
| ty::Coroutine(..)
441+
| ty::CoroutineWitness(..) => {
442+
unreachable!("unnameable type in coherence: {ty:?}");
458443
}
459-
// This should only be created when checking whether we have to check whether some
460-
// auto trait impl applies. There will never be multiple impls, so we can just
461-
// act as if it were a local type here.
462-
ty::CoroutineWitness(..) => ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty)),
463444
};
464445
// A bit of a hack, the `OrphanChecker` is only used to visit a `TraitRef`, so
465446
// the first type we visit is always the self type.

0 commit comments

Comments
 (0)