Add a new Binding::is_unused method (#12729)
This commit is contained in:
@@ -36,9 +36,18 @@ pub struct Binding<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Binding<'a> {
|
||||
/// Return `true` if this [`Binding`] is unused.
|
||||
///
|
||||
/// This method is the opposite of [`Binding::is_used`].
|
||||
pub fn is_unused(&self) -> bool {
|
||||
self.references.is_empty()
|
||||
}
|
||||
|
||||
/// Return `true` if this [`Binding`] is used.
|
||||
///
|
||||
/// This method is the opposite of [`Binding::is_unused`].
|
||||
pub fn is_used(&self) -> bool {
|
||||
!self.references.is_empty()
|
||||
!self.is_unused()
|
||||
}
|
||||
|
||||
/// Returns an iterator over all references for the current [`Binding`].
|
||||
|
||||
@@ -1455,7 +1455,7 @@ impl<'a> SemanticModel<'a> {
|
||||
.get_all(id)
|
||||
.map(|binding_id| self.binding(binding_id))
|
||||
.filter(|binding| binding.start() >= expr.start())
|
||||
.all(|binding| !binding.is_used())
|
||||
.all(Binding::is_unused)
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user