Skip to content

Commit 190a6c4

Browse files
committed
Auto merge of #50096 - alexcrichton:less-simd-warnings, r=michaelwoerister
Tweak some warnings around #[target_feature] This commit fixes up some issues discovered when getting the `stdsimd` crate's CI compiling again.
2 parents f5203d1 + 81a6437 commit 190a6c4

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

src/librustc_typeck/collect.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,7 @@ fn is_foreign_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
16821682

16831683
fn from_target_feature(
16841684
tcx: TyCtxt,
1685+
id: DefId,
16851686
attr: &ast::Attribute,
16861687
whitelist: &FxHashMap<String, Option<String>>,
16871688
target_features: &mut Vec<Symbol>,
@@ -1752,7 +1753,7 @@ fn from_target_feature(
17521753
Some(name) => bug!("unknown target feature gate {}", name),
17531754
None => true,
17541755
};
1755-
if !allowed {
1756+
if !allowed && id.is_local() {
17561757
feature_gate::emit_feature_err(
17571758
&tcx.sess.parse_sess,
17581759
feature_gate.as_ref().unwrap(),
@@ -1877,7 +1878,7 @@ fn trans_fn_attrs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> TransFnAt
18771878
`unsafe` function";
18781879
tcx.sess.span_err(attr.span, msg);
18791880
}
1880-
from_target_feature(tcx, attr, &whitelist, &mut trans_fn_attrs.target_features);
1881+
from_target_feature(tcx, id, attr, &whitelist, &mut trans_fn_attrs.target_features);
18811882
} else if attr.check_name("linkage") {
18821883
if let Some(val) = attr.value_str() {
18831884
trans_fn_attrs.linkage = Some(linkage_by_name(tcx, id, &val.as_str()));

src/libsyntax/feature_gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG
936936
"the `#[naked]` attribute \
937937
is an experimental feature",
938938
cfg_fn!(naked_functions))),
939-
("target_feature", Normal, Ungated),
939+
("target_feature", Whitelisted, Ungated),
940940
("export_name", Whitelisted, Ungated),
941941
("inline", Whitelisted, Ungated),
942942
("link", Whitelisted, Ungated),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(mmx_target_feature)]
12+
13+
#[inline]
14+
#[target_feature(enable = "mmx")]
15+
pub unsafe fn foo() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// only-x86_64
12+
// aux-build:using-target-feature-unstable.rs
13+
14+
extern crate using_target_feature_unstable;
15+
16+
fn main() {
17+
unsafe {
18+
using_target_feature_unstable::foo();
19+
}
20+
}

0 commit comments

Comments
 (0)