Skip to content

Commit 4b6dfc2

Browse files
Use vec rather than mutable slice
1 parent 0b63477 commit 4b6dfc2

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

compiler/rustc_lint/src/late.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,12 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
307307
// `check_foo` method in `$methods` within this pass simply calls `check_foo`
308308
// once per `$pass`. Compare with `declare_combined_late_lint_pass`, which is
309309
// similar, but combines lint passes at compile time.
310-
struct RuntimeCombinedLateLintPass<'a, 'tcx> {
311-
passes: &'a mut [LateLintPassObject<'tcx>],
310+
struct RuntimeCombinedLateLintPass<'tcx> {
311+
passes: Vec<LateLintPassObject<'tcx>>,
312312
}
313313

314314
#[allow(rustc::lint_pass_impl_without_macro)]
315-
impl LintPass for RuntimeCombinedLateLintPass<'_, '_> {
315+
impl LintPass for RuntimeCombinedLateLintPass<'_> {
316316
fn name(&self) -> &'static str {
317317
panic!()
318318
}
@@ -323,7 +323,7 @@ impl LintPass for RuntimeCombinedLateLintPass<'_, '_> {
323323

324324
macro_rules! impl_late_lint_pass {
325325
([], [$($(#[$attr:meta])* fn $f:ident($($param:ident: $arg:ty),*);)*]) => {
326-
impl<'tcx> LateLintPass<'tcx> for RuntimeCombinedLateLintPass<'_, 'tcx> {
326+
impl<'tcx> LateLintPass<'tcx> for RuntimeCombinedLateLintPass<'tcx> {
327327
$(fn $f(&mut self, context: &LateContext<'tcx>, $($param: $arg),*) {
328328
for pass in self.passes.iter_mut() {
329329
pass.$f(context, $($param),*);
@@ -360,14 +360,14 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
360360
late_lint_mod_inner(tcx, module_def_id, context, builtin_lints);
361361
} else {
362362
let builtin_lints = Box::new(builtin_lints) as Box<dyn LateLintPass<'tcx>>;
363-
let mut binding = store
363+
let passes = store
364364
.late_module_passes
365365
.iter()
366366
.map(|mk_pass| (mk_pass)(tcx))
367367
.chain(std::iter::once(builtin_lints))
368368
.collect::<Vec<_>>();
369369

370-
let pass = RuntimeCombinedLateLintPass { passes: binding.as_mut_slice() };
370+
let pass = RuntimeCombinedLateLintPass { passes };
371371
late_lint_mod_inner(tcx, module_def_id, context, pass);
372372
}
373373
}
@@ -398,10 +398,10 @@ fn late_lint_mod_inner<'tcx, T: LateLintPass<'tcx>>(
398398

399399
fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) {
400400
// Note: `passes` is often empty.
401-
let passes: Vec<_> =
401+
let unfiltered_passes: Vec<_> =
402402
unerased_lint_store(tcx.sess).late_passes.iter().map(|mk_pass| (mk_pass)(tcx)).collect();
403403

404-
if passes.is_empty() {
404+
if unfiltered_passes.is_empty() {
405405
return;
406406
}
407407

@@ -418,7 +418,7 @@ fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) {
418418

419419
let lints_that_dont_need_to_run = tcx.lints_that_dont_need_to_run(());
420420

421-
let mut filtered_passes: Vec<Box<dyn LateLintPass<'tcx>>> = passes
421+
let mut passes: Vec<Box<dyn LateLintPass<'tcx>>> = unfiltered_passes
422422
.into_iter()
423423
.filter(|pass| {
424424
let lints = (**pass).get_lints();
@@ -429,8 +429,8 @@ fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) {
429429
})
430430
.collect();
431431

432-
filtered_passes.push(Box::new(HardwiredLints));
433-
let pass = RuntimeCombinedLateLintPass { passes: &mut filtered_passes[..] };
432+
passes.push(Box::new(HardwiredLints));
433+
let pass = RuntimeCombinedLateLintPass { passes };
434434
late_lint_crate_inner(tcx, context, pass);
435435
}
436436

0 commit comments

Comments
 (0)