diff options
| author | varkor <github@varkor.com> | 2019-10-11 02:42:23 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2019-10-25 23:26:27 +0100 |
| commit | 41ee9eaee76fc38eebc0580e8361bced8edd7ccb (patch) | |
| tree | b4abc88ccbde340940981e59b4d7bf753ce269df /src | |
| parent | 4552c8f2f7c20ff5bb7e23b31b4aa863b4502903 (diff) | |
| download | rust-41ee9eaee76fc38eebc0580e8361bced8edd7ccb.tar.gz rust-41ee9eaee76fc38eebc0580e8361bced8edd7ccb.zip | |
Refactor `check_track_caller`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/hir/check_attr.rs | 18 |
1 files changed, 12 insertions, 6 deletions
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<Attribute>, + 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]`", ) |
