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

petrochenkov
Copy link
Contributor

@petrochenkov 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
Copy link
Member

eddyb commented Oct 24, 2016

Started crater run.

@eddyb
Copy link
Member

eddyb commented Oct 24, 2016

Crater run looks pretty bad (177 root regressions).

@petrochenkov
Copy link
Contributor Author

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
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
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
Copy link
Member

eddyb commented Oct 25, 2016

Second crater report shows only 22 root regressions.

@petrochenkov
Copy link
Contributor Author

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
Copy link
Member

eddyb commented Oct 25, 2016

@bors r+

@bors
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
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
Copy link
Member

Fails tidy, d230a7e

@TimNN
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be unused?

@retep998
Copy link
Member

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
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
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Oct 26, 2016

📌 Commit 811a2b9 has been approved by eddyb

@bors
Copy link
Contributor

bors commented Oct 29, 2016

⌛ Testing commit 811a2b9 with merge e61c918...

@bors
Copy link
Contributor

bors commented Oct 29, 2016

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

@TimNN
Copy link
Contributor

TimNN commented Oct 29, 2016

This probably needs to update the sha at https://github.com/rust-lang/rust/blob/master/src/tools/cargotest/main.rs#L27 to at least rust-lang/cargo@806e3c3

@petrochenkov
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Oct 29, 2016

📌 Commit 4ca11ce has been approved by eddyb

@bors
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
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
@WaDelma
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
Copy link
Contributor Author

@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
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants