Skip to content

Commit d73d0b1

Browse files
Use vec rather than mutable slice
1 parent ebcf860 commit d73d0b1

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
@@ -302,12 +302,12 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
302302
// `check_foo` method in `$methods` within this pass simply calls `check_foo`
303303
// once per `$pass`. Compare with `declare_combined_late_lint_pass`, which is
304304
// similar, but combines lint passes at compile time.
305-
struct RuntimeCombinedLateLintPass<'a, 'tcx> {
306-
passes: &'a mut [LateLintPassObject<'tcx>],
305+
struct RuntimeCombinedLateLintPass<'tcx> {
306+
passes: Vec<LateLintPassObject<'tcx>>,
307307
}
308308

309309
#[allow(rustc::lint_pass_impl_without_macro)]
310-
impl LintPass for RuntimeCombinedLateLintPass<'_, '_> {
310+
impl LintPass for RuntimeCombinedLateLintPass<'_> {
311311
fn name(&self) -> &'static str {
312312
panic!()
313313
}
@@ -318,7 +318,7 @@ impl LintPass for RuntimeCombinedLateLintPass<'_, '_> {
318318

319319
macro_rules! impl_late_lint_pass {
320320
([], [$($(#[$attr:meta])* fn $f:ident($($param:ident: $arg:ty),*);)*]) => {
321-
impl<'tcx> LateLintPass<'tcx> for RuntimeCombinedLateLintPass<'_, 'tcx> {
321+
impl<'tcx> LateLintPass<'tcx> for RuntimeCombinedLateLintPass<'tcx> {
322322
$(fn $f(&mut self, context: &LateContext<'tcx>, $($param: $arg),*) {
323323
for pass in self.passes.iter_mut() {
324324
pass.$f(context, $($param),*);
@@ -355,14 +355,14 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
355355
late_lint_mod_inner(tcx, module_def_id, context, builtin_lints);
356356
} else {
357357
let builtin_lints = Box::new(builtin_lints) as Box<dyn LateLintPass<'tcx>>;
358-
let mut binding = store
358+
let passes = store
359359
.late_module_passes
360360
.iter()
361361
.map(|mk_pass| (mk_pass)(tcx))
362362
.chain(std::iter::once(builtin_lints))
363363
.collect::<Vec<_>>();
364364

365-
let pass = RuntimeCombinedLateLintPass { passes: binding.as_mut_slice() };
365+
let pass = RuntimeCombinedLateLintPass { passes };
366366
late_lint_mod_inner(tcx, module_def_id, context, pass);
367367
}
368368
}
@@ -393,10 +393,10 @@ fn late_lint_mod_inner<'tcx, T: LateLintPass<'tcx>>(
393393

394394
fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) {
395395
// Note: `passes` is often empty.
396-
let passes: Vec<_> =
396+
let unfiltered_passes: Vec<_> =
397397
unerased_lint_store(tcx.sess).late_passes.iter().map(|mk_pass| (mk_pass)(tcx)).collect();
398398

399-
if passes.is_empty() {
399+
if unfiltered_passes.is_empty() {
400400
return;
401401
}
402402

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

414414
let lints_that_dont_need_to_run = tcx.lints_that_dont_need_to_run(());
415415

416-
let mut filtered_passes: Vec<Box<dyn LateLintPass<'tcx>>> = passes
416+
let mut passes: Vec<Box<dyn LateLintPass<'tcx>>> = unfiltered_passes
417417
.into_iter()
418418
.filter(|pass| {
419419
let lints = (**pass).get_lints();
@@ -424,8 +424,8 @@ fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) {
424424
})
425425
.collect();
426426

427-
filtered_passes.push(Box::new(HardwiredLints));
428-
let pass = RuntimeCombinedLateLintPass { passes: &mut filtered_passes[..] };
427+
passes.push(Box::new(HardwiredLints));
428+
let pass = RuntimeCombinedLateLintPass { passes };
429429
late_lint_crate_inner(tcx, context, pass);
430430
}
431431

0 commit comments

Comments
 (0)