stabilize const_extern_fn
· rust-lang/rust@a528f4e (original) (raw)
`@@ -75,22 +75,9 @@ struct PostExpansionVisitor<'a> {
`
75
75
``
76
76
`impl<'a> PostExpansionVisitor<'a> {
`
77
77
`#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
`
78
``
`-
fn check_abi(&self, abi: ast::StrLit, constness: ast::Const) {
`
``
78
`+
fn check_abi(&self, abi: ast::StrLit) {
`
79
79
`let ast::StrLit { symbol_unescaped, span, .. } = abi;
`
80
80
``
81
``
`-
if let ast::Const::Yes(_) = constness {
`
82
``
`-
match symbol_unescaped {
`
83
``
`-
// Stable
`
84
``
`-
sym::Rust | sym::C => {}
`
85
``
`-
abi => gate!(
`
86
``
`-
&self,
`
87
``
`-
const_extern_fn,
`
88
``
`-
span,
`
89
``
`` -
format!("{}
as a const fn
ABI is unstable", abi)
``
90
``
`-
),
`
91
``
`-
}
`
92
``
`-
}
`
93
``
-
94
81
`match abi::is_enabled(self.features, span, symbol_unescaped.as_str()) {
`
95
82
`Ok(()) => (),
`
96
83
`Err(abi::AbiDisabled::Unstable { feature, explain }) => {
`
`@@ -110,9 +97,9 @@ impl<'a> PostExpansionVisitor<'a> {
`
110
97
`}
`
111
98
`}
`
112
99
``
113
``
`-
fn check_extern(&self, ext: ast::Extern, constness: ast::Const) {
`
``
100
`+
fn check_extern(&self, ext: ast::Extern) {
`
114
101
`if let ast::Extern::Explicit(abi, _) = ext {
`
115
``
`-
self.check_abi(abi, constness);
`
``
102
`+
self.check_abi(abi);
`
116
103
`}
`
117
104
`}
`
118
105
``
`@@ -239,7 +226,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
`
239
226
`match &i.kind {
`
240
227
` ast::ItemKind::ForeignMod(foreign_module) => {
`
241
228
`if let Some(abi) = foreign_module.abi {
`
242
``
`-
self.check_abi(abi, ast::Const::No);
`
``
229
`+
self.check_abi(abi);
`
243
230
`}
`
244
231
`}
`
245
232
``
`@@ -341,7 +328,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
`
341
328
`match &ty.kind {
`
342
329
` ast::TyKind::BareFn(bare_fn_ty) => {
`
343
330
`` // Function pointers cannot be const
``
344
``
`-
self.check_extern(bare_fn_ty.ext, ast::Const::No);
`
``
331
`+
self.check_extern(bare_fn_ty.ext);
`
345
332
`self.check_late_bound_lifetime_defs(&bare_fn_ty.generic_params);
`
346
333
`}
`
347
334
` ast::TyKind::Never => {
`
`@@ -446,7 +433,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
`
446
433
`fn visit_fn(&mut self, fn_kind: FnKind<'a>, span: Span, _: NodeId) {
`
447
434
`if let Some(header) = fn_kind.header() {
`
448
435
`` // Stability of const fn methods are covered in visit_assoc_item
below.
``
449
``
`-
self.check_extern(header.ext, header.constness);
`
``
436
`+
self.check_extern(header.ext);
`
450
437
`}
`
451
438
``
452
439
`if let FnKind::Closure(ast::ClosureBinder::For { generic_params, .. }, ..) = fn_kind {
`