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

#[must_use] now suddenly warns in nightly #44213

Closed
nox opened this issue Aug 31, 2017 · 7 comments
Closed

#[must_use] now suddenly warns in nightly #44213

nox opened this issue Aug 31, 2017 · 7 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nox
Copy link
Contributor

nox commented Aug 31, 2017

Building Euclid on nightly now produces a gazillion of warnings that were not there before.

   Compiling euclid v0.15.1
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform2d.rs:164:5
    |
164 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform2d.rs:178:5
    |
178 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform2d.rs:194:5
    |
194 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform2d.rs:200:5
    |
200 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform2d.rs:216:5
    |
216 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform2d.rs:222:5
    |
222 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform2d.rs:244:5
    |
244 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform2d.rs:250:5
    |
250 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform2d.rs:257:5
    |
257 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform2d.rs:265:5
    |
265 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform2d.rs:274:5
    |
274 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform2d.rs:290:5
    |
290 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform3d.rs:373:5
    |
373 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform3d.rs:460:5
    |
460 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform3d.rs:466:5
    |
466 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform3d.rs:483:5
    |
483 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform3d.rs:494:5
    |
494 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform3d.rs:537:5
    |
537 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/transform3d.rs:543:5
    |
543 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/point.rs:236:5
    |
236 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/point.rs:248:5
    |
248 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/point.rs:260:5
    |
260 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/point.rs:547:5
    |
547 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/point.rs:558:5
    |
558 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/point.rs:569:5
    |
569 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/rect.rs:170:5
    |
170 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/rect.rs:195:5
    |
195 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/rect.rs:204:5
    |
204 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/rect.rs:225:5
    |
225 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/rect.rs:397:5
    |
397 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/rect.rs:406:5
    |
406 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/rect.rs:415:5
    |
415 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/vector.rs:269:5
    |
269 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/vector.rs:281:5
    |
281 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/vector.rs:293:5
    |
293 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/vector.rs:616:5
    |
616 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/vector.rs:627:5
    |
627 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
warning: `#[must_use]` on methods is experimental (see issue #43302)
   --> /home/travis/build/servo/servo-with-rust-nightly/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/euclid-0.15.1/src/vector.rs:638:5
    |
638 |     #[must_use]
    |     ^^^^^^^^^^^
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable

Cc @nical @SimonSapin

@SimonSapin
Copy link
Contributor

This is #43776.

This warning shouldn’t become an error without a epoch/checkpoint since previous stable version accepted code that now warn.

Feature-gating with only a warning rather than an error is a bit pointless. I think #43776 should be reverted.

@SimonSapin
Copy link
Contributor

Or at the very least, this should be made the kind of warning that doesn’t spam downstream users despite --cap-lints=allow.

@kennytm
Copy link
Member

kennytm commented Aug 31, 2017

Both this and E0122 should repsect --cap-lints. There is nothing downstream can do with these warnings. But I disagree reverting #43776 entirely.

Did #43728 (#[must_use]) / #43776 (add feature gate) enter beta?

EDIT: Both did.

@zackmdavis
Copy link
Member

Unfortunately, the "soft" feature-gate warning (which is just a .struct_span_warn) is not respecting --cap-lints=allow. I can look into this tomorrow (if no one else scoops it up today).

@zackmdavis
Copy link
Member

zackmdavis commented Sep 1, 2017

Also unfortunately, it doesn't look like the feature-gate machinery already has access to the lint-cap setting. I'm having trouble deciding whether it's less terrible/hacky/inelegant/unæsthetic to add it as another argument to feature_gate::check_crate or as a field on ParseSess. 😞

@kennytm
Copy link
Member

kennytm commented Sep 1, 2017

@zackmdavis Is it possible to switch off the can_emit_warnings field of errors::Handler when it is constructed? The driver should know the --cap-lints level while constructing the Handler.

@shepmaster shepmaster added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 1, 2017
bors-servo pushed a commit to servo/euclid that referenced this issue Sep 13, 2017
efficacious `#[must_use]` methods for nightly, fix warnings

137660d annotated many methods with `#[must_use]`, but despite not
being rejected by the compiler, this is actually a no-op (as of Rust
1.20). `#[must_use]` for functions is now available on nightly
Rust (since rust-lang/rust@3645b062), under a feature-gate (since
rust-lang/rust@8492ad24 and 35c44941), with a warning if `#[must_use]`
appears on a function or method without the feature being enabled—a
warning that regrettably added a lot of noise to Euclid's build, as
reported in rust-lang/rust#44213. But with judicious use of [`cfg_attr`](https://doc.rust-lang.org/1.19.0/book/first-edition/conditional-compilation.html#cfg_attr),
Euclid can make use of this functionality if our "unstable" feature is
enabled, and shut up the warnings in any case.

![must_euclid](https://user-images.githubusercontent.com/1076988/29959879-3f527186-8eae-11e7-915b-357f39e4be17.png)

(SHA in the screenshot doesn't match because I had to amend the commit message)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/euclid/225)
<!-- Reviewable:end -->
zackmdavis added a commit to zackmdavis/rust that referenced this issue Sep 16, 2017
This boolean field on the error `Handler` is toggled to silence
warnings when `-A warnings` is passed. (This is actually a separate
mechanism from the global lint level—whether there's some redundancy
to be factored away here is an important question, but not one we
concern ourselves with in this commit.)  But the same rationale
applies for `--cap-lints allow`. In particular, this makes the "soft"
feature-gate warning introduced in 8492ad2 (which is not a lint, but
just calls `struct_span_warn`) not pollute the builds of dependent
crates.

Thanks to @kennytm for pointing out the potential of
`can_emit_warnings` for this purpose.

Resolves rust-lang#44213.
@zackmdavis
Copy link
Member

Is it possible to switch off the can_emit_warnings field of errors::Handler when it is constructed?

Yes.

bors added a commit that referenced this issue Sep 21, 2017
`--cap-lints allow` switches off `can_emit_warnings`

This boolean field on the error `Handler` is toggled to silence
warnings when `-A warnings` is passed. (This is actually a separate
mechanism from the global lint level—whether there's some redundancy
to be factored away here is an important question, but not one we
concern ourselves with in this commit.)  But the same rationale
applies for `--cap-lints allow`. In particular, this makes the "soft"
feature-gate warning introduced in 8492ad2 (which is not a lint, but
just calls `struct_span_warn`) not pollute the builds of dependent
crates.

Thanks to @kennytm for pointing out the potential of
`can_emit_warnings` for this purpose.

Resolves #44213.
nikomatsakis pushed a commit to nikomatsakis/rust that referenced this issue Sep 28, 2017
This boolean field on the error `Handler` is toggled to silence
warnings when `-A warnings` is passed. (This is actually a separate
mechanism from the global lint level—whether there's some redundancy
to be factored away here is an important question, but not one we
concern ourselves with in this commit.)  But the same rationale
applies for `--cap-lints allow`. In particular, this makes the "soft"
feature-gate warning introduced in 8492ad2 (which is not a lint, but
just calls `struct_span_warn`) not pollute the builds of dependent
crates.

Thanks to @kennytm for pointing out the potential of
`can_emit_warnings` for this purpose.

Resolves rust-lang#44213.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants