Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ impl<'a> AstValidator<'a> {
self.dcx().emit_err(diagnostics::ArgsBeforeConstraint {
arg_spans: arg_spans.clone(),
constraints: constraint_spans[0],
args: *arg_spans.iter().last().unwrap(),
args: *arg_spans.last().unwrap(),
data: data.span,
constraint_spans: diagnostics::EmptyLabelManySpans(constraint_spans),
arg_spans2: diagnostics::EmptyLabelManySpans(arg_spans),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ fn extend_err_with_const_context(
{
// `foo<N>()`, point at the const parameter in the definition of `foo`.
if let Some(i) =
path.segments.iter().last().and_then(|segment| segment.args).and_then(|args| {
path.segments.last().and_then(|segment| segment.args).and_then(|args| {
args.args.iter().position(|arg| {
matches!(arg, hir::GenericArg::Const(arg) if arg.hir_id == parent.hir_id)
})
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,7 @@ impl<'a> Parser<'a> {
/// If the user writes `S { ref field: name }` instead of `S { field: ref name }`, we suggest
/// the correct code.
fn recover_misplaced_pattern_modifiers(&self, fields: &ThinVec<PatField>, err: &mut Diag<'a>) {
if let Some(last) = fields.iter().last()
if let Some(last) = fields.last()
&& last.is_shorthand
&& let PatKind::Ident(binding, ident, None) = last.pat.kind
&& binding != BindingMode::NONE
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_resolve/src/diagnostics/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
for note in notes {
diag.note(note);
}
} else if let Some((_, UnresolvedImportError { note: Some(note), .. })) =
errors.iter().last()
{
} else if let Some((_, UnresolvedImportError { note: Some(note), .. })) = errors.last() {
diag.note(note.clone());
}

Expand Down Expand Up @@ -2876,7 +2874,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
if struct_expr.fields.is_empty() {
return;
}
let last_span = struct_expr.fields.iter().last().unwrap().span;
let last_span = struct_expr.fields.last().unwrap().span;
let mut iter = struct_expr.fields.iter().peekable();
let mut prev: Option<Span> = None;
while let Some(field) = iter.next() {
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4092,7 +4092,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
v.could_be_path = false;
}
self.report_error(
v.origin.iter().next().unwrap().0,
v.origin.first().unwrap().0,
ResolutionError::VariableNotBoundInPattern(v, self.parent_scope),
);
}
Expand Down Expand Up @@ -4757,8 +4757,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
self.resolve_path(&std_path, Some(ns), None, source)
{
// Check if we wrote `str::from_utf8` instead of `std::str::from_utf8`
let item_span =
path.iter().last().map_or(path_span, |segment| segment.ident.span);
let item_span = path.last().map_or(path_span, |segment| segment.ident.span);

self.r.confused_type_with_std_module.insert(item_span, path_span);
self.r.confused_type_with_std_module.insert(path_span, path_span);
Expand Down
Loading