use crate::check::FnCtxt;
use rustc_ast as ast;
-use rustc_ast::util::lev_distance::find_best_match_for_name;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder};
use rustc_hir as hir;
use rustc_middle::ty::subst::GenericArg;
use rustc_middle::ty::{self, Adt, BindingMode, Ty, TypeFoldable};
use rustc_span::hygiene::DesugaringKind;
+use rustc_span::lev_distance::find_best_match_for_name;
use rustc_span::source_map::{Span, Spanned};
use rustc_span::symbol::Ident;
use rustc_trait_selection::traits::{ObligationCause, Pattern};
// Now that we know the types can be unified we find the unified type
// and use it to type the entire expression.
- let common_type = self.resolve_vars_if_possible(&lhs_ty.or(rhs_ty).unwrap_or(expected));
+ let common_type = self.resolve_vars_if_possible(lhs_ty.or(rhs_ty).unwrap_or(expected));
// Subtyping doesn't matter here, as the value is some kind of scalar.
let demand_eqtype = |x, y| {
}
let mut unmentioned_err = None;
- // Report an error if incorrect number of the fields were specified.
+ // Report an error if an incorrect number of fields was specified.
if adt.is_union() {
if fields.len() != 1 {
tcx.sess
tcx.sess.struct_span_err(pat.span, "`..` cannot be used in union patterns").emit();
}
} else if !etc && !unmentioned_fields.is_empty() {
- let no_accessible_unmentioned_fields = unmentioned_fields
- .iter()
- .find(|(field, _)| {
- field.vis.is_accessible_from(tcx.parent_module(pat.hir_id).to_def_id(), tcx)
- })
- .is_none();
+ let no_accessible_unmentioned_fields = !unmentioned_fields.iter().any(|(field, _)| {
+ field.vis.is_accessible_from(tcx.parent_module(pat.hir_id).to_def_id(), tcx)
+ });
if no_accessible_unmentioned_fields {
unmentioned_err = Some(self.error_no_accessible_fields(pat, &fields));
),
);
if plural == "" {
- let input = unmentioned_fields.iter().map(|(_, field)| &field.name);
- let suggested_name = find_best_match_for_name(input, ident.name, None);
+ let input =
+ unmentioned_fields.iter().map(|(_, field)| field.name).collect::<Vec<_>>();
+ let suggested_name = find_best_match_for_name(&input, ident.name, None);
if let Some(suggested_name) = suggested_name {
err.span_suggestion(
ident.span,