diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2024-05-11 11:46:25 +0200 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2024-05-19 11:10:56 -0300 |
| commit | 4501ae89f1a442df66e0aeb8f864045d46a98d79 (patch) | |
| tree | a0d1bf8bf9af187c6120644f93af16c499bd77d9 /compiler/rustc_middle | |
| parent | 84b9b6d16c9328fa495743638f664f80a7379795 (diff) | |
| download | rust-4501ae89f1a442df66e0aeb8f864045d46a98d79.tar.gz rust-4501ae89f1a442df66e0aeb8f864045d46a98d79.zip | |
Add and use generics.is_empty() and generics.is_own_empty, rather than using generics' attributes
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/ty/generics.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/mod.rs | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs index 04655c5d20b..cfaca05c2f0 100644 --- a/compiler/rustc_middle/src/ty/generics.rs +++ b/compiler/rustc_middle/src/ty/generics.rs @@ -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. diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index e7589737d64..dc77f59f3d0 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -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), |
