forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#54683 - zackmdavis:critique_of_pure_lints, …
…r=petrochenkov lint reasons (RFC 2883, part 1) This implements the `reason =` functionality described in [the RFC](https://github.com/rust-lang/rfcs/blob/master/text/2383-lint-reasons.md) under a `lint_reasons` feature gate. ![lint_reasons_pt_1](https://user-images.githubusercontent.com/1076988/46252097-eed51000-c418-11e8-8212-939d3f02f95d.png)
- Loading branch information
Showing
12 changed files
with
304 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#![warn(nonstandard_style, reason = "the standard should be respected")] | ||
//~^ ERROR lint reasons are experimental | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
src/test/ui/feature-gates/feature-gate-lint-reasons.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0658]: lint reasons are experimental (see issue #54503) | ||
--> $DIR/feature-gate-lint-reasons.rs:1:28 | ||
| | ||
LL | #![warn(nonstandard_style, reason = "the standard should be respected")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: add #![feature(lint_reasons)] to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#![feature(lint_reasons)] | ||
|
||
// run-pass | ||
|
||
// Empty (and reason-only) lint attributes are legal—although we may want to | ||
// lint them in the future (Issue #55112). | ||
|
||
#![allow()] | ||
#![warn(reason = "observationalism")] | ||
|
||
#[forbid()] | ||
fn devoir() {} | ||
|
||
#[deny(reason = "ultion")] | ||
fn waldgrave() {} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#![feature(lint_reasons)] | ||
|
||
#![warn(absolute_paths_not_starting_with_crate, reason = 0)] | ||
//~^ ERROR malformed lint attribute | ||
//~| HELP reason must be a string literal | ||
#![warn(anonymous_parameters, reason = b"consider these, for we have condemned them")] | ||
//~^ ERROR malformed lint attribute | ||
//~| HELP reason must be a string literal | ||
#![warn(bare_trait_objects, reasons = "leaders to no sure land, guides their bearings lost")] | ||
//~^ ERROR malformed lint attribute | ||
#![warn(box_pointers, blerp = "or in league with robbers have reversed the signposts")] | ||
//~^ ERROR malformed lint attribute | ||
#![warn(elided_lifetimes_in_paths, reason("disrespectful to ancestors", "irresponsible to heirs"))] | ||
//~^ ERROR malformed lint attribute | ||
#![warn(ellipsis_inclusive_range_patterns, reason = "born barren", reason = "a freak growth")] | ||
//~^ ERROR malformed lint attribute | ||
//~| HELP reason in lint attribute must come last | ||
#![warn(keyword_idents, reason = "root in rubble", macro_use_extern_crate)] | ||
//~^ ERROR malformed lint attribute | ||
//~| HELP reason in lint attribute must come last | ||
#![warn(missing_copy_implementations, reason)] | ||
//~^ WARN unknown lint | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
error[E0452]: malformed lint attribute | ||
--> $DIR/reasons-erroneous.rs:3:58 | ||
| | ||
LL | #![warn(absolute_paths_not_starting_with_crate, reason = 0)] | ||
| ^ | ||
| | ||
= help: reason must be a string literal | ||
|
||
error[E0452]: malformed lint attribute | ||
--> $DIR/reasons-erroneous.rs:6:40 | ||
| | ||
LL | #![warn(anonymous_parameters, reason = b"consider these, for we have condemned them")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: reason must be a string literal | ||
|
||
error[E0452]: malformed lint attribute | ||
--> $DIR/reasons-erroneous.rs:9:29 | ||
| | ||
LL | #![warn(bare_trait_objects, reasons = "leaders to no sure land, guides their bearings lost")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0452]: malformed lint attribute | ||
--> $DIR/reasons-erroneous.rs:11:23 | ||
| | ||
LL | #![warn(box_pointers, blerp = "or in league with robbers have reversed the signposts")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0452]: malformed lint attribute | ||
--> $DIR/reasons-erroneous.rs:13:36 | ||
| | ||
LL | #![warn(elided_lifetimes_in_paths, reason("disrespectful to ancestors", "irresponsible to heirs"))] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0452]: malformed lint attribute | ||
--> $DIR/reasons-erroneous.rs:15:44 | ||
| | ||
LL | #![warn(ellipsis_inclusive_range_patterns, reason = "born barren", reason = "a freak growth")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: reason in lint attribute must come last | ||
|
||
error[E0452]: malformed lint attribute | ||
--> $DIR/reasons-erroneous.rs:18:25 | ||
| | ||
LL | #![warn(keyword_idents, reason = "root in rubble", macro_use_extern_crate)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: reason in lint attribute must come last | ||
|
||
warning: unknown lint: `reason` | ||
--> $DIR/reasons-erroneous.rs:21:39 | ||
| | ||
LL | #![warn(missing_copy_implementations, reason)] | ||
| ^^^^^^ | ||
| | ||
= note: #[warn(unknown_lints)] on by default | ||
|
||
error: aborting due to 7 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0452`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#![feature(lint_reasons)] | ||
|
||
#![forbid( | ||
unsafe_code, | ||
//~^ NOTE `forbid` level set here | ||
reason = "our errors & omissions insurance policy doesn't cover unsafe Rust" | ||
)] | ||
|
||
use std::ptr; | ||
|
||
fn main() { | ||
let a_billion_dollar_mistake = ptr::null(); | ||
|
||
#[allow(unsafe_code)] | ||
//~^ ERROR allow(unsafe_code) overruled by outer forbid(unsafe_code) | ||
//~| NOTE overruled by previous forbid | ||
//~| NOTE our errors & omissions insurance policy doesn't cover unsafe Rust | ||
unsafe { | ||
*a_billion_dollar_mistake | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0453]: allow(unsafe_code) overruled by outer forbid(unsafe_code) | ||
--> $DIR/reasons-forbidden.rs:14:13 | ||
| | ||
LL | unsafe_code, | ||
| ----------- `forbid` level set here | ||
... | ||
LL | #[allow(unsafe_code)] | ||
| ^^^^^^^^^^^ overruled by previous forbid | ||
| | ||
= note: our errors & omissions insurance policy doesn't cover unsafe Rust | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0453`. |
Oops, something went wrong.