Mark Printer methods as unreachable where appropriate.

This helps me understand the structure of the code a lot.

If any of these are actually reachable, we can put the old code back,
add a new test case, and we will have improved our test coverage.
This commit is contained in:
Nicholas Nethercote
2025-08-01 08:10:16 +10:00
parent da19b9d24c
commit df524163be
4 changed files with 17 additions and 14 deletions

View File

@@ -756,22 +756,22 @@ impl<'tcx> LateContext<'tcx> {
}
fn print_region(&mut self, _region: ty::Region<'_>) -> Result<(), PrintError> {
Ok(())
unreachable!(); // because `path_generic_args` ignores the `GenericArgs`
}
fn print_type(&mut self, _ty: Ty<'tcx>) -> Result<(), PrintError> {
Ok(())
unreachable!(); // because `path_generic_args` ignores the `GenericArgs`
}
fn print_dyn_existential(
&mut self,
_predicates: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
) -> Result<(), PrintError> {
Ok(())
unreachable!(); // because `path_generic_args` ignores the `GenericArgs`
}
fn print_const(&mut self, _ct: ty::Const<'tcx>) -> Result<(), PrintError> {
Ok(())
unreachable!(); // because `path_generic_args` ignores the `GenericArgs`
}
fn path_crate(&mut self, cnum: CrateNum) -> Result<(), PrintError> {
@@ -784,10 +784,10 @@ impl<'tcx> LateContext<'tcx> {
self_ty: Ty<'tcx>,
trait_ref: Option<ty::TraitRef<'tcx>>,
) -> Result<(), PrintError> {
if trait_ref.is_none() {
if let ty::Adt(def, args) = self_ty.kind() {
return self.print_def_path(def.did(), args);
}
if trait_ref.is_none()
&& let ty::Adt(def, args) = self_ty.kind()
{
return self.print_def_path(def.did(), args);
}
// This shouldn't ever be needed, but just in case: