From 41ee9eaee76fc38eebc0580e8361bced8edd7ccb Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 11 Oct 2019 02:42:23 +0100 Subject: Refactor `check_track_caller` --- src/librustc/hir/check_attr.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 8777785859c..d366cd9b4c3 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -146,7 +146,7 @@ impl CheckAttrVisitor<'tcx> { } else if attr.check_name(sym::target_feature) { self.check_target_feature(attr, span, target) } else if attr.check_name(sym::track_caller) { - self.check_track_caller(attr, &item, target) + self.check_track_caller(&attr.span, attrs, span, target) } else { true }; @@ -190,21 +190,27 @@ impl CheckAttrVisitor<'tcx> { } /// Checks if a `#[track_caller]` is applied to a non-naked function. Returns `true` if valid. - fn check_track_caller(&self, attr: &hir::Attribute, item: &hir::Item, target: Target) -> bool { + fn check_track_caller( + &self, + attr_span: &Span, + attrs: &HirVec, + span: &Span, + target: Target, + ) -> bool { if target != Target::Fn { struct_span_err!( self.tcx.sess, - attr.span, + *attr_span, E0739, "attribute should be applied to function" ) - .span_label(item.span, "not a function") + .span_label(*span, "not a function") .emit(); false - } else if attr::contains_name(&item.attrs, sym::naked) { + } else if attr::contains_name(attrs, sym::naked) { struct_span_err!( self.tcx.sess, - attr.span, + *attr_span, E0736, "cannot use `#[track_caller]` with `#[naked]`", ) -- cgit 1.4.1-3-g733a5