1
Fork 0

Re-format let-else per rustfmt update

This commit is contained in:
Mark Rousskov 2023-07-12 21:49:27 -04:00
parent 67b0cfc761
commit cc907f80b9
162 changed files with 1404 additions and 947 deletions

View file

@ -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;
};

View file

@ -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);

View file

@ -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 &params.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 {

View file

@ -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))?