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

Lints should be initialized via derived Default wherever possible #60181

Closed
stepnivlk opened this issue Apr 22, 2019 · 0 comments · Fixed by #60259
Closed

Lints should be initialized via derived Default wherever possible #60181

stepnivlk opened this issue Apr 22, 2019 · 0 comments · Fixed by #60259
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@stepnivlk
Copy link
Contributor

stepnivlk commented Apr 22, 2019

As mentioned in this PR #60152 all the lints implementing new to just return Self with empty/default values should use #[derive(Default)] instead to achieve semantic compression.

Example of such a lint
https://github.com/rust-lang/rust/blob/master/src/librustc_lint/builtin.rs#L553
Lint is then instantiated here
https://github.com/rust-lang/rust/blob/master/src/librustc_lint/lib.rs#L135

@jonas-schievink jonas-schievink added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Apr 22, 2019
Centril added a commit to Centril/rust that referenced this issue Apr 25, 2019
…, r=Centril

Derive Default instead of new in applicable lint

Closes rust-lang#60181

As far as I can see, at least within the `src/librustc_lint` directory this is the only place this is applicable.
Centril added a commit to Centril/rust that referenced this issue Apr 25, 2019
…, r=Centril

Derive Default instead of new in applicable lint

Closes rust-lang#60181

As far as I can see, at least within the `src/librustc_lint` directory this is the only place this is applicable.
Centril added a commit to Centril/rust that referenced this issue Apr 26, 2019
…, r=Centril

Derive Default instead of new in applicable lint

Closes rust-lang#60181

As far as I can see, at least within the `src/librustc_lint` directory this is the only place this is applicable.
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. C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. 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.

2 participants