Skip to content

Commit

Permalink
patterns_in_fns_without_body -> deny
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Nov 6, 2019
1 parent a12e69d commit 574d2b8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
40 changes: 40 additions & 0 deletions src/doc/rustc/src/lints/listing/deny-by-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down
40 changes: 0 additions & 40 deletions src/doc/rustc/src/lints/listing/warn-by-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>",
Expand Down

0 comments on commit 574d2b8

Please sign in to comment.