Skip to content

Commit ac2c599

Browse files
committed
fix validation for rustc_allow_const_fn_unstable targets
The validation was introduced in 3a63bf0 without strict validation of functions, e. g. all function types were allowed. Now the validation only allows `const fn`s.
1 parent 13b481b commit ac2c599

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: compiler/rustc_passes/src/check_attr.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl CheckAttrVisitor<'tcx> {
8888
} else if self.tcx.sess.check_name(attr, sym::allow_internal_unstable) {
8989
self.check_allow_internal_unstable(&attr, span, target, &attrs)
9090
} 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)
91+
self.check_rustc_allow_const_fn_unstable(hir_id, &attr, span, target)
9292
} else {
9393
// lint-only checks
9494
if self.tcx.sess.check_name(attr, sym::cold) {
@@ -798,13 +798,15 @@ impl CheckAttrVisitor<'tcx> {
798798
/// (Allows proc_macro functions)
799799
fn check_rustc_allow_const_fn_unstable(
800800
&self,
801+
hir_id: HirId,
801802
attr: &Attribute,
802803
span: &Span,
803804
target: Target,
804805
) -> bool {
805806
if let Target::Fn | Target::Method(_) = target {
806-
// FIXME Check that this isn't just a function, but a const fn
807-
return true;
807+
if self.tcx.is_const_fn_raw(self.tcx.hir().local_def_id(hir_id)) {
808+
return true;
809+
}
808810
}
809811
self.tcx
810812
.sess

0 commit comments

Comments
 (0)