Skip to content

Commit d9ddce8

Browse files
committed
Auto merge of #8942 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents 8ef4908 + 36b1892 commit d9ddce8

25 files changed

+123
-80
lines changed

clippy_lints/src/casts/unnecessary_cast.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ use rustc_middle::ty::{self, FloatTy, InferTy, Ty};
1212

1313
use super::UNNECESSARY_CAST;
1414

15-
pub(super) fn check(
16-
cx: &LateContext<'_>,
17-
expr: &Expr<'_>,
18-
cast_expr: &Expr<'_>,
19-
cast_from: Ty<'_>,
20-
cast_to: Ty<'_>,
15+
pub(super) fn check<'tcx>(
16+
cx: &LateContext<'tcx>,
17+
expr: &Expr<'tcx>,
18+
cast_expr: &Expr<'tcx>,
19+
cast_from: Ty<'tcx>,
20+
cast_to: Ty<'tcx>,
2121
) -> bool {
2222
// skip non-primitive type cast
2323
if_chain! {

clippy_lints/src/crate_in_macro_def.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn contains_unhygienic_crate_reference(tts: &TokenStream) -> Option<Span> {
9090
while let Some(curr) = cursor.next() {
9191
if_chain! {
9292
if !prev_is_dollar;
93-
if let Some(span) = is_crate_keyword(&curr);
93+
if let Some(span) = is_crate_keyword(curr);
9494
if let Some(next) = cursor.look_ahead(0);
9595
if is_token(next, &TokenKind::ModSep);
9696
then {
@@ -103,7 +103,7 @@ fn contains_unhygienic_crate_reference(tts: &TokenStream) -> Option<Span> {
103103
return span;
104104
}
105105
}
106-
prev_is_dollar = is_token(&curr, &TokenKind::Dollar);
106+
prev_is_dollar = is_token(curr, &TokenKind::Dollar);
107107
}
108108
None
109109
}

clippy_lints/src/dereference.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ fn try_parse_ref_op<'tcx>(
446446

447447
// Checks whether the type for a deref call actually changed the type, not just the mutability of
448448
// the reference.
449-
fn deref_method_same_type(result_ty: Ty<'_>, arg_ty: Ty<'_>) -> bool {
449+
fn deref_method_same_type<'tcx>(result_ty: Ty<'tcx>, arg_ty: Ty<'tcx>) -> bool {
450450
match (result_ty.kind(), arg_ty.kind()) {
451451
(ty::Ref(_, result_ty, _), ty::Ref(_, arg_ty, _)) => result_ty == arg_ty,
452452

@@ -541,8 +541,8 @@ fn is_auto_borrow_position(parent: Option<Node<'_>>, child_id: HirId) -> bool {
541541
/// Adjustments are sometimes made in the parent block rather than the expression itself.
542542
fn find_adjustments<'tcx>(
543543
tcx: TyCtxt<'tcx>,
544-
typeck: &'tcx TypeckResults<'_>,
545-
expr: &'tcx Expr<'_>,
544+
typeck: &'tcx TypeckResults<'tcx>,
545+
expr: &'tcx Expr<'tcx>,
546546
) -> &'tcx [Adjustment<'tcx>] {
547547
let map = tcx.hir();
548548
let mut iter = map.parent_iter(expr.hir_id);
@@ -581,7 +581,7 @@ fn find_adjustments<'tcx>(
581581
}
582582

583583
#[expect(clippy::needless_pass_by_value)]
584-
fn report(cx: &LateContext<'_>, expr: &Expr<'_>, state: State, data: StateData) {
584+
fn report<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, state: State, data: StateData) {
585585
match state {
586586
State::DerefMethod {
587587
ty_changed_count,
@@ -656,7 +656,7 @@ fn report(cx: &LateContext<'_>, expr: &Expr<'_>, state: State, data: StateData)
656656
}
657657

658658
impl Dereferencing {
659-
fn check_local_usage(&mut self, cx: &LateContext<'_>, e: &Expr<'_>, local: HirId) {
659+
fn check_local_usage<'tcx>(&mut self, cx: &LateContext<'tcx>, e: &Expr<'tcx>, local: HirId) {
660660
if let Some(outer_pat) = self.ref_locals.get_mut(&local) {
661661
if let Some(pat) = outer_pat {
662662
// Check for auto-deref

clippy_lints/src/escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
189189
}
190190
}
191191

192-
fn fake_read(&mut self, _: rustc_typeck::expr_use_visitor::Place<'tcx>, _: FakeReadCause, _: HirId) {}
192+
fn fake_read(&mut self, _: &rustc_typeck::expr_use_visitor::PlaceWithHirId<'tcx>, _: FakeReadCause, _: HirId) {}
193193
}
194194

195195
impl<'a, 'tcx> EscapeDelegate<'a, 'tcx> {

clippy_lints/src/explicit_write.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ use clippy_utils::source::snippet_with_applicability;
44
use clippy_utils::{is_expn_of, match_function_call, paths};
55
use if_chain::if_chain;
66
use rustc_errors::Applicability;
7-
use rustc_hir::{Expr, ExprKind};
7+
use rustc_hir::def::Res;
8+
use rustc_hir::{BindingAnnotation, Block, BlockCheckMode, Expr, ExprKind, Node, PatKind, QPath, Stmt, StmtKind};
89
use rustc_lint::{LateContext, LateLintPass};
910
use rustc_session::{declare_lint_pass, declare_tool_lint};
1011
use rustc_span::sym;
@@ -47,7 +48,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitWrite {
4748
if let ExprKind::MethodCall(unwrap_fun, [write_call], _) = expr.kind;
4849
if unwrap_fun.ident.name == sym::unwrap;
4950
// match call to write_fmt
50-
if let ExprKind::MethodCall(write_fun, [write_recv, write_arg], _) = write_call.kind;
51+
if let ExprKind::MethodCall(write_fun, [write_recv, write_arg], _) = look_in_block(cx, &write_call.kind);
5152
if write_fun.ident.name == sym!(write_fmt);
5253
// match calls to std::io::stdout() / std::io::stderr ()
5354
if let Some(dest_name) = if match_function_call(cx, write_recv, &paths::STDOUT).is_some() {
@@ -108,3 +109,34 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitWrite {
108109
}
109110
}
110111
}
112+
113+
/// If `kind` is a block that looks like `{ let result = $expr; result }` then
114+
/// returns $expr. Otherwise returns `kind`.
115+
fn look_in_block<'tcx, 'hir>(cx: &LateContext<'tcx>, kind: &'tcx ExprKind<'hir>) -> &'tcx ExprKind<'hir> {
116+
if_chain! {
117+
if let ExprKind::Block(block, _label @ None) = kind;
118+
if let Block {
119+
stmts: [Stmt { kind: StmtKind::Local(local), .. }],
120+
expr: Some(expr_end_of_block),
121+
rules: BlockCheckMode::DefaultBlock,
122+
..
123+
} = block;
124+
125+
// Find id of the local that expr_end_of_block resolves to
126+
if let ExprKind::Path(QPath::Resolved(None, expr_path)) = expr_end_of_block.kind;
127+
if let Res::Local(expr_res) = expr_path.res;
128+
if let Some(Node::Binding(res_pat)) = cx.tcx.hir().find(expr_res);
129+
130+
// Find id of the local we found in the block
131+
if let PatKind::Binding(BindingAnnotation::Unannotated, local_hir_id, _ident, None) = local.pat.kind;
132+
133+
// If those two are the same hir id
134+
if res_pat.hir_id == local_hir_id;
135+
136+
if let Some(init) = local.init;
137+
then {
138+
return &init.kind;
139+
}
140+
}
141+
kind
142+
}

clippy_lints/src/len_zero.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ fn parse_len_output<'tcx>(cx: &LateContext<'_>, sig: FnSig<'tcx>) -> Option<LenO
259259
}
260260
}
261261

262-
impl LenOutput<'_> {
263-
fn matches_is_empty_output(self, ty: Ty<'_>) -> bool {
262+
impl<'tcx> LenOutput<'tcx> {
263+
fn matches_is_empty_output(self, ty: Ty<'tcx>) -> bool {
264264
match (self, ty.kind()) {
265265
(_, &ty::Bool) => true,
266266
(Self::Option(id), &ty::Adt(adt, subs)) if id == adt.did() => subs.type_at(0).is_bool(),
@@ -292,7 +292,7 @@ impl LenOutput<'_> {
292292
}
293293

294294
/// Checks if the given signature matches the expectations for `is_empty`
295-
fn check_is_empty_sig(sig: FnSig<'_>, self_kind: ImplicitSelfKind, len_output: LenOutput<'_>) -> bool {
295+
fn check_is_empty_sig<'tcx>(sig: FnSig<'tcx>, self_kind: ImplicitSelfKind, len_output: LenOutput<'tcx>) -> bool {
296296
match &**sig.inputs_and_output {
297297
[arg, res] if len_output.matches_is_empty_output(*res) => {
298298
matches!(
@@ -306,11 +306,11 @@ fn check_is_empty_sig(sig: FnSig<'_>, self_kind: ImplicitSelfKind, len_output: L
306306
}
307307

308308
/// Checks if the given type has an `is_empty` method with the appropriate signature.
309-
fn check_for_is_empty(
310-
cx: &LateContext<'_>,
309+
fn check_for_is_empty<'tcx>(
310+
cx: &LateContext<'tcx>,
311311
span: Span,
312312
self_kind: ImplicitSelfKind,
313-
output: LenOutput<'_>,
313+
output: LenOutput<'tcx>,
314314
impl_ty: DefId,
315315
item_name: Symbol,
316316
item_kind: &str,

clippy_lints/src/lifetimes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ impl<'a, 'tcx> RefVisitor<'a, 'tcx> {
371371
if let Some(ref lt) = *lifetime {
372372
if lt.name == LifetimeName::Static {
373373
self.lts.push(RefLt::Static);
374-
} else if let LifetimeName::Param(ParamName::Fresh(_)) = lt.name {
374+
} else if let LifetimeName::Param(_, ParamName::Fresh) = lt.name {
375375
// Fresh lifetimes generated should be ignored.
376376
} else if lt.is_elided() {
377377
self.lts.push(RefLt::Unnamed);

clippy_lints/src/loops/mut_range_bound.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
114114
}
115115
}
116116

117-
fn fake_read(&mut self, _: rustc_typeck::expr_use_visitor::Place<'tcx>, _: FakeReadCause, _: HirId) {}
117+
fn fake_read(&mut self, _: &rustc_typeck::expr_use_visitor::PlaceWithHirId<'tcx>, _: FakeReadCause, _: HirId) {}
118118
}
119119

120120
impl MutatePairDelegate<'_, '_> {

clippy_lints/src/loops/needless_range_loop.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ pub(super) fn check<'tcx>(
117117
let take_expr = sugg::Sugg::hir(cx, take_expr, "<count>");
118118
format!(".take({})", take_expr + sugg::ONE)
119119
},
120-
ast::RangeLimits::HalfOpen => format!(".take({})", snippet(cx, take_expr.span, "..")),
120+
ast::RangeLimits::HalfOpen => {
121+
format!(".take({})", snippet(cx, take_expr.span, ".."))
122+
},
121123
}
122124
}
123125
} else {
@@ -262,7 +264,11 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
262264
match res {
263265
Res::Local(hir_id) => {
264266
let parent_def_id = self.cx.tcx.hir().get_parent_item(expr.hir_id);
265-
let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id).unwrap();
267+
let extent = self.cx
268+
.tcx
269+
.region_scope_tree(parent_def_id)
270+
.var_scope(hir_id.local_id)
271+
.unwrap();
266272
if index_used_directly {
267273
self.indexed_directly.insert(
268274
seqvar.segments[0].ident.name,

clippy_lints/src/manual_non_exhaustive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl EarlyLintPass for ManualNonExhaustiveStruct {
113113
let mut iter = fields.iter().filter_map(|f| match f.vis.kind {
114114
VisibilityKind::Public => None,
115115
VisibilityKind::Inherited => Some(Ok(f)),
116-
_ => Some(Err(())),
116+
VisibilityKind::Restricted { .. } => Some(Err(())),
117117
});
118118
if let Some(Ok(field)) = iter.next()
119119
&& iter.next().is_none()

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2882,7 +2882,7 @@ enum SelfKind {
28822882

28832883
impl SelfKind {
28842884
fn matches<'a>(self, cx: &LateContext<'a>, parent_ty: Ty<'a>, ty: Ty<'a>) -> bool {
2885-
fn matches_value<'a>(cx: &LateContext<'a>, parent_ty: Ty<'_>, ty: Ty<'_>) -> bool {
2885+
fn matches_value<'a>(cx: &LateContext<'a>, parent_ty: Ty<'a>, ty: Ty<'a>) -> bool {
28862886
if ty == parent_ty {
28872887
true
28882888
} else if ty.is_box() {

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,5 +343,5 @@ impl<'tcx> euv::Delegate<'tcx> for MovedVariablesCtxt {
343343

344344
fn mutate(&mut self, _: &euv::PlaceWithHirId<'tcx>, _: HirId) {}
345345

346-
fn fake_read(&mut self, _: rustc_typeck::expr_use_visitor::Place<'tcx>, _: FakeReadCause, _: HirId) {}
346+
fn fake_read(&mut self, _: &rustc_typeck::expr_use_visitor::PlaceWithHirId<'tcx>, _: FakeReadCause, _: HirId) {}
347347
}

clippy_lints/src/ptr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl fmt::Display for RefPrefix {
343343
use fmt::Write;
344344
f.write_char('&')?;
345345
match self.lt {
346-
LifetimeName::Param(ParamName::Plain(name)) => {
346+
LifetimeName::Param(_, ParamName::Plain(name)) => {
347347
name.fmt(f)?;
348348
f.write_char(' ')?;
349349
},
@@ -395,9 +395,9 @@ impl<'tcx> DerefTy<'tcx> {
395395

396396
fn check_fn_args<'cx, 'tcx: 'cx>(
397397
cx: &'cx LateContext<'tcx>,
398-
tys: &'tcx [Ty<'_>],
399-
hir_tys: &'tcx [hir::Ty<'_>],
400-
params: &'tcx [Param<'_>],
398+
tys: &'tcx [Ty<'tcx>],
399+
hir_tys: &'tcx [hir::Ty<'tcx>],
400+
params: &'tcx [Param<'tcx>],
401401
) -> impl Iterator<Item = PtrArg<'tcx>> + 'cx {
402402
tys.iter()
403403
.zip(hir_tys.iter())

clippy_lints/src/redundant_clone.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ fn is_call_with_ref_arg<'tcx>(
292292
if let (inner_ty, 1) = walk_ptrs_ty_depth(args[0].ty(mir, cx.tcx));
293293
if !is_copy(cx, inner_ty);
294294
then {
295-
Some((def_id, *local, inner_ty, destination.as_ref().map(|(dest, _)| dest)?.as_local()?))
295+
Some((def_id, *local, inner_ty, destination.as_local()?))
296296
} else {
297297
None
298298
}
@@ -584,7 +584,7 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
584584
fn visit_terminator(&mut self, terminator: &mir::Terminator<'_>, _loc: mir::Location) {
585585
if let mir::TerminatorKind::Call {
586586
args,
587-
destination: Some((mir::Place { local: dest, .. }, _)),
587+
destination: mir::Place { local: dest, .. },
588588
..
589589
} = &terminator.kind
590590
{

clippy_lints/src/transmute/transmute_undefined_repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ fn is_size_pair(ty: Ty<'_>) -> bool {
358358
}
359359
}
360360

361-
fn same_except_params(subs1: SubstsRef<'_>, subs2: SubstsRef<'_>) -> bool {
361+
fn same_except_params<'tcx>(subs1: SubstsRef<'tcx>, subs2: SubstsRef<'tcx>) -> bool {
362362
// TODO: check const parameters as well. Currently this will consider `Array<5>` the same as
363363
// `Array<6>`
364364
for (ty1, ty2) in subs1.types().zip(subs2.types()).filter(|(ty1, ty2)| ty1 != ty2) {

clippy_lints/src/undocumented_unsafe_blocks.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,13 @@ fn item_has_safety_comment(cx: &LateContext<'_>, item: &hir::Item<'_>) -> bool {
187187
&& Lrc::ptr_eq(&unsafe_line.sf, &comment_start_line.sf)
188188
&& let Some(src) = unsafe_line.sf.src.as_deref()
189189
{
190-
comment_start_line.line < unsafe_line.line && text_has_safety_comment(
191-
src,
192-
&unsafe_line.sf.lines[comment_start_line.line + 1..=unsafe_line.line],
193-
unsafe_line.sf.start_pos.to_usize(),
194-
)
190+
unsafe_line.sf.lines(|lines| {
191+
comment_start_line.line < unsafe_line.line && text_has_safety_comment(
192+
src,
193+
&lines[comment_start_line.line + 1..=unsafe_line.line],
194+
unsafe_line.sf.start_pos.to_usize(),
195+
)
196+
})
195197
} else {
196198
// Problem getting source text. Pretend a comment was found.
197199
true
@@ -249,11 +251,13 @@ fn span_from_macro_expansion_has_safety_comment(cx: &LateContext<'_>, span: Span
249251
&& Lrc::ptr_eq(&unsafe_line.sf, &macro_line.sf)
250252
&& let Some(src) = unsafe_line.sf.src.as_deref()
251253
{
252-
macro_line.line < unsafe_line.line && text_has_safety_comment(
253-
src,
254-
&unsafe_line.sf.lines[macro_line.line + 1..=unsafe_line.line],
255-
unsafe_line.sf.start_pos.to_usize(),
256-
)
254+
unsafe_line.sf.lines(|lines| {
255+
macro_line.line < unsafe_line.line && text_has_safety_comment(
256+
src,
257+
&lines[macro_line.line + 1..=unsafe_line.line],
258+
unsafe_line.sf.start_pos.to_usize(),
259+
)
260+
})
257261
} else {
258262
// Problem getting source text. Pretend a comment was found.
259263
true
@@ -276,11 +280,13 @@ fn span_in_body_has_safety_comment(cx: &LateContext<'_>, span: Span) -> bool {
276280
// Get the text from the start of function body to the unsafe block.
277281
// fn foo() { some_stuff; unsafe { stuff }; other_stuff; }
278282
// ^-------------^
279-
body_line.line < unsafe_line.line && text_has_safety_comment(
280-
src,
281-
&unsafe_line.sf.lines[body_line.line + 1..=unsafe_line.line],
282-
unsafe_line.sf.start_pos.to_usize(),
283-
)
283+
unsafe_line.sf.lines(|lines| {
284+
body_line.line < unsafe_line.line && text_has_safety_comment(
285+
src,
286+
&lines[body_line.line + 1..=unsafe_line.line],
287+
unsafe_line.sf.start_pos.to_usize(),
288+
)
289+
})
284290
} else {
285291
// Problem getting source text. Pretend a comment was found.
286292
true

clippy_utils/src/ast_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ pub fn eq_defaultness(l: Defaultness, r: Defaultness) -> bool {
545545
pub fn eq_vis(l: &Visibility, r: &Visibility) -> bool {
546546
use VisibilityKind::*;
547547
match (&l.kind, &r.kind) {
548-
(Public, Public) | (Inherited, Inherited) | (Crate(_), Crate(_)) => true,
548+
(Public, Public) | (Inherited, Inherited) => true,
549549
(Restricted { path: l, .. }, Restricted { path: r, .. }) => eq_path(l, r),
550550
_ => false,
551551
}

clippy_utils/src/diagnostics.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,11 @@ pub fn span_lint_and_sugg_for_edges(
274274
let sm = cx.sess().source_map();
275275
if let (Ok(line_upper), Ok(line_bottom)) = (sm.lookup_line(sp.lo()), sm.lookup_line(sp.hi())) {
276276
let split_idx = MAX_SUGGESTION_HIGHLIGHT_LINES / 2;
277-
let span_upper = sm.span_until_char(sp.with_hi(line_upper.sf.lines[line_upper.line + split_idx]), '\n');
278-
let span_bottom = sp.with_lo(line_bottom.sf.lines[line_bottom.line - split_idx]);
277+
let span_upper = sm.span_until_char(
278+
sp.with_hi(line_upper.sf.lines(|lines| lines[line_upper.line + split_idx])),
279+
'\n',
280+
);
281+
let span_bottom = sp.with_lo(line_bottom.sf.lines(|lines| lines[line_bottom.line - split_idx]));
279282

280283
let sugg_lines_vec = sugg.lines().collect::<Vec<&str>>();
281284
let sugg_upper = sugg_lines_vec[..split_idx].join("\n");

clippy_utils/src/hir_utils.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -902,16 +902,14 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
902902

903903
pub fn hash_lifetime(&mut self, lifetime: Lifetime) {
904904
std::mem::discriminant(&lifetime.name).hash(&mut self.s);
905-
if let LifetimeName::Param(ref name) = lifetime.name {
905+
if let LifetimeName::Param(param_id, ref name) = lifetime.name {
906906
std::mem::discriminant(name).hash(&mut self.s);
907+
param_id.hash(&mut self.s);
907908
match name {
908909
ParamName::Plain(ref ident) => {
909910
ident.name.hash(&mut self.s);
910911
},
911-
ParamName::Fresh(ref size) => {
912-
size.hash(&mut self.s);
913-
},
914-
ParamName::Error => {},
912+
ParamName::Fresh | ParamName::Error => {},
915913
}
916914
}
917915
}

clippy_utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ fn line_span<T: LintContext>(cx: &T, span: Span) -> Span {
11491149
let span = original_sp(span, DUMMY_SP);
11501150
let source_map_and_line = cx.sess().source_map().lookup_line(span.lo()).unwrap();
11511151
let line_no = source_map_and_line.line;
1152-
let line_start = source_map_and_line.sf.lines[line_no];
1152+
let line_start = source_map_and_line.sf.lines(|lines| lines[line_no]);
11531153
span.with_lo(line_start)
11541154
}
11551155

0 commit comments

Comments
 (0)