Skip to content

Commit 97d388a

Browse files
committed
Add feature for const pointers
1 parent 05f4924 commit 97d388a

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use rustc_span::symbol::{kw, sym, Ident};
2222
use rustc_span::Span;
2323
use std::mem;
2424
use std::ops::DerefMut;
25+
use rustc_session::parse::feature_err;
2526

2627
const MORE_EXTERN: &str =
2728
"for more information, visit https://doc.rust-lang.org/std/keyword.extern.html";
@@ -824,6 +825,16 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
824825
)
825826
.emit();
826827
});
828+
if !self.session.features_untracked().const_fn_pointer {
829+
if let Const::Yes(span) = bfty.constness {
830+
feature_err(
831+
&self.session.parse_sess,
832+
sym::const_fn_pointer,
833+
span,
834+
"`const fn` pointer type is unstable"
835+
).emit()
836+
}
837+
}
827838
self.check_late_bound_lifetime_defs(&bfty.generic_params);
828839
}
829840
TyKind::TraitObject(ref bounds, ..) => {

compiler/rustc_feature/src/active.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,9 @@ declare_features! (
602602
/// Allows `#[instruction_set(_)]` attribute
603603
(active, isa_attribute, "1.48.0", Some(74727), None),
604604

605+
/// Allow const fn pointer
606+
(active, const_fn_pointer, "1.49.0", Some(63997), None),
607+
605608
// -------------------------------------------------------------------------
606609
// feature-group-end: actual feature gates
607610
// -------------------------------------------------------------------------

compiler/rustc_middle/src/ty/relate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl<'tcx> Relate<'tcx> for ast::Constness {
225225
a: ast::Constness,
226226
b: ast::Constness
227227
) -> RelateResult<'tcx, ast::Constness> {
228-
if a == b || (a == ast::Constness::Const && b == ast::Constness::NotConst) { Ok(a) }
228+
if a == b || (a == ast::Constness::Const && b == ast::Constness::NotConst) { Ok(b) }
229229
else { Err(TypeError::ConstnessMismatch(expected_found(relation, a, b))) }
230230
}
231231
}

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ symbols! {
357357
const_fn,
358358
const_fn_floating_point_arithmetic,
359359
const_fn_fn_ptr_basics,
360+
const_fn_pointer,
360361
const_fn_transmute,
361362
const_fn_union,
362363
const_generics,

0 commit comments

Comments
 (0)