fix validation for rustc_allow_const_fn_unstable targets
The validation was introduced in 3a63bf0299
without strict validation of functions, e. g. all function types were
allowed.
Now the validation only allows `const fn`s.
This commit is contained in:
parent
13b481b247
commit
ac2c599f23
1 changed files with 5 additions and 3 deletions
|
@ -88,7 +88,7 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
} else if self.tcx.sess.check_name(attr, sym::allow_internal_unstable) {
|
} else if self.tcx.sess.check_name(attr, sym::allow_internal_unstable) {
|
||||||
self.check_allow_internal_unstable(&attr, span, target, &attrs)
|
self.check_allow_internal_unstable(&attr, span, target, &attrs)
|
||||||
} else if self.tcx.sess.check_name(attr, sym::rustc_allow_const_fn_unstable) {
|
} else if self.tcx.sess.check_name(attr, sym::rustc_allow_const_fn_unstable) {
|
||||||
self.check_rustc_allow_const_fn_unstable(&attr, span, target)
|
self.check_rustc_allow_const_fn_unstable(hir_id, &attr, span, target)
|
||||||
} else {
|
} else {
|
||||||
// lint-only checks
|
// lint-only checks
|
||||||
if self.tcx.sess.check_name(attr, sym::cold) {
|
if self.tcx.sess.check_name(attr, sym::cold) {
|
||||||
|
@ -798,13 +798,15 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
/// (Allows proc_macro functions)
|
/// (Allows proc_macro functions)
|
||||||
fn check_rustc_allow_const_fn_unstable(
|
fn check_rustc_allow_const_fn_unstable(
|
||||||
&self,
|
&self,
|
||||||
|
hir_id: HirId,
|
||||||
attr: &Attribute,
|
attr: &Attribute,
|
||||||
span: &Span,
|
span: &Span,
|
||||||
target: Target,
|
target: Target,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if let Target::Fn | Target::Method(_) = target {
|
if let Target::Fn | Target::Method(_) = target {
|
||||||
// FIXME Check that this isn't just a function, but a const fn
|
if self.tcx.is_const_fn_raw(self.tcx.hir().local_def_id(hir_id)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue