Skip to content

Commit feb1303

Browse files
committed
remove support for type-of
1 parent cdb4236 commit feb1303

File tree

33 files changed

+38
-285
lines changed

33 files changed

+38
-285
lines changed

compiler/rustc_ast/src/ast.rs

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

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
@@ -1367,7 +1367,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13671367
self.lower_ty(ty, itctx),
13681368
self.lower_array_length_to_const_arg(length),
13691369
),
1370-
TyKind::Typeof(expr) => hir::TyKind::Typeof(self.lower_anon_const_to_anon_const(expr)),
13711370
TyKind::TraitObject(bounds, kind) => {
13721371
let mut lifetime_bound = None;
13731372
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/src/hir.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3680,8 +3680,6 @@ pub enum TyKind<'hir, Unambig = ()> {
36803680
/// We use pointer tagging to represent a `&'hir Lifetime` and `TraitObjectSyntax` pair
36813681
/// as otherwise this type being `repr(C)` would result in `TyKind` increasing in size.
36823682
TraitObject(&'hir [PolyTraitRef<'hir>], TaggedRef<'hir, Lifetime, TraitObjectSyntax>),
3683-
/// Unused for now.
3684-
Typeof(&'hir AnonConst),
36853683
/// Placeholder for a type that has failed to be defined.
36863684
Err(rustc_span::ErrorGuaranteed),
36873685
/// Pattern types (`pattern_type!(u32 is 1..)`)

compiler/rustc_hir/src/intravisit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,6 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v, AmbigArg>) -
10291029
}
10301030
try_visit!(visitor.visit_lifetime(lifetime));
10311031
}
1032-
TyKind::Typeof(ref expression) => try_visit!(visitor.visit_anon_const(expression)),
10331032
TyKind::InferDelegation(..) | TyKind::Err(_) => {}
10341033
TyKind::Pat(ty, pat) => {
10351034
try_visit!(visitor.visit_ty_unambig(ty));

compiler/rustc_hir_analysis/messages.ftl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,6 @@ hir_analysis_ty_param_some = type parameter `{$param}` must be used as the type
552552
553553
hir_analysis_type_of = {$ty}
554554
555-
hir_analysis_typeof_reserved_keyword_used =
556-
`typeof` is a reserved keyword but unimplemented
557-
.suggestion = consider replacing `typeof(...)` with an actual type
558-
.label = reserved keyword
559-
560555
hir_analysis_unconstrained_generic_parameter = the {$param_def_kind} `{$param_name}` is not constrained by the impl trait, self type, or predicates
561556
.label = unconstrained {$param_def_kind}
562557
.const_param_note = expressions using a const parameter must map each value to a distinct output value

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
}

0 commit comments

Comments
 (0)