File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
compiler/rustc_passes/src Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,8 @@ impl CheckAttrVisitor<'tcx> {
87
87
self.check_rustc_args_required_const(&attr, span, target, item)
88
88
} else if self.tcx.sess.check_name(attr, sym::allow_internal_unstable) {
89
89
self.check_allow_internal_unstable(&attr, span, target, &attrs)
90
+ } else if self.tcx.sess.check_name(attr, sym::rustc_allow_const_fn_unstable) {
91
+ self.check_rustc_allow_const_fn_unstable(&attr, span, target)
90
92
} else {
91
93
// lint-only checks
92
94
if self.tcx.sess.check_name(attr, sym::cold) {
@@ -791,6 +793,26 @@ impl CheckAttrVisitor<'tcx> {
791
793
.emit();
792
794
false
793
795
}
796
+
797
+ /// Outputs an error for `#[allow_internal_unstable]` which can only be applied to macros.
798
+ /// (Allows proc_macro functions)
799
+ fn check_rustc_allow_const_fn_unstable(
800
+ &self,
801
+ attr: &Attribute,
802
+ span: &Span,
803
+ target: Target,
804
+ ) -> bool {
805
+ if let Target::Fn | Target::Method(_) = target {
806
+ // FIXME Check that this isn't just a function, but a const fn
807
+ return true;
808
+ }
809
+ self.tcx
810
+ .sess
811
+ .struct_span_err(attr.span, "attribute should be applied to `const fn`")
812
+ .span_label(*span, "not a `const fn`")
813
+ .emit();
814
+ false
815
+ }
794
816
}
795
817
796
818
impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
You can’t perform that action at this time.
0 commit comments