rust/src/test/ui/feature-gate-fn_must_use.rs
est31 38438c618c Migrate a few feature gate tests to ui
Renames only in this commit, and obviously
.stderr file additions.
2017-12-07 10:14:39 +01:00

32 lines
1.2 KiB
Rust

// 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