8bb29465d0
There were several feature-gated attributes for which the feature-not-available error spans would point to the item annotated with the gated attribute, when it would make more sense for the span to point to the attribute itself: if the attribute is removed, the function/struct/&c. likely still makes sense and the program will compile. (Note that we decline to make the analogous change for the `main`, `start`, and `plugin_registrar` features, for in those cases it makes sense for the span to implicate the entire function, of which there is little hope of using without the gated attribute.)
32 lines
1.2 KiB
Rust
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
|