diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-03 22:33:19 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-11-06 11:10:37 +0100 |
| commit | 574d2b83a16dbbe975bbb3cf2ed541563a2f756c (patch) | |
| tree | 548ff7b26b461935a5db1921b6eb8700b7af5882 | |
| parent | a12e69d62798a4fb894209b249e16a6eda7c0d0f (diff) | |
| download | rust-574d2b83a16dbbe975bbb3cf2ed541563a2f756c.tar.gz rust-574d2b83a16dbbe975bbb3cf2ed541563a2f756c.zip | |
patterns_in_fns_without_body -> deny
| -rw-r--r-- | src/doc/rustc/src/lints/listing/deny-by-default.md | 40 | ||||
| -rw-r--r-- | src/doc/rustc/src/lints/listing/warn-by-default.md | 40 | ||||
| -rw-r--r-- | src/librustc/lint/builtin.rs | 2 |
3 files changed, 41 insertions, 41 deletions
diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index 466a748bcee..dc5a9e44acf 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -122,6 +122,46 @@ error: literal out of range for u8 | ``` +## patterns-in-fns-without-body + +This lint detects patterns in functions without body were that were +previously erroneously allowed. Some example code that triggers this lint: + +```rust,compile_fail +trait Trait { + fn foo(mut arg: u8); +} +``` + +This will produce: + +```text +warning: patterns aren't allowed in methods without bodies + --> src/main.rs:2:12 + | +2 | fn foo(mut arg: u8); + | ^^^^^^^ + | + = note: `#[warn(patterns_in_fns_without_body)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #35203 <https://github.com/rust-lang/rust/issues/35203> +``` + +To fix this, remove the pattern; it can be used in the implementation without +being used in the definition. That is: + +```rust +trait Trait { + fn foo(arg: u8); +} + +impl Trait for i32 { + fn foo(mut arg: u8) { + + } +} +``` + ## pub-use-of-private-extern-crate This lint detects a specific situation of re-exporting a private `extern crate`; diff --git a/src/doc/rustc/src/lints/listing/warn-by-default.md b/src/doc/rustc/src/lints/listing/warn-by-default.md index 813d7c4bafe..77642a850fa 100644 --- a/src/doc/rustc/src/lints/listing/warn-by-default.md +++ b/src/doc/rustc/src/lints/listing/warn-by-default.md @@ -307,46 +307,6 @@ warning: path statement with no effect | ``` -## patterns-in-fns-without-body - -This lint detects patterns in functions without body were that were -previously erroneously allowed. Some example code that triggers this lint: - -```rust -trait Trait { - fn foo(mut arg: u8); -} -``` - -This will produce: - -```text -warning: patterns aren't allowed in methods without bodies - --> src/main.rs:2:12 - | -2 | fn foo(mut arg: u8); - | ^^^^^^^ - | - = note: `#[warn(patterns_in_fns_without_body)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #35203 <https://github.com/rust-lang/rust/issues/35203> -``` - -To fix this, remove the pattern; it can be used in the implementation without -being used in the definition. That is: - -```rust -trait Trait { - fn foo(arg: u8); -} - -impl Trait for i32 { - fn foo(mut arg: u8) { - - } -} -``` - ## plugin-as-library This lint detects when compiler plugins are used as ordinary library in diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index baa1075e6b3..f8a592d22c1 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -189,7 +189,7 @@ declare_lint! { declare_lint! { pub PATTERNS_IN_FNS_WITHOUT_BODY, - Warn, + Deny, "patterns in functions without body were erroneously allowed", @future_incompatible = FutureIncompatibleInfo { reference: "issue #35203 <https://github.com/rust-lang/rust/issues/35203>", |
