Skip to content

Commit

Permalink
Rollup merge of rust-lang#103006 - WaffleLapkin:rustdoc_dont, r=compi…
Browse files Browse the repository at this point in the history
…ler-errors

rustdoc: don't ICE on `TyKind::Typeof`

Fixes rust-lang#102986

I'm not sure why rustdoc started seeing `TyKind::Typeof` all of a sudden (the code being editted was last touched 3 months ago), probably something to do with error recovery? idk.
  • Loading branch information
matthiaskrgr authored Oct 13, 2022
2 parents e991efd + 577d2cf commit e35ac3d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1543,8 +1543,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
}
TyKind::BareFn(barefn) => BareFunction(Box::new(clean_bare_fn_ty(barefn, cx))),
// Rustdoc handles `TyKind::Err`s by turning them into `Type::Infer`s.
TyKind::Infer | TyKind::Err => Infer,
TyKind::Typeof(..) => panic!("unimplemented type {:?}", ty.kind),
TyKind::Infer | TyKind::Err | TyKind::Typeof(..) => Infer,
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/test/rustdoc-ui/issue-102986.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
struct Struct {
y: (typeof("hey"),),
//~^ `typeof` is a reserved keyword but unimplemented
}
14 changes: 14 additions & 0 deletions src/test/rustdoc-ui/issue-102986.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0516]: `typeof` is a reserved keyword but unimplemented
--> $DIR/issue-102986.rs:2:9
|
LL | y: (typeof("hey"),),
| ^^^^^^^^^^^^^ reserved keyword
|
help: consider replacing `typeof(...)` with an actual type
|
LL | y: (&'static str,),
| ~~~~~~~~~~~~

error: aborting due to previous error

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

0 comments on commit e35ac3d

Please sign in to comment.