Skip to content

Commit 3b4d6e0

Browse files
committedFeb 22, 2023
Auto merge of #108339 - GuillaumeGomez:rollup-4z02kas, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - #108110 (Move some `InferCtxt` methods to `EvalCtxt` in new solver) - #108168 (Fix ICE on type alias in recursion) - #108230 (Convert a hard-warning about named static lifetimes into lint "unused_lifetimes") - #108239 (Fix overlapping spans in removing extra arguments) - #108246 (Add an InstCombine for redundant casts) - #108264 (no-fail-fast support for tool testsuites) - #108310 (rustdoc: Fix duplicated attributes for first reexport) - #108318 (Remove unused FileDesc::get_cloexec) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents bd4a96a + 0d0de49 commit 3b4d6e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+562
-400
lines changed
 

‎compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+24-22
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_middle::bug;
1818
use rustc_middle::hir::nested_filter;
1919
use rustc_middle::middle::resolve_bound_vars::*;
2020
use rustc_middle::ty::{self, ir::TypeVisitor, DefIdTree, TyCtxt, TypeSuperVisitable};
21+
use rustc_session::lint;
2122
use rustc_span::def_id::DefId;
2223
use rustc_span::symbol::{sym, Ident};
2324
use rustc_span::Span;
@@ -923,17 +924,16 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
923924
origin,
924925
..
925926
}) => {
926-
927927
let (bound_vars, binders): (FxIndexMap<LocalDefId, ResolvedArg>, Vec<_>) =
928928
bound_generic_params
929-
.iter()
930-
.enumerate()
931-
.map(|(late_bound_idx, param)| {
932-
let pair = ResolvedArg::late(late_bound_idx as u32, param);
933-
let r = late_arg_as_bound_arg(this.tcx, &pair.1, param);
934-
(pair, r)
935-
})
936-
.unzip();
929+
.iter()
930+
.enumerate()
931+
.map(|(late_bound_idx, param)| {
932+
let pair = ResolvedArg::late(late_bound_idx as u32, param);
933+
let r = late_arg_as_bound_arg(this.tcx, &pair.1, param);
934+
(pair, r)
935+
})
936+
.unzip();
937937
this.record_late_bound_vars(hir_id, binders.clone());
938938
// Even if there are no lifetimes defined here, we still wrap it in a binder
939939
// scope. If there happens to be a nested poly trait ref (an error), that
@@ -968,20 +968,22 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
968968
continue;
969969
}
970970
this.insert_lifetime(lt, ResolvedArg::StaticLifetime);
971-
this.tcx
972-
.sess
973-
.struct_span_warn(
974-
lifetime.ident.span,
975-
&format!(
976-
"unnecessary lifetime parameter `{}`",
971+
this.tcx.struct_span_lint_hir(
972+
lint::builtin::UNUSED_LIFETIMES,
973+
lifetime.hir_id,
974+
lifetime.ident.span,
975+
format!(
976+
"unnecessary lifetime parameter `{}`",
977+
lifetime.ident
978+
),
979+
|lint| {
980+
let help = &format!(
981+
"you can use the `'static` lifetime directly, in place of `{}`",
977982
lifetime.ident,
978-
),
979-
)
980-
.help(&format!(
981-
"you can use the `'static` lifetime directly, in place of `{}`",
982-
lifetime.ident,
983-
))
984-
.emit();
983+
);
984+
lint.help(help)
985+
},
986+
);
985987
}
986988
}
987989
}

‎compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -932,25 +932,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
932932
labels
933933
.push((provided_span, format!("unexpected argument{}", provided_ty_name)));
934934
let mut span = provided_span;
935-
if arg_idx.index() > 0
935+
if span.can_be_used_for_suggestions() {
936+
if arg_idx.index() > 0
936937
&& let Some((_, prev)) = provided_arg_tys
937938
.get(ProvidedIdx::from_usize(arg_idx.index() - 1)
938939
) {
939940
// Include previous comma
940-
span = span.with_lo(prev.hi());
941-
} else if let Some((_, next)) = provided_arg_tys.get(
942-
ProvidedIdx::from_usize(arg_idx.index() + 1),
943-
) {
944-
// Include next comma
945-
span = span.until(*next);
941+
span = prev.shrink_to_hi().to(span);
946942
}
947-
suggestions.push((span, String::new()));
943+
suggestions.push((span, String::new()));
948944

949-
suggestion_text = match suggestion_text {
950-
SuggestionText::None => SuggestionText::Remove(false),
951-
SuggestionText::Remove(_) => SuggestionText::Remove(true),
952-
_ => SuggestionText::DidYouMean,
953-
};
945+
suggestion_text = match suggestion_text {
946+
SuggestionText::None => SuggestionText::Remove(false),
947+
SuggestionText::Remove(_) => SuggestionText::Remove(true),
948+
_ => SuggestionText::DidYouMean,
949+
};
950+
}
954951
}
955952
Error::Missing(expected_idx) => {
956953
// If there are multiple missing arguments adjacent to each other,

0 commit comments

Comments
 (0)