Add and use generics.is_empty() and generics.is_own_empty, rather than using generics' attributes

This commit is contained in:
Santiago Pastorino
2024-05-11 11:46:25 +02:00
parent 84b9b6d16c
commit 4501ae89f1
18 changed files with 25 additions and 17 deletions

View File

@@ -391,6 +391,14 @@ impl<'tcx> Generics {
}
false
}
pub fn is_empty(&'tcx self) -> bool {
self.count() == 0
}
pub fn is_own_empty(&'tcx self) -> bool {
self.own_params.is_empty()
}
}
/// Bounds on generics.

View File

@@ -160,7 +160,7 @@ pub trait Printer<'tcx>: Sized {
// If we have any generic arguments to print, we do that
// on top of the same path, but without its own generics.
_ => {
if !generics.own_params.is_empty() && args.len() >= generics.count() {
if !generics.is_own_empty() && args.len() >= generics.count() {
let args = generics.own_args_no_defaults(self.tcx(), args);
return self.path_generic_args(
|cx| cx.print_def_path(def_id, parent_args),