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

Prohibit patterns in trait methods without bodies #37378

Merged
merged 2 commits into from Oct 29, 2016

Conversation

Projects
None yet
7 participants
@petrochenkov
Copy link
Contributor

petrochenkov commented Oct 24, 2016

They are not properly type checked

trait Tr {
    fn f(&a: u8); // <- This compiles
}

, mostly rejected by the parser already and generally don't make much sense.
This PR is kind of a missing part of #35015.

Given the statistics from crater, the effect of this PR is mostly equivalent to improving unused_mut lint.

cc #35078 (comment) #35015 rust-lang/rfcs#1685 #35203
r? @eddyb

@eddyb

This comment has been minimized.

Copy link
Member

eddyb commented Oct 24, 2016

Started crater run.

@eddyb

This comment has been minimized.

Copy link
Member

eddyb commented Oct 24, 2016

Crater run looks pretty bad (177 root regressions).

@petrochenkov petrochenkov force-pushed the petrochenkov:nopat branch from f4cc508 to e41f9c9 Oct 24, 2016

@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Oct 24, 2016

Something is wrong with root/non-root partitioning in crater.
Two very popular crates - rustc-serialize and num-traits have this problem, most of others seem to break because of these dependencies.
I turned the error into a deny-by-default lint, @eddyb can you run crater once more to determine the real number of root regressions? (Unless you think it's waste of resources.)

Anyway, it looks like we can't make this an error in the nearest future, but I still hope to proceed with a warn-by-default lint.

@eddyb

This comment has been minimized.

Copy link
Member

eddyb commented Oct 24, 2016

@petrochenkov Maybe they don't show themselves? They might be broken or missing?

EDIT: started a second run, only on the "after" half.

homu added a commit to rust-num/num that referenced this pull request Oct 24, 2016

Auto merge of #238 - bluss:fix-mut, r=cuviper
traits: Remove pattern in trait's method signature

This use of `mut` was nonsensical for now, but is proposed to be
disallowed by rustc in the future (as a bugfix).

See rust-lang/rust/pull/37378 for context.
@eddyb

This comment has been minimized.

Copy link
Member

eddyb commented Oct 25, 2016

Second crater report shows only 22 root regressions.

@petrochenkov petrochenkov force-pushed the petrochenkov:nopat branch from e41f9c9 to 82d4200 Oct 25, 2016

@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Oct 25, 2016

mut arg - 19 crates (if only unused_mut worked in this context...).
&arg - 3 crates.

I've updated the PR with warning-by-default and tracking issue number.
Also #35203 needs to be reopened (I have no rights to do it).

@eddyb

This comment has been minimized.

Copy link
Member

eddyb commented Oct 25, 2016

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 25, 2016

📌 Commit 82d4200 has been approved by eddyb

Manishearth added a commit to Manishearth/rust that referenced this pull request Oct 26, 2016

Rollup merge of rust-lang#37378 - petrochenkov:nopat, r=eddyb
Prohibit patterns in trait methods without bodies

They are not properly type checked
```rust
trait Tr {
    fn f(&a: u8); // <- This compiles
}
```
, mostly rejected by the parser already and generally don't make much sense.
This PR is kind of a missing part of rust-lang#35015.

Needs crater run.
cc rust-lang#35078 (comment) rust-lang#35015 rust-lang/rfcs#1685 rust-lang#35203
r? @eddyb

Manishearth added a commit to Manishearth/rust that referenced this pull request Oct 26, 2016

@Manishearth

This comment has been minimized.

Copy link
Member

Manishearth commented Oct 26, 2016

Fails tidy, d230a7e

@TimNN

This comment has been minimized.

Copy link
Contributor

TimNN commented Oct 26, 2016

The used error code (E0570) has been merged by a different PR (#36421) since this PR was opened (thus this PR currently fails travis when merged).

@@ -228,4 +228,5 @@ pub impl Foo for Bar {
register_diagnostics! {
E0472, // asm! is unsupported on this target
E0561, // patterns aren't allowed in function pointer types
E0570, // patterns aren't allowed in methods without bodies

This comment has been minimized.

@Manishearth

Manishearth Oct 26, 2016

Member

This seems to be unused?

bors added a commit that referenced this pull request Oct 26, 2016

Auto merge of #37416 - Manishearth:rollup, r=Manishearth
Rollup of 11 pull requests

- Successful merges: #37144, #37315, #37350, #37367, #37373, #37378, #37385, #37387, #37389, #37391, #37399
- Failed merges:
@retep998

This comment has been minimized.

Copy link
Member

retep998 commented Oct 26, 2016

I believe this caused #37416 to fail

https://buildbot.rust-lang.org/builders/auto-win-msvc-64-cargotest/builds/2155

error: patterns aren't allowed in methods without bodies
   --> tests\cargotest\support/mod.rs:604:34
    |
604 |     fn tap<F: FnOnce(&mut Self)>(mut self, callback: F) -> Self;
    |                                  ^^^^^^^^
    |
    = 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>
note: lint level defined here
   --> tests\cargotest\lib.rs:1:9
    |
1   | #![deny(warnings)]
    |         ^^^^^^^^

error: aborting due to previous error

bors added a commit to rust-lang/cargo that referenced this pull request Oct 26, 2016

Auto merge of #3231 - TimNN:patch-1, r=alexcrichton
Fix rust-lang/rust#35203 warning/error

rust-lang/rust#35203 made patterns in functions without body into a warn by default lint (which is being `deny`ed here).

cc rust-lang/rust#37378, rust-lang/rust#37416

@petrochenkov petrochenkov force-pushed the petrochenkov:nopat branch from 82d4200 to 811a2b9 Oct 26, 2016

@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Oct 26, 2016

@bors r=eddyb

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 26, 2016

📌 Commit 811a2b9 has been approved by eddyb

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 29, 2016

⌛️ Testing commit 811a2b9 with merge e61c918...

bors added a commit that referenced this pull request Oct 29, 2016

Auto merge of #37378 - petrochenkov:nopat, r=eddyb
Prohibit patterns in trait methods without bodies

They are not properly type checked
```rust
trait Tr {
    fn f(&a: u8); // <- This compiles
}
```
, mostly rejected by the parser already and generally don't make much sense.
This PR is kind of a missing part of #35015.

Given the [statistics from crater](#37378 (comment)), the effect of this PR is mostly equivalent to improving `unused_mut` lint.

cc #35078 (comment) #35015 rust-lang/rfcs#1685 #35203
r? @eddyb
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 29, 2016

💔 Test failed - auto-win-msvc-64-cargotest

@TimNN

This comment has been minimized.

Copy link
Contributor

TimNN commented Oct 29, 2016

@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Oct 29, 2016

@bors r=eddyb

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 29, 2016

📌 Commit 4ca11ce has been approved by eddyb

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 29, 2016

⌛️ Testing commit 4ca11ce with merge 75a87c5...

bors added a commit that referenced this pull request Oct 29, 2016

Auto merge of #37378 - petrochenkov:nopat, r=eddyb
Prohibit patterns in trait methods without bodies

They are not properly type checked
```rust
trait Tr {
    fn f(&a: u8); // <- This compiles
}
```
, mostly rejected by the parser already and generally don't make much sense.
This PR is kind of a missing part of #35015.

Given the [statistics from crater](#37378 (comment)), the effect of this PR is mostly equivalent to improving `unused_mut` lint.

cc #35078 (comment) #35015 rust-lang/rfcs#1685 #35203
r? @eddyb

@bors bors merged commit 4ca11ce into rust-lang:master Oct 29, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@bluss bluss referenced this pull request Nov 1, 2016

Closed

Bounds parsing refactoring #37511

@WaDelma

This comment has been minimized.

Copy link

WaDelma commented Nov 14, 2016

@petrochenkov
Hey that crater run that said 22 root regressions didn't fail to build my crate even though it quite few anonymous parameters in traits (poisson::algorithm::Creator and poisson::algorithm::Algorithm). Was the lint broken or is there something I am missing?

Edit. Ah the first one was broken already from rustc-serialize and num-traits and didn't reveal that the crate would fail to build even without them...

(And this is why I would really like central place to check crater runs...)

@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Nov 14, 2016

@WaDelma
This lint reports patterns in parameters of trait methods without body

fn f(&arg: Type);
fn g(mut arg: Type);

, anonymous parameters

fn h(Type);

are not reported (yet, waiting for rust-lang/rfcs#1685).

@WaDelma

This comment has been minimized.

Copy link

WaDelma commented Nov 14, 2016

Ah okay. That was the part I was missing. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.