Skip to content

Commit 8973049

Browse files
committed
Auto merge of #108268 - matthiaskrgr:rollup-4tdvnx6, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #108124 (Document that CStr::as_ptr returns a type alias) - #108171 (Improve building compiler artifacts output) - #108200 (Use restricted Damerau-Levenshtein distance for diagnostics) - #108259 (remove FIXME that doesn't require fixing) - #108265 ("`const` generic" -> "const parameter") Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 267cd1d + e4dadd6 commit 8973049

File tree

27 files changed

+506
-325
lines changed

27 files changed

+506
-325
lines changed

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
1313
use rustc_hir::PredicateOrigin;
1414
use rustc_index::vec::{Idx, IndexVec};
1515
use rustc_middle::ty::{DefIdTree, ResolverAstLowering, TyCtxt};
16-
use rustc_span::lev_distance::find_best_match_for_name;
16+
use rustc_span::edit_distance::find_best_match_for_name;
1717
use rustc_span::source_map::DesugaringKind;
1818
use rustc_span::symbol::{kw, sym, Ident};
1919
use rustc_span::{Span, Symbol};

compiler/rustc_hir_analysis/src/astconv/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_hir::def_id::DefId;
77
use rustc_infer::traits::FulfillmentError;
88
use rustc_middle::ty::{self, Ty};
99
use rustc_session::parse::feature_err;
10-
use rustc_span::lev_distance::find_best_match_for_name;
10+
use rustc_span::edit_distance::find_best_match_for_name;
1111
use rustc_span::symbol::{sym, Ident};
1212
use rustc_span::{Span, Symbol, DUMMY_SP};
1313

compiler/rustc_hir_analysis/src/astconv/generics.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::astconv::{
66
use crate::errors::AssocTypeBindingNotAllowed;
77
use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs};
88
use rustc_ast::ast::ParamKindOrd;
9-
use rustc_errors::{struct_span_err, Applicability, Diagnostic, MultiSpan};
9+
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed, MultiSpan};
1010
use rustc_hir as hir;
1111
use rustc_hir::def::{DefKind, Res};
1212
use rustc_hir::def_id::DefId;
@@ -26,7 +26,7 @@ fn generic_arg_mismatch_err(
2626
param: &GenericParamDef,
2727
possible_ordering_error: bool,
2828
help: Option<&str>,
29-
) {
29+
) -> ErrorGuaranteed {
3030
let sess = tcx.sess;
3131
let mut err = struct_span_err!(
3232
sess,
@@ -70,9 +70,9 @@ fn generic_arg_mismatch_err(
7070
) => match path.res {
7171
Res::Err => {
7272
add_braces_suggestion(arg, &mut err);
73-
err.set_primary_message("unresolved item provided when a constant was expected")
73+
return err
74+
.set_primary_message("unresolved item provided when a constant was expected")
7475
.emit();
75-
return;
7676
}
7777
Res::Def(DefKind::TyParam, src_def_id) => {
7878
if let Some(param_local_id) = param.def_id.as_local() {
@@ -81,7 +81,7 @@ fn generic_arg_mismatch_err(
8181
if param_type.is_suggestable(tcx, false) {
8282
err.span_suggestion(
8383
tcx.def_span(src_def_id),
84-
"consider changing this type parameter to be a `const` generic",
84+
"consider changing this type parameter to a const parameter",
8585
format!("const {}: {}", param_name, param_type),
8686
Applicability::MaybeIncorrect,
8787
);
@@ -137,7 +137,7 @@ fn generic_arg_mismatch_err(
137137
}
138138
}
139139

140-
err.emit();
140+
err.emit()
141141
}
142142

143143
/// Creates the relevant generic argument substitutions

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ use rustc_middle::ty::DynKind;
3737
use rustc_middle::ty::GenericParamDefKind;
3838
use rustc_middle::ty::{self, Const, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeVisitable};
3939
use rustc_session::lint::builtin::{AMBIGUOUS_ASSOCIATED_ITEMS, BARE_TRAIT_OBJECTS};
40+
use rustc_span::edit_distance::find_best_match_for_name;
4041
use rustc_span::edition::Edition;
41-
use rustc_span::lev_distance::find_best_match_for_name;
4242
use rustc_span::symbol::{kw, Ident, Symbol};
4343
use rustc_span::{sym, Span, DUMMY_SP};
4444
use rustc_target::spec::abi;

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ use rustc_middle::ty::subst::SubstsRef;
4545
use rustc_middle::ty::{self, AdtKind, Ty, TypeVisitable};
4646
use rustc_session::errors::ExprParenthesesNeeded;
4747
use rustc_session::parse::feature_err;
48+
use rustc_span::edit_distance::find_best_match_for_name;
4849
use rustc_span::hygiene::DesugaringKind;
49-
use rustc_span::lev_distance::find_best_match_for_name;
5050
use rustc_span::source_map::{Span, Spanned};
5151
use rustc_span::symbol::{kw, sym, Ident, Symbol};
5252
use rustc_target::spec::abi::Abi::RustIntrinsic;

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use rustc_middle::ty::{InternalSubsts, SubstsRef};
2424
use rustc_session::lint;
2525
use rustc_span::def_id::DefId;
2626
use rustc_span::def_id::LocalDefId;
27-
use rustc_span::lev_distance::{
28-
find_best_match_for_name_with_substrings, lev_distance_with_substrings,
27+
use rustc_span::edit_distance::{
28+
edit_distance_with_substrings, find_best_match_for_name_with_substrings,
2929
};
3030
use rustc_span::symbol::sym;
3131
use rustc_span::{symbol::Ident, Span, Symbol, DUMMY_SP};
@@ -69,7 +69,7 @@ struct ProbeContext<'a, 'tcx> {
6969
impl_dups: FxHashSet<DefId>,
7070

7171
/// When probing for names, include names that are close to the
72-
/// requested name (by Levenshtein distance)
72+
/// requested name (by edit distance)
7373
allow_similar_names: bool,
7474

7575
/// Some(candidate) if there is a private candidate
@@ -1793,7 +1793,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
17931793

17941794
/// Similarly to `probe_for_return_type`, this method attempts to find the best matching
17951795
/// candidate method where the method name may have been misspelled. Similarly to other
1796-
/// Levenshtein based suggestions, we provide at most one such suggestion.
1796+
/// edit distance based suggestions, we provide at most one such suggestion.
17971797
fn probe_for_similar_candidate(&mut self) -> Result<Option<ty::AssocItem>, MethodError<'tcx>> {
17981798
debug!("probing for method names similar to {:?}", self.method_name);
17991799

@@ -2024,8 +2024,11 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
20242024
if self.matches_by_doc_alias(x.def_id) {
20252025
return true;
20262026
}
2027-
match lev_distance_with_substrings(name.as_str(), x.name.as_str(), max_dist)
2028-
{
2027+
match edit_distance_with_substrings(
2028+
name.as_str(),
2029+
x.name.as_str(),
2030+
max_dist,
2031+
) {
20292032
Some(d) => d > 0,
20302033
None => false,
20312034
}

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc_middle::ty::{self, DefIdTree, GenericArgKind, Ty, TyCtxt, TypeVisitabl
3131
use rustc_middle::ty::{IsSuggestable, ToPolyTraitRef};
3232
use rustc_span::symbol::{kw, sym, Ident};
3333
use rustc_span::Symbol;
34-
use rustc_span::{lev_distance, source_map, ExpnKind, FileName, MacroKind, Span};
34+
use rustc_span::{edit_distance, source_map, ExpnKind, FileName, MacroKind, Span};
3535
use rustc_trait_selection::traits::error_reporting::on_unimplemented::OnUnimplementedNote;
3636
use rustc_trait_selection::traits::error_reporting::on_unimplemented::TypeErrCtxtExt as _;
3737
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
@@ -1014,7 +1014,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10141014
// that had unsatisfied trait bounds
10151015
if unsatisfied_predicates.is_empty() && rcvr_ty.is_enum() {
10161016
let adt_def = rcvr_ty.ty_adt_def().expect("enum is not an ADT");
1017-
if let Some(suggestion) = lev_distance::find_best_match_for_name(
1017+
if let Some(suggestion) = edit_distance::find_best_match_for_name(
10181018
&adt_def.variants().iter().map(|s| s.name).collect::<Vec<_>>(),
10191019
item_name.name,
10201020
None,

compiler/rustc_hir_typeck/src/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKi
1414
use rustc_middle::middle::stability::EvalResult;
1515
use rustc_middle::ty::{self, Adt, BindingMode, Ty, TypeVisitable};
1616
use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
17+
use rustc_span::edit_distance::find_best_match_for_name;
1718
use rustc_span::hygiene::DesugaringKind;
18-
use rustc_span::lev_distance::find_best_match_for_name;
1919
use rustc_span::source_map::{Span, Spanned};
2020
use rustc_span::symbol::{kw, sym, Ident};
2121
use rustc_span::{BytePos, DUMMY_SP};

compiler/rustc_interface/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use rustc_session::filesearch::sysroot_candidates;
1414
use rustc_session::lint::{self, BuiltinLintDiagnostics, LintBuffer};
1515
use rustc_session::parse::CrateConfig;
1616
use rustc_session::{early_error, filesearch, output, Session};
17+
use rustc_span::edit_distance::find_best_match_for_name;
1718
use rustc_span::edition::Edition;
18-
use rustc_span::lev_distance::find_best_match_for_name;
1919
use rustc_span::source_map::FileLoader;
2020
use rustc_span::symbol::{sym, Symbol};
2121
use session::CompilerIO;

compiler/rustc_lint/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use rustc_middle::ty::{self, print::Printer, subst::GenericArg, RegisteredTools,
3939
use rustc_session::lint::{BuiltinLintDiagnostics, LintExpectationId};
4040
use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId};
4141
use rustc_session::Session;
42-
use rustc_span::lev_distance::find_best_match_for_name;
42+
use rustc_span::edit_distance::find_best_match_for_name;
4343
use rustc_span::symbol::{sym, Ident, Symbol};
4444
use rustc_span::{BytePos, Span};
4545
use rustc_target::abi;

0 commit comments

Comments
 (0)