Feature gate macro arguments
Uses the same approach as https://github.com/rust-lang/rust/pull/17286 (and subsequent changes making it more correct), where the visitor will skip any pieces of the AST that are from "foreign code", where the spans don't line up, indicating that that piece of code is due to a macro expansion. If this breaks your code, read the error message to determine which feature gate you should add to your crate, and bask in the knowledge that your code won't mysteriously break should you try to use the 1.0 release. Closes #18102 [breaking-change]
This commit is contained in:
parent
84f5ad8679
commit
41da99dff4
6 changed files with 172 additions and 78 deletions
24
src/test/compile-fail/feature-gated-feature-in-macro-arg.rs
Normal file
24
src/test/compile-fail/feature-gated-feature-in-macro-arg.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2014 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.
|
||||
|
||||
// tests that input to a macro is checked for use of gated features. If this
|
||||
// test succeeds due to the acceptance of a feature, pick a new feature to
|
||||
// test. Not ideal, but oh well :(
|
||||
|
||||
fn main() {
|
||||
let a = &[1i32, 2, 3];
|
||||
println!("{}", {
|
||||
extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change
|
||||
fn atomic_fence();
|
||||
}
|
||||
atomic_fence();
|
||||
42
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue