diff options
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/imports.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/late.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/late/diagnostics.rs | 38 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/lib.rs | 5 |
4 files changed, 40 insertions, 18 deletions
diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index d37fe783bba..526fc9c3aa5 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -1300,9 +1300,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let ImportKind::Glob { id, is_prelude, .. } = import.kind else { unreachable!() }; let ModuleOrUniformRoot::Module(module) = import.imported_module.get().unwrap() else { - self.tcx.sess.create_err(CannotGlobImportAllCrates { - span: import.span, - }).emit(); + self.tcx.sess.create_err(CannotGlobImportAllCrates { span: import.span }).emit(); return; }; diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index f6c7aecf8b0..a715a1453a3 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -2460,8 +2460,11 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { F: FnOnce(&mut Self), { debug!("with_generic_param_rib"); - let LifetimeRibKind::Generics { binder, span: generics_span, kind: generics_kind, .. } - = lifetime_kind else { panic!() }; + let LifetimeRibKind::Generics { binder, span: generics_span, kind: generics_kind, .. } = + lifetime_kind + else { + panic!() + }; let mut function_type_rib = Rib::new(kind); let mut function_value_rib = Rib::new(kind); @@ -2972,7 +2975,9 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { F: FnOnce(Ident, String, Option<Symbol>) -> ResolutionError<'a>, { // If there is a TraitRef in scope for an impl, then the method must be in the trait. - let Some((module, _)) = self.current_trait_ref else { return; }; + let Some((module, _)) = self.current_trait_ref else { + return; + }; ident.span.normalize_to_macros_2_0_and_adjust(module.expansion); let key = BindingKey::new(ident, ns); let mut binding = self.r.resolution(module, key).try_borrow().ok().and_then(|r| r.binding); diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 78ef72a7e34..753a1adc66d 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -446,20 +446,29 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { err: &mut Diagnostic, base_error: &BaseError, ) { - let Some(ty) = self.diagnostic_metadata.current_type_path else { return; }; - let TyKind::Path(_, path) = &ty.kind else { return; }; + let Some(ty) = self.diagnostic_metadata.current_type_path else { + return; + }; + let TyKind::Path(_, path) = &ty.kind else { + return; + }; for segment in &path.segments { - let Some(params) = &segment.args else { continue; }; - let ast::GenericArgs::AngleBracketed(ref params) = params.deref() else { continue; }; + let Some(params) = &segment.args else { + continue; + }; + let ast::GenericArgs::AngleBracketed(ref params) = params.deref() else { + continue; + }; for param in ¶ms.args { - let ast::AngleBracketedArg::Constraint(constraint) = param else { continue; }; + let ast::AngleBracketedArg::Constraint(constraint) = param else { + continue; + }; let ast::AssocConstraintKind::Bound { bounds } = &constraint.kind else { continue; }; for bound in bounds { - let ast::GenericBound::Trait(trait_ref, ast::TraitBoundModifier::None) - = bound else - { + let ast::GenericBound::Trait(trait_ref, ast::TraitBoundModifier::None) = bound + else { continue; }; if base_error.span == trait_ref.span { @@ -1148,7 +1157,11 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { &poly_trait_ref.trait_ref.path.segments[..] { if ident.span == span { - let Some(new_where_bound_predicate) = mk_where_bound_predicate(path, poly_trait_ref, ty) else { return false; }; + let Some(new_where_bound_predicate) = + mk_where_bound_predicate(path, poly_trait_ref, ty) + else { + return false; + }; err.span_suggestion_verbose( *where_span, format!("constrain the associated type to `{}`", ident), @@ -1831,7 +1844,8 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { None, ) { Some(found) => { - let Some(sugg) = names.into_iter().find(|suggestion| suggestion.candidate == found) else { + let Some(sugg) = names.into_iter().find(|suggestion| suggestion.candidate == found) + else { return TypoCandidate::None; }; if found == name { @@ -2677,7 +2691,9 @@ fn mk_where_bound_predicate( use rustc_span::DUMMY_SP; let modified_segments = { let mut segments = path.segments.clone(); - let [preceding @ .., second_last, last] = segments.as_mut_slice() else { return None; }; + let [preceding @ .., second_last, last] = segments.as_mut_slice() else { + return None; + }; let mut segments = ThinVec::from(preceding); let added_constraint = ast::AngleBracketedArg::Constraint(ast::AssocConstraint { diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index da3d86a4718..faa672db59c 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1871,7 +1871,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } else { let crate_id = if finalize { let Some(crate_id) = - self.crate_loader(|c| c.process_path_extern(ident.name, ident.span)) else { return Some(self.dummy_binding); }; + self.crate_loader(|c| c.process_path_extern(ident.name, ident.span)) + else { + return Some(self.dummy_binding); + }; crate_id } else { self.crate_loader(|c| c.maybe_process_path_extern(ident.name))? |
