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:
parent
da19b9d24c
commit
df524163be
4 changed files with 17 additions and 14 deletions
|
|
@ -18,7 +18,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
|
|||
}
|
||||
|
||||
fn print_region(&mut self, _region: ty::Region<'_>) -> Result<(), PrintError> {
|
||||
Ok(())
|
||||
unreachable!(); // because `<Self As PrettyPrinter>::should_print_region` returns false
|
||||
}
|
||||
|
||||
fn print_type(&mut self, ty: Ty<'tcx>) -> Result<(), PrintError> {
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ impl<'tcx> Printer<'tcx> for SymbolPrinter<'tcx> {
|
|||
}
|
||||
|
||||
fn print_region(&mut self, _region: ty::Region<'_>) -> Result<(), PrintError> {
|
||||
Ok(())
|
||||
unreachable!(); // because `<Self As PrettyPrinter>::should_print_region` returns false
|
||||
}
|
||||
|
||||
fn print_type(&mut self, ty: Ty<'tcx>) -> Result<(), PrintError> {
|
||||
|
|
|
|||
|
|
@ -235,28 +235,29 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn print_region(&mut self, _region: ty::Region<'_>) -> Result<(), PrintError> {
|
||||
Err(fmt::Error)
|
||||
unreachable!(); // because `path_generic_args` ignores the `GenericArgs`
|
||||
}
|
||||
|
||||
fn print_type(&mut self, _ty: Ty<'tcx>) -> Result<(), PrintError> {
|
||||
Err(fmt::Error)
|
||||
unreachable!(); // because `path_generic_args` ignores the `GenericArgs`
|
||||
}
|
||||
|
||||
fn print_dyn_existential(
|
||||
&mut self,
|
||||
_predicates: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
|
||||
) -> Result<(), PrintError> {
|
||||
Err(fmt::Error)
|
||||
unreachable!(); // because `path_generic_args` ignores the `GenericArgs`
|
||||
}
|
||||
|
||||
fn print_const(&mut self, _ct: ty::Const<'tcx>) -> Result<(), PrintError> {
|
||||
Err(fmt::Error)
|
||||
unreachable!(); // because `path_generic_args` ignores the `GenericArgs`
|
||||
}
|
||||
|
||||
fn path_crate(&mut self, cnum: CrateNum) -> Result<(), PrintError> {
|
||||
self.segments = vec![self.tcx.crate_name(cnum)];
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn path_qualified(
|
||||
&mut self,
|
||||
_self_ty: Ty<'tcx>,
|
||||
|
|
@ -274,6 +275,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
) -> Result<(), PrintError> {
|
||||
Err(fmt::Error)
|
||||
}
|
||||
|
||||
fn path_append(
|
||||
&mut self,
|
||||
print_prefix: impl FnOnce(&mut Self) -> Result<(), PrintError>,
|
||||
|
|
@ -283,6 +285,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
self.segments.push(disambiguated_data.as_sym(true));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn path_generic_args(
|
||||
&mut self,
|
||||
print_prefix: impl FnOnce(&mut Self) -> Result<(), PrintError>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue