This is in the matter of RFC 1940 and tracking issue #43302.
+++ /dev/null
-# `fn_must_use`
-
-The tracking issue for this feature is [#43302].
-
-[#43302]: https://github.com/rust-lang/rust/issues/43302
-
-------------------------
-
-The `fn_must_use` feature allows functions and methods to be annotated with
-`#[must_use]`, indicating that the `unused_must_use` lint should require their
-return values to be used (similarly to how types annotated with `must_use`,
-most notably `Result`, are linted if not used).
-
-## Examples
-
-```rust
-#![feature(fn_must_use)]
-
-#[must_use]
-fn double(x: i32) -> i32 {
- 2 * x
-}
-
-fn main() {
- double(4); // warning: unused return value of `double` which must be used
-
- let _ = double(4); // (no warning)
-}
-
-```
#![feature(dropck_eyepatch)]
#![feature(exact_size_is_empty)]
#![feature(fmt_internals)]
-#![feature(fn_must_use)]
+#![cfg_attr(stage0, feature(fn_must_use))]
#![feature(from_ref)]
#![feature(fundamental)]
#![feature(lang_items)]
}
#[test]
+#[allow(unused_must_use)] // here, we care about the side effects of `.clone()`
#[cfg_attr(target_os = "emscripten", ignore)]
fn test_box_slice_clone_panics() {
use std::sync::Arc;
#![feature(doc_cfg)]
#![feature(doc_spotlight)]
#![feature(extern_types)]
-#![feature(fn_must_use)]
#![feature(fundamental)]
#![feature(intrinsics)]
#![feature(iterator_flatten)]
#![cfg_attr(stage0, feature(target_feature))]
#![cfg_attr(stage0, feature(cfg_target_feature))]
+#![cfg_attr(stage0, feature(fn_must_use))]
#[prelude_import]
#[allow(unused)]
let mut fn_warned = false;
let mut op_warned = false;
- if cx.tcx.features().fn_must_use {
- let maybe_def = match expr.node {
- hir::ExprCall(ref callee, _) => {
- match callee.node {
- hir::ExprPath(ref qpath) => {
- let def = cx.tables.qpath_def(qpath, callee.hir_id);
- if let Def::Fn(_) = def {
- Some(def)
- } else { // `Def::Local` if it was a closure, for which we
- None // do not currently support must-use linting
- }
- },
- _ => None
- }
- },
- hir::ExprMethodCall(..) => {
- cx.tables.type_dependent_defs().get(expr.hir_id).cloned()
- },
- _ => None
- };
- if let Some(def) = maybe_def {
- let def_id = def.def_id();
- fn_warned = check_must_use(cx, def_id, s.span, "return value of ");
- }
- let must_use_op = match expr.node {
- // Hardcoding operators here seemed more expedient than the
- // refactoring that would be needed to look up the `#[must_use]`
- // attribute which does exist on the comparison trait methods
- hir::ExprBinary(bin_op, ..) => {
- match bin_op.node {
- hir::BiEq | hir::BiLt | hir::BiLe | hir::BiNe | hir::BiGe | hir::BiGt => {
- Some("comparison")
- },
- hir::BiAdd | hir::BiSub | hir::BiDiv | hir::BiMul | hir::BiRem => {
- Some("arithmetic operation")
- },
- hir::BiAnd | hir::BiOr => {
- Some("logical operation")
- },
- hir::BiBitXor | hir::BiBitAnd | hir::BiBitOr | hir::BiShl | hir::BiShr => {
- Some("bitwise operation")
- },
- }
- },
- hir::ExprUnary(..) => Some("unary operation"),
- _ => None
- };
- if let Some(must_use_op) = must_use_op {
- cx.span_lint(UNUSED_MUST_USE, expr.span,
- &format!("unused {} which must be used", must_use_op));
- op_warned = true;
- }
+ let maybe_def = match expr.node {
+ hir::ExprCall(ref callee, _) => {
+ match callee.node {
+ hir::ExprPath(ref qpath) => {
+ let def = cx.tables.qpath_def(qpath, callee.hir_id);
+ if let Def::Fn(_) = def {
+ Some(def)
+ } else { // `Def::Local` if it was a closure, for which we
+ None // do not currently support must-use linting
+ }
+ },
+ _ => None
+ }
+ },
+ hir::ExprMethodCall(..) => {
+ cx.tables.type_dependent_defs().get(expr.hir_id).cloned()
+ },
+ _ => None
+ };
+ if let Some(def) = maybe_def {
+ let def_id = def.def_id();
+ fn_warned = check_must_use(cx, def_id, s.span, "return value of ");
}
+ let must_use_op = match expr.node {
+ // Hardcoding operators here seemed more expedient than the
+ // refactoring that would be needed to look up the `#[must_use]`
+ // attribute which does exist on the comparison trait methods
+ hir::ExprBinary(bin_op, ..) => {
+ match bin_op.node {
+ hir::BiEq | hir::BiLt | hir::BiLe | hir::BiNe | hir::BiGe | hir::BiGt => {
+ Some("comparison")
+ },
+ hir::BiAdd | hir::BiSub | hir::BiDiv | hir::BiMul | hir::BiRem => {
+ Some("arithmetic operation")
+ },
+ hir::BiAnd | hir::BiOr => {
+ Some("logical operation")
+ },
+ hir::BiBitXor | hir::BiBitAnd | hir::BiBitOr | hir::BiShl | hir::BiShr => {
+ Some("bitwise operation")
+ },
+ }
+ },
+ hir::ExprUnary(..) => Some("unary operation"),
+ _ => None
+ };
+
+ if let Some(must_use_op) = must_use_op {
+ cx.span_lint(UNUSED_MUST_USE, expr.span,
+ &format!("unused {} which must be used", must_use_op));
+ op_warned = true;
+ }
+
if !(ty_warned || fn_warned || op_warned) {
cx.span_lint(UNUSED_RESULTS, s.span, "unused result");
}
/// behavior when `ptr` is used inside the `unsafe` block:
///
/// ```no_run
+ /// # #![allow(unused_must_use)]
/// use std::ffi::{CString};
///
/// let ptr = CString::new("Hello").unwrap().as_ptr();
/// To fix the problem, bind the `CString` to a local variable:
///
/// ```no_run
+ /// # #![allow(unused_must_use)]
/// use std::ffi::{CString};
///
/// let hello = CString::new("Hello").unwrap();
}
}
+ #[allow(unused_must_use)]
#[test]
fn cloning() {
let (tx1, rx1) = channel::<i32>();
tx3.send(()).unwrap();
}
+ #[allow(unused_must_use)]
#[test]
fn cloning2() {
let (tx1, rx1) = channel::<i32>();
// #[doc(include="some-file")]
(active, external_doc, "1.22.0", Some(44732), None),
- // allow `#[must_use]` on functions and comparison operators (RFC 1940)
- (active, fn_must_use, "1.21.0", Some(43302), None),
-
// Future-proofing enums/structs with #[non_exhaustive] attribute (RFC 2008)
(active, non_exhaustive, "1.22.0", Some(44109), None),
(accepted, target_feature, "1.27.0", None, None),
// Trait object syntax with `dyn` prefix
(accepted, dyn_trait, "1.27.0", Some(44662), None),
+ // allow `#[must_use]` on functions; and, must-use operators (RFC 1940)
+ (accepted, fn_must_use, "1.27.0", Some(43302), None),
);
// If you change this, please modify src/doc/unstable-book as well. You must
function may change over time, for now \
a top-level `fn main()` is required");
}
- if let Some(attr) = attr::find_by_name(&i.attrs[..], "must_use") {
- gate_feature_post!(&self, fn_must_use, attr.span,
- "`#[must_use]` on functions is experimental",
- GateStrength::Soft);
- }
}
ast::ItemKind::Struct(..) => {
"trait aliases are not yet fully implemented");
}
- ast::ItemKind::Impl(_, polarity, defaultness, _, _, _, ref impl_items) => {
+ ast::ItemKind::Impl(_, polarity, defaultness, _, _, _, _) => {
if polarity == ast::ImplPolarity::Negative {
gate_feature_post!(&self, optin_builtin_traits,
i.span,
i.span,
"specialization is unstable");
}
-
- for impl_item in impl_items {
- if let ast::ImplItemKind::Method(..) = impl_item.node {
- if let Some(attr) = attr::find_by_name(&impl_item.attrs[..], "must_use") {
- gate_feature_post!(&self, fn_must_use, attr.span,
- "`#[must_use]` on methods is experimental",
- GateStrength::Soft);
- }
- }
- }
}
ast::ItemKind::Trait(ast::IsAuto::Yes, ..) => {
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// compile-flags: --cap-lints allow
-
-// This tests that the fn_must_use feature-gate warning respects the lint
-// cap. (See discussion in Issue #44213.)
-
-#![feature(rustc_attrs)]
-
-#[must_use] // (no feature-gate warning because of the lint cap!)
-fn need_to_use_it() -> bool { true }
-
-#[rustc_error]
-fn main() {} //~ ERROR compilation successful
+++ /dev/null
-error: compilation successful
- --> $DIR/feature-gate-fn_must_use-cap-lints-allow.rs:22:1
- |
-LL | fn main() {} //~ ERROR compilation successful
- | ^^^^^^^^^^^^
-
-error: aborting due to previous error
-
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(rustc_attrs)]
-
-struct MyStruct;
-
-impl MyStruct {
- #[must_use] //~ WARN `#[must_use]` on methods is experimental
- fn need_to_use_method() -> bool { true }
-}
-
-#[must_use] //~ WARN `#[must_use]` on functions is experimental
-fn need_to_use_it() -> bool { true }
-
-
-// Feature gates are tidy-required to have a specially named (or
-// comment-annotated) compile-fail test (which MUST fail), but for
-// backwards-compatibility reasons, we want `#[must_use]` on functions to be
-// compilable even if the `fn_must_use` feature is absent, thus necessitating
-// the usage of `#[rustc_error]` here, pragmatically if awkwardly solving this
-// dilemma until a superior solution can be devised.
-#[rustc_error]
-fn main() {} //~ ERROR compilation successful
+++ /dev/null
-warning: `#[must_use]` on methods is experimental (see issue #43302)
- --> $DIR/feature-gate-fn_must_use.rs:16:5
- |
-LL | #[must_use] //~ WARN `#[must_use]` on methods is experimental
- | ^^^^^^^^^^^
- |
- = help: add #![feature(fn_must_use)] to the crate attributes to enable
-
-warning: `#[must_use]` on functions is experimental (see issue #43302)
- --> $DIR/feature-gate-fn_must_use.rs:20:1
- |
-LL | #[must_use] //~ WARN `#[must_use]` on functions is experimental
- | ^^^^^^^^^^^
- |
- = help: add #![feature(fn_must_use)] to the crate attributes to enable
-
-error: compilation successful
- --> $DIR/feature-gate-fn_must_use.rs:31:1
- |
-LL | fn main() {} //~ ERROR compilation successful
- | ^^^^^^^^^^^^
-
-error: aborting due to previous error
-
mod inner { #![must_use="1400"] }
#[must_use = "1400"] fn f() { }
- //~^ WARN `#[must_use]` on functions is experimental
#[must_use = "1400"] struct S;
|
= help: consider an outer attribute, #[macro_use] mod ...
-warning: `#[must_use]` on functions is experimental (see issue #43302)
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:663:5
- |
-LL | #[must_use = "1400"] fn f() { }
- | ^^^^^^^^^^^^^^^^^^^^
- |
- = help: add #![feature(fn_must_use)] to the crate attributes to enable
-
warning: unknown lint: `x5400`
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:49:33
|
| ^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:692:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:691:17
|
LL | mod inner { #![crate_name="0900"] }
| ^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be in the root module
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:692:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:691:17
|
LL | mod inner { #![crate_name="0900"] }
| ^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:696:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:695:5
|
LL | #[crate_name = "0900"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:696:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:695:5
|
LL | #[crate_name = "0900"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:700:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:699:5
|
LL | #[crate_name = "0900"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:700:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:699:5
|
LL | #[crate_name = "0900"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:704:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:703:5
|
LL | #[crate_name = "0900"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:704:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:703:5
|
LL | #[crate_name = "0900"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:708:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:707:5
|
LL | #[crate_name = "0900"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:708:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:707:5
|
LL | #[crate_name = "0900"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:688:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:687:1
|
LL | #[crate_name = "0900"]
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:688:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:687:1
|
LL | #[crate_name = "0900"]
| ^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:717:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:716:17
|
LL | mod inner { #![crate_type="0800"] }
| ^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be in the root module
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:717:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:716:17
|
LL | mod inner { #![crate_type="0800"] }
| ^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:721:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:720:5
|
LL | #[crate_type = "0800"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:721:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:720:5
|
LL | #[crate_type = "0800"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:725:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:724:5
|
LL | #[crate_type = "0800"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:725:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:724:5
|
LL | #[crate_type = "0800"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:729:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:728:5
|
LL | #[crate_type = "0800"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:729:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:728:5
|
LL | #[crate_type = "0800"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:733:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:732:5
|
LL | #[crate_type = "0800"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:733:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:732:5
|
LL | #[crate_type = "0800"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:713:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:712:1
|
LL | #[crate_type = "0800"]
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:713:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:712:1
|
LL | #[crate_type = "0800"]
| ^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:742:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:741:17
|
LL | mod inner { #![feature(x0600)] }
| ^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be in the root module
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:742:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:741:17
|
LL | mod inner { #![feature(x0600)] }
| ^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:746:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:745:5
|
LL | #[feature(x0600)] fn f() { }
| ^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:746:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:745:5
|
LL | #[feature(x0600)] fn f() { }
| ^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:749:5
|
LL | #[feature(x0600)] struct S;
| ^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:749:5
|
LL | #[feature(x0600)] struct S;
| ^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:754:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:753:5
|
LL | #[feature(x0600)] type T = S;
| ^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:754:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:753:5
|
LL | #[feature(x0600)] type T = S;
| ^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:758:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:757:5
|
LL | #[feature(x0600)] impl S { }
| ^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:758:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:757:5
|
LL | #[feature(x0600)] impl S { }
| ^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:738:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:737:1
|
LL | #[feature(x0600)]
| ^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:738:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:737:1
|
LL | #[feature(x0600)]
| ^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:768:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:767:17
|
LL | mod inner { #![no_main="0400"] }
| ^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be in the root module
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:768:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:767:17
|
LL | mod inner { #![no_main="0400"] }
| ^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:772:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:771:5
|
LL | #[no_main = "0400"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:772:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:771:5
|
LL | #[no_main = "0400"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:776:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:775:5
|
LL | #[no_main = "0400"] struct S;
| ^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:776:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:775:5
|
LL | #[no_main = "0400"] struct S;
| ^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:780:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:779:5
|
LL | #[no_main = "0400"] type T = S;
| ^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:780:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:779:5
|
LL | #[no_main = "0400"] type T = S;
| ^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:784:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:783:5
|
LL | #[no_main = "0400"] impl S { }
| ^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:784:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:783:5
|
LL | #[no_main = "0400"] impl S { }
| ^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:764:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:763:1
|
LL | #[no_main = "0400"]
| ^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:764:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:763:1
|
LL | #[no_main = "0400"]
| ^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:806:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:805:17
|
LL | mod inner { #![recursion_limit="0200"] }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be in the root module
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:806:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:805:17
|
LL | mod inner { #![recursion_limit="0200"] }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:810:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:809:5
|
LL | #[recursion_limit="0200"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:810:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:809:5
|
LL | #[recursion_limit="0200"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:814:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:813:5
|
LL | #[recursion_limit="0200"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:814:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:813:5
|
LL | #[recursion_limit="0200"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:818:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:817:5
|
LL | #[recursion_limit="0200"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:818:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:817:5
|
LL | #[recursion_limit="0200"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:822:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:821:5
|
LL | #[recursion_limit="0200"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:822:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:821:5
|
LL | #[recursion_limit="0200"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:802:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:801:1
|
LL | #[recursion_limit="0200"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:802:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:801:1
|
LL | #[recursion_limit="0200"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:831:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:830:17
|
LL | mod inner { #![type_length_limit="0100"] }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be in the root module
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:831:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:830:17
|
LL | mod inner { #![type_length_limit="0100"] }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:835:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:834:5
|
LL | #[type_length_limit="0100"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:835:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:834:5
|
LL | #[type_length_limit="0100"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:839:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:838:5
|
LL | #[type_length_limit="0100"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:839:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:838:5
|
LL | #[type_length_limit="0100"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:843:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:842:5
|
LL | #[type_length_limit="0100"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:843:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:842:5
|
LL | #[type_length_limit="0100"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:847:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:846:5
|
LL | #[type_length_limit="0100"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:847:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:846:5
|
LL | #[type_length_limit="0100"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused attribute
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:827:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:826:1
|
LL | #[type_length_limit="0100"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo]
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:827:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:826:1
|
LL | #[type_length_limit="0100"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: compilation successful
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:858:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:857:1
|
LL | / fn main() { //~ ERROR compilation successful
LL | | println!("Hello World");
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-pass
+
+#![warn(unused_must_use)]
+
+#[derive(PartialEq, Eq)]
+struct MyStruct {
+ n: usize,
+}
+
+impl MyStruct {
+ #[must_use]
+ fn need_to_use_this_method_value(&self) -> usize {
+ self.n
+ }
+}
+
+trait EvenNature {
+ #[must_use = "no side effects"]
+ fn is_even(&self) -> bool;
+}
+
+impl EvenNature for MyStruct {
+ fn is_even(&self) -> bool {
+ self.n % 2 == 0
+ }
+}
+
+trait Replaceable {
+ fn replace(&mut self, substitute: usize) -> usize;
+}
+
+impl Replaceable for MyStruct {
+ // ↓ N.b.: `#[must_use]` attribute on a particular trait implementation
+ // method won't work; the attribute should be on the method signature in
+ // the trait's definition.
+ #[must_use]
+ fn replace(&mut self, substitute: usize) -> usize {
+ let previously = self.n;
+ self.n = substitute;
+ previously
+ }
+}
+
+#[must_use = "it's important"]
+fn need_to_use_this_value() -> bool {
+ false
+}
+
+fn main() {
+ need_to_use_this_value(); //~ WARN unused return value
+
+ let mut m = MyStruct { n: 2 };
+ let n = MyStruct { n: 3 };
+
+ m.need_to_use_this_method_value(); //~ WARN unused return value
+ m.is_even(); // trait method!
+ //~^ WARN unused return value
+
+ m.replace(3); // won't warn (annotation needs to be in trait definition)
+
+ // comparison methods are `must_use`
+ 2.eq(&3); //~ WARN unused return value
+ m.eq(&n); //~ WARN unused return value
+
+ // lint includes comparison operators
+ 2 == 3; //~ WARN unused comparison
+ m == n; //~ WARN unused comparison
+}
--- /dev/null
+warning: unused return value of `need_to_use_this_value` which must be used: it's important
+ --> $DIR/fn_must_use.rs:60:5
+ |
+LL | need_to_use_this_value(); //~ WARN unused return value
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: lint level defined here
+ --> $DIR/fn_must_use.rs:13:9
+ |
+LL | #![warn(unused_must_use)]
+ | ^^^^^^^^^^^^^^^
+
+warning: unused return value of `MyStruct::need_to_use_this_method_value` which must be used
+ --> $DIR/fn_must_use.rs:65:5
+ |
+LL | m.need_to_use_this_method_value(); //~ WARN unused return value
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: unused return value of `EvenNature::is_even` which must be used: no side effects
+ --> $DIR/fn_must_use.rs:66:5
+ |
+LL | m.is_even(); // trait method!
+ | ^^^^^^^^^^^^
+
+warning: unused return value of `std::cmp::PartialEq::eq` which must be used
+ --> $DIR/fn_must_use.rs:72:5
+ |
+LL | 2.eq(&3); //~ WARN unused return value
+ | ^^^^^^^^^
+
+warning: unused return value of `std::cmp::PartialEq::eq` which must be used
+ --> $DIR/fn_must_use.rs:73:5
+ |
+LL | m.eq(&n); //~ WARN unused return value
+ | ^^^^^^^^^
+
+warning: unused comparison which must be used
+ --> $DIR/fn_must_use.rs:76:5
+ |
+LL | 2 == 3; //~ WARN unused comparison
+ | ^^^^^^
+
+warning: unused comparison which must be used
+ --> $DIR/fn_must_use.rs:77:5
+ |
+LL | m == n; //~ WARN unused comparison
+ | ^^^^^^
+
// compile-pass
-#![feature(fn_must_use)]
#![warn(unused_must_use)]
fn main() {
warning: unused comparison which must be used
- --> $DIR/must-use-ops.rs:23:5
+ --> $DIR/must-use-ops.rs:22:5
|
LL | val == 1;
| ^^^^^^^^
|
note: lint level defined here
- --> $DIR/must-use-ops.rs:16:9
+ --> $DIR/must-use-ops.rs:15:9
|
LL | #![warn(unused_must_use)]
| ^^^^^^^^^^^^^^^
warning: unused comparison which must be used
- --> $DIR/must-use-ops.rs:24:5
+ --> $DIR/must-use-ops.rs:23:5
|
LL | val < 1;
| ^^^^^^^
warning: unused comparison which must be used
- --> $DIR/must-use-ops.rs:25:5
+ --> $DIR/must-use-ops.rs:24:5
|
LL | val <= 1;
| ^^^^^^^^
warning: unused comparison which must be used
- --> $DIR/must-use-ops.rs:26:5
+ --> $DIR/must-use-ops.rs:25:5
|
LL | val != 1;
| ^^^^^^^^
warning: unused comparison which must be used
- --> $DIR/must-use-ops.rs:27:5
+ --> $DIR/must-use-ops.rs:26:5
|
LL | val >= 1;
| ^^^^^^^^
warning: unused comparison which must be used
- --> $DIR/must-use-ops.rs:28:5
+ --> $DIR/must-use-ops.rs:27:5
|
LL | val > 1;
| ^^^^^^^
warning: unused arithmetic operation which must be used
- --> $DIR/must-use-ops.rs:31:5
+ --> $DIR/must-use-ops.rs:30:5
|
LL | val + 2;
| ^^^^^^^
warning: unused arithmetic operation which must be used
- --> $DIR/must-use-ops.rs:32:5
+ --> $DIR/must-use-ops.rs:31:5
|
LL | val - 2;
| ^^^^^^^
warning: unused arithmetic operation which must be used
- --> $DIR/must-use-ops.rs:33:5
+ --> $DIR/must-use-ops.rs:32:5
|
LL | val / 2;
| ^^^^^^^
warning: unused arithmetic operation which must be used
- --> $DIR/must-use-ops.rs:34:5
+ --> $DIR/must-use-ops.rs:33:5
|
LL | val * 2;
| ^^^^^^^
warning: unused arithmetic operation which must be used
- --> $DIR/must-use-ops.rs:35:5
+ --> $DIR/must-use-ops.rs:34:5
|
LL | val % 2;
| ^^^^^^^
warning: unused logical operation which must be used
- --> $DIR/must-use-ops.rs:38:5
+ --> $DIR/must-use-ops.rs:37:5
|
LL | true && true;
| ^^^^^^^^^^^^
warning: unused logical operation which must be used
- --> $DIR/must-use-ops.rs:39:5
+ --> $DIR/must-use-ops.rs:38:5
|
LL | false || true;
| ^^^^^^^^^^^^^
warning: unused bitwise operation which must be used
- --> $DIR/must-use-ops.rs:42:5
+ --> $DIR/must-use-ops.rs:41:5
|
LL | 5 ^ val;
| ^^^^^^^
warning: unused bitwise operation which must be used
- --> $DIR/must-use-ops.rs:43:5
+ --> $DIR/must-use-ops.rs:42:5
|
LL | 5 & val;
| ^^^^^^^
warning: unused bitwise operation which must be used
- --> $DIR/must-use-ops.rs:44:5
+ --> $DIR/must-use-ops.rs:43:5
|
LL | 5 | val;
| ^^^^^^^
warning: unused bitwise operation which must be used
- --> $DIR/must-use-ops.rs:45:5
+ --> $DIR/must-use-ops.rs:44:5
|
LL | 5 << val;
| ^^^^^^^^
warning: unused bitwise operation which must be used
- --> $DIR/must-use-ops.rs:46:5
+ --> $DIR/must-use-ops.rs:45:5
|
LL | 5 >> val;
| ^^^^^^^^
warning: unused unary operation which must be used
- --> $DIR/must-use-ops.rs:49:5
+ --> $DIR/must-use-ops.rs:48:5
|
LL | !val;
| ^^^^
warning: unused unary operation which must be used
- --> $DIR/must-use-ops.rs:50:5
+ --> $DIR/must-use-ops.rs:49:5
|
LL | -val;
| ^^^^
warning: unused unary operation which must be used
- --> $DIR/must-use-ops.rs:51:5
+ --> $DIR/must-use-ops.rs:50:5
|
LL | *val_pointer;
| ^^^^^^^^^^^^
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// compile-pass
-
-#![feature(fn_must_use)]
-#![warn(unused_must_use)]
-
-#[derive(PartialEq, Eq)]
-struct MyStruct {
- n: usize,
-}
-
-impl MyStruct {
- #[must_use]
- fn need_to_use_this_method_value(&self) -> usize {
- self.n
- }
-}
-
-trait EvenNature {
- #[must_use = "no side effects"]
- fn is_even(&self) -> bool;
-}
-
-impl EvenNature for MyStruct {
- fn is_even(&self) -> bool {
- self.n % 2 == 0
- }
-}
-
-trait Replaceable {
- fn replace(&mut self, substitute: usize) -> usize;
-}
-
-impl Replaceable for MyStruct {
- // ↓ N.b.: `#[must_use]` attribute on a particular trait implementation
- // method won't work; the attribute should be on the method signature in
- // the trait's definition.
- #[must_use]
- fn replace(&mut self, substitute: usize) -> usize {
- let previously = self.n;
- self.n = substitute;
- previously
- }
-}
-
-#[must_use = "it's important"]
-fn need_to_use_this_value() -> bool {
- false
-}
-
-fn main() {
- need_to_use_this_value(); //~ WARN unused return value
-
- let mut m = MyStruct { n: 2 };
- let n = MyStruct { n: 3 };
-
- m.need_to_use_this_method_value(); //~ WARN unused return value
- m.is_even(); // trait method!
- //~^ WARN unused return value
-
- m.replace(3); // won't warn (annotation needs to be in trait definition)
-
- // comparison methods are `must_use`
- 2.eq(&3); //~ WARN unused return value
- m.eq(&n); //~ WARN unused return value
-
- // lint includes comparison operators
- 2 == 3; //~ WARN unused comparison
- m == n; //~ WARN unused comparison
-}
+++ /dev/null
-warning: unused return value of `need_to_use_this_value` which must be used: it's important
- --> $DIR/fn_must_use.rs:61:5
- |
-LL | need_to_use_this_value(); //~ WARN unused return value
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
- |
-note: lint level defined here
- --> $DIR/fn_must_use.rs:14:9
- |
-LL | #![warn(unused_must_use)]
- | ^^^^^^^^^^^^^^^
-
-warning: unused return value of `MyStruct::need_to_use_this_method_value` which must be used
- --> $DIR/fn_must_use.rs:66:5
- |
-LL | m.need_to_use_this_method_value(); //~ WARN unused return value
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-warning: unused return value of `EvenNature::is_even` which must be used: no side effects
- --> $DIR/fn_must_use.rs:67:5
- |
-LL | m.is_even(); // trait method!
- | ^^^^^^^^^^^^
-
-warning: unused return value of `std::cmp::PartialEq::eq` which must be used
- --> $DIR/fn_must_use.rs:73:5
- |
-LL | 2.eq(&3); //~ WARN unused return value
- | ^^^^^^^^^
-
-warning: unused return value of `std::cmp::PartialEq::eq` which must be used
- --> $DIR/fn_must_use.rs:74:5
- |
-LL | m.eq(&n); //~ WARN unused return value
- | ^^^^^^^^^
-
-warning: unused comparison which must be used
- --> $DIR/fn_must_use.rs:77:5
- |
-LL | 2 == 3; //~ WARN unused comparison
- | ^^^^^^
-
-warning: unused comparison which must be used
- --> $DIR/fn_must_use.rs:78:5
- |
-LL | m == n; //~ WARN unused comparison
- | ^^^^^^
-
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(attr_literals)]
-
-#[repr(align(16))]
-struct Gem {
- mohs_hardness: u8,
- poofed: bool,
- weapon: Weapon,
-}
-
#[repr(simd)] //~ ERROR are experimental
struct Weapon {
name: String,
damage: u32
}
-impl Gem {
- #[must_use] fn summon_weapon(&self) -> Weapon { self.weapon }
- //~^ WARN is experimental
-}
-
-#[must_use] //~ WARN is experimental
-fn bubble(gem: Gem) -> Result<Gem, ()> {
- if gem.poofed {
- Ok(gem)
- } else {
- Err(())
- }
-}
-
fn main() {}
error[E0658]: SIMD types are experimental and possibly buggy (see issue #27731)
- --> $DIR/gated-features-attr-spans.rs:20:1
+ --> $DIR/gated-features-attr-spans.rs:11:1
|
LL | #[repr(simd)] //~ ERROR are experimental
| ^^^^^^^^^^^^^
|
= help: add #![feature(repr_simd)] to the crate attributes to enable
-warning: `#[must_use]` on methods is experimental (see issue #43302)
- --> $DIR/gated-features-attr-spans.rs:27:5
- |
-LL | #[must_use] fn summon_weapon(&self) -> Weapon { self.weapon }
- | ^^^^^^^^^^^
- |
- = help: add #![feature(fn_must_use)] to the crate attributes to enable
-
-warning: `#[must_use]` on functions is experimental (see issue #43302)
- --> $DIR/gated-features-attr-spans.rs:31:1
- |
-LL | #[must_use] //~ WARN is experimental
- | ^^^^^^^^^^^
- |
- = help: add #![feature(fn_must_use)] to the crate attributes to enable
-
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.