Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce import / type code styles throughout the compiler. #59952

Closed
eddyb opened this issue Apr 13, 2019 · 4 comments · Fixed by #60317
Closed

Enforce import / type code styles throughout the compiler. #59952

eddyb opened this issue Apr 13, 2019 · 4 comments · Fixed by #60317
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@eddyb
Copy link
Member

eddyb commented Apr 13, 2019

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

@petrochenkov
Copy link
Contributor

petrochenkov commented Apr 14, 2019

cc #49509 (Add compiler-internal lints)

@jonas-schievink jonas-schievink added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 14, 2019
@oli-obk
Copy link
Contributor

oli-obk commented Apr 15, 2019

cc @flip1995

@flip1995
Copy link
Member

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

@flip1995
Copy link
Member

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)

bors added a commit that referenced this issue Apr 28, 2019
Internal lints: usage_of_qualified_ty & ty_pass_by_reference

Closes #59952

Implements internal lints:

- `USAGE_OF_QUALIFIED_TY`
- `TY_PASS_BY_REFERENCE`

r? @oli-obk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants