check_used
should only look at actual used
attributes
This commit is contained in:
parent
d981633ed6
commit
45a441b61c
2 changed files with 11 additions and 2 deletions
|
@ -1740,8 +1740,8 @@ impl CheckAttrVisitor<'_> {
|
||||||
fn check_used(&self, attrs: &[Attribute], target: Target) {
|
fn check_used(&self, attrs: &[Attribute], target: Target) {
|
||||||
let mut used_linker_span = None;
|
let mut used_linker_span = None;
|
||||||
let mut used_compiler_span = None;
|
let mut used_compiler_span = None;
|
||||||
for attr in attrs {
|
for attr in attrs.iter().filter(|attr| attr.has_name(sym::used)) {
|
||||||
if attr.has_name(sym::used) && target != Target::Static {
|
if target != Target::Static {
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
.span_err(attr.span, "attribute must be applied to a `static` variable");
|
.span_err(attr.span, "attribute must be applied to a `static` variable");
|
||||||
|
|
9
src/test/ui/attributes/used_with_arg_no_mangle.rs
Normal file
9
src/test/ui/attributes/used_with_arg_no_mangle.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
// check-pass
|
||||||
|
|
||||||
|
#![feature(used_with_arg)]
|
||||||
|
|
||||||
|
#[used(linker)]
|
||||||
|
#[no_mangle] // accidentally detected as `used(compiler)`
|
||||||
|
pub static GLOB: usize = 0;
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue