1
Fork 0

rustc: Fix ICE with #[target_feature] on module

This commit fixes an ICE in rustc when `#[target_feature]` was applied to items
other than functions due to the way the feature was validated.
This commit is contained in:
Alex Crichton 2018-03-05 08:12:13 -08:00
parent 5430c0c5c0
commit 4bde92c176
4 changed files with 22 additions and 2 deletions

View file

@ -47,7 +47,13 @@ struct CheckAttrVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
/// Check any attribute.
fn check_attributes(&self, item: &hir::Item, target: Target) {
self.tcx.trans_fn_attrs(self.tcx.hir.local_def_id(item.id));
if target == Target::Fn {
self.tcx.trans_fn_attrs(self.tcx.hir.local_def_id(item.id));
} else if let Some(a) = item.attrs.iter().find(|a| a.check_name("target_feature")) {
self.tcx.sess.struct_span_err(a.span, "attribute should be applied to a function")
.span_label(item.span, "not a function")
.emit();
}
for attr in &item.attrs {
if let Some(name) = attr.name() {