mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
gccrs: feat: Implement no_core feature gate check
The compiler was accepting `#![no_core]` without requiring `#![feature(no_core)]`, silently treating an unstable attribute as stable. Gate it via check_no_core_attribute, consistent with how other experimental attributes are handled. Fixes: Rust-GCC#4461 gcc/rust/ChangeLog: * checks/errors/feature/rust-feature-gate.cc (FeatureGate::visit): Call check_no_core_attri. * checks/errors/feature/rust-feature-gate.h: Declare method check_no_core_attri. gcc/testsuite/ChangeLog: * rust/compile/match-scope.rs: Fix test. * rust/compile/no_core_feature_gate.rs: New test. Signed-off-by: Mohamed Ali <mohmedali1462005@gmail.com>
This commit is contained in:
committed by
Arthur Cohen
parent
5706c607e2
commit
3753033a3a
@@ -63,6 +63,7 @@ FeatureGate::visit (AST::Crate &crate)
|
||||
rust_error_at (locus, ErrorCode::E0635, "unknown feature %qs",
|
||||
feature.c_str ());
|
||||
}
|
||||
check_no_core_attribute (crate.inner_attrs);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -108,6 +109,18 @@ FeatureGate::visit (AST::ExternBlock &block)
|
||||
AST::DefaultASTVisitor::visit (block);
|
||||
}
|
||||
|
||||
void
|
||||
FeatureGate::check_no_core_attribute (
|
||||
const std::vector<AST::Attribute> &attributes)
|
||||
{
|
||||
for (const AST::Attribute &attr : attributes)
|
||||
{
|
||||
if (attr.get_path ().as_string () == Values::Attributes::NO_CORE)
|
||||
gate (Feature::Name::NO_CORE, attr.get_locus (),
|
||||
"no_core is experimental");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FeatureGate::check_rustc_attri (const std::vector<AST::Attribute> &attributes)
|
||||
{
|
||||
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
|
||||
private:
|
||||
void gate (Feature::Name name, location_t loc, const std::string &error_msg);
|
||||
void check_no_core_attribute (const std::vector<AST::Attribute> &attributes);
|
||||
void check_rustc_attri (const std::vector<AST::Attribute> &attributes);
|
||||
void
|
||||
check_may_dangle_attribute (const std::vector<AST::Attribute> &attributes);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![feature(no_core)]
|
||||
#![no_core]
|
||||
|
||||
pub fn main() -> i32 {
|
||||
|
||||
3
gcc/testsuite/rust/compile/no_core_feature_gate.rs
Normal file
3
gcc/testsuite/rust/compile/no_core_feature_gate.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
#![no_core] // { dg-error "no_core is experimental" }
|
||||
|
||||
fn main() {}
|
||||
Reference in New Issue
Block a user