1
Fork 0

Rollup merge of #137712 - meithecatte:extract-binding-mode, r=oli-obk

Clean up TypeckResults::extract_binding_mode

- Remove the `Option` from the result type, as `None` is never returned.
- Document the difference from the `BindingMode` in `PatKind::Binding`.
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2025-02-28 21:42:00 +08:00 committed by GitHub
commit a9f3f02ed7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 45 additions and 45 deletions

View file

@ -394,8 +394,10 @@ impl<'tcx> TypeckResults<'tcx> {
matches!(self.type_dependent_defs().get(expr.hir_id), Some(Ok((DefKind::AssocFn, _))))
}
pub fn extract_binding_mode(&self, s: &Session, id: HirId, sp: Span) -> Option<BindingMode> {
self.pat_binding_modes().get(id).copied().or_else(|| {
/// Returns the computed binding mode for a `PatKind::Binding` pattern
/// (after match ergonomics adjustments).
pub fn extract_binding_mode(&self, s: &Session, id: HirId, sp: Span) -> BindingMode {
self.pat_binding_modes().get(id).copied().unwrap_or_else(|| {
s.dcx().span_bug(sp, "missing binding mode");
})
}