Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions gcc/rust/checks/errors/feature/rust-feature-gate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,17 @@ FeatureGate::visit (AST::Crate &crate)
rust_error_at (locus, ErrorCode::E0635, "unknown feature %qs",
feature.c_str ());
}
check_no_core_attribute (crate.inner_attrs);
for (const auto &attribute : crate.inner_attrs)
{
check_no_core_attribute (attribute);

if (attribute.get_path ().as_string ()
== Values::Attributes::COMPILER_BUILTINS)
gate (Feature::Name::COMPILER_BUILTINS, attribute.get_locus (),
"the #[compiler_builtins] attribute is used to identify the "
"compiler_builtins crate which contains compiler-rt intrinsics "
"and will never be stable");
}
}

void
Expand Down Expand Up @@ -110,15 +120,11 @@ FeatureGate::visit (AST::ExternBlock &block)
}

void
FeatureGate::check_no_core_attribute (
const std::vector<AST::Attribute> &attributes)
FeatureGate::check_no_core_attribute (const AST::Attribute &attribute)
{
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");
}
if (attribute.get_path ().as_string () == Values::Attributes::NO_CORE)
gate (Feature::Name::NO_CORE, attribute.get_locus (),
"no_core is experimental");
}

void
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/checks/errors/feature/rust-feature-gate.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class FeatureGate : public AST::DefaultASTVisitor

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_no_core_attribute (const AST::Attribute &attribute);
void check_rustc_attri (const std::vector<AST::Attribute> &attributes);
void
check_may_dangle_attribute (const std::vector<AST::Attribute> &attributes);
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/util/rust-attribute-values.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class Attributes
static constexpr auto &RUSTC_LAYOUT_SCALAR_VALID_RANGE_START
= "rustc_layout_scalar_valid_range_start";

static constexpr auto &COMPILER_BUILTINS = "compiler_builtins";
static constexpr auto &NO_BUILTINS = "no_builtins";

static constexpr auto &MAY_DANGLE = "may_dangle";
static constexpr auto &PRELUDE_IMPORT = "prelude_import";
static constexpr auto &TRACK_CALLER = "track_caller";
Expand Down
2 changes: 2 additions & 0 deletions gcc/rust/util/rust-attributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ static const BuiltinAttrDefinition __definitions[]
{Attrs::RUSTC_LAYOUT_SCALAR_VALID_RANGE_START, CODE_GENERATION},
// TODO: be careful about calling functions marked with this?
{Attrs::RUSTC_ARGS_REQUIRED_CONST, CODE_GENERATION},
{Attrs::COMPILER_BUILTINS, CODE_GENERATION},
{Attrs::NO_BUILTINS, CODE_GENERATION},
{Attrs::PRELUDE_IMPORT, NAME_RESOLUTION},
{Attrs::RUSTC_DIAGNOSTIC_ITEM, STATIC_ANALYSIS},
{Attrs::RUSTC_ON_UNIMPLEMENTED, STATIC_ANALYSIS},
Expand Down
3 changes: 3 additions & 0 deletions gcc/testsuite/rust/compile/compiler_builtins_gate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#![feature(no_core)]
#![no_core]
#![compiler_builtins] // { dg-error "the ..compiler_builtins. attribute is used to identify the compiler_builtins" }
Loading