Rust: Enforce import / type code styles throughout the compiler.

Created on 14 Apr 2019  路  4Comments  路  Source: rust-lang/rust

We've had a few large-scale cleanup PRs before, but it doesn't always stick.
This is a quick example of what I'm referring to (as the agreed-upon style):

use rustc::ty::{Ty, TyCtxt};
fn foo(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) {...}

TyCtxt and Ty are referred to unqualified (without ty::) and passed by value.
(Note that types can be behind & due to a trait, but that should be the only exception to the rule)

Currently both &TyCtxt and &Ty<'tcx> show up in the codebase (although in small quantities), but I only accidentally noticed and I won't be replacing them any time soon (someone else can, if they want to, but I'm more interested in how we keep this from happening - maybe with clippy?).

cc @rust-lang/compiler

A-lint T-compiler

Most helpful comment

I'll write internal lints for these two cases. I try to open a PR by the end of this week.

All 4 comments

cc https://github.com/rust-lang/rust/issues/49509 (Add compiler-internal lints)

cc @flip1995

I'll write internal lints for these two cases. I try to open a PR by the end of this week.

Quick update on this:
The lint writing is done: https://github.com/flip1995/rust/commits/internal_lints

Now I have to fix the findings of the lints. This may take a little bit of time (I had to touch 18 files for librustc alone)

Was this page helpful?
0 / 5 - 0 ratings