Skip to content

Commit a3fcbad

Browse files
committed
temp: Make this Option<&ast::Item> to make it build
1 parent b28f2d9 commit a3fcbad

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/librustc/hir/check_attr.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct CheckAttrVisitor<'a> {
5757

5858
impl<'a> CheckAttrVisitor<'a> {
5959
/// Check any attribute.
60-
fn check_attribute(&self, attr: &ast::Attribute, item: &ast::Item, target: Target) {
60+
fn check_attribute(&self, attr: &ast::Attribute, item: Option<&ast::Item>, target: Target) {
6161
if let Some(name) = attr.name() {
6262
match &*name.as_str() {
6363
"inline" => self.check_inline(attr, item, target),
@@ -68,10 +68,10 @@ impl<'a> CheckAttrVisitor<'a> {
6868
}
6969

7070
/// Check if an `#[inline]` is applied to a function.
71-
fn check_inline(&self, attr: &ast::Attribute, item: &ast::Item, target: Target) {
71+
fn check_inline(&self, attr: &ast::Attribute, _item: Option<&ast::Item>, target: Target) {
7272
if target != Target::Fn {
7373
struct_span_err!(self.sess, attr.span, E0518, "attribute should be applied to function")
74-
.span_label(item.span, "not a function")
74+
.span_label(attr.span, "not a function")
7575
.emit();
7676
}
7777
if ::std::env::var_os("ATTR").is_some() {
@@ -85,7 +85,7 @@ impl<'a> CheckAttrVisitor<'a> {
8585
}
8686

8787
/// Check if an `#[repr]` attr is valid.
88-
fn check_repr(&self, attr: &ast::Attribute, item: &ast::Item, target: Target) {
88+
fn check_repr(&self, attr: &ast::Attribute, item: Option<&ast::Item>, target: Target) {
8989
let words = match attr.meta_item_list() {
9090
Some(words) => words,
9191
None => {
@@ -157,7 +157,7 @@ impl<'a> CheckAttrVisitor<'a> {
157157
_ => continue,
158158
};
159159
struct_span_err!(self.sess, attr.span, E0517, "{}", message)
160-
.span_label(item.span, format!("not {}", label))
160+
.span_label(item.unwrap().span, format!("not {}", label))
161161
.emit();
162162
}
163163
if conflicting_reprs > 1 {
@@ -171,23 +171,23 @@ impl<'a> Visitor<'a> for CheckAttrVisitor<'a> {
171171
fn visit_item(&mut self, item: &'a ast::Item) {
172172
let target = Target::from_item(item);
173173
for attr in &item.attrs {
174-
self.check_attribute(attr, item, target);
174+
self.check_attribute(attr, Some(item), target);
175175
}
176176
visit::walk_item(self, item);
177177
}
178178

179179
fn visit_trait_item(&mut self, item: &'a ast::TraitItem) {
180180
let target = Target::from_trait_item(item);
181181
for attr in &item.attrs {
182-
self.check_attribute(attr, target);
182+
self.check_attribute(attr, None/*item*/, target);
183183
}
184184
visit::walk_trait_item(self, item);
185185
}
186186

187187
fn visit_impl_item(&mut self, item: &'a ast::ImplItem) {
188188
let target = Target::from_impl_item(item);
189189
for attr in &item.attrs {
190-
self.check_attribute(attr, target);
190+
self.check_attribute(attr, None/*item*/, target);
191191
}
192192
visit::walk_impl_item(self, item);
193193
}

0 commit comments

Comments
 (0)