aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/checks/errors/rust-feature-gate.cc8
-rw-r--r--gcc/rust/checks/errors/rust-feature-gate.h2
-rw-r--r--gcc/rust/checks/errors/rust-feature.cc4
-rw-r--r--gcc/rust/checks/errors/rust-feature.h1
-rw-r--r--gcc/rust/util/rust-attribute-values.h1
-rw-r--r--gcc/rust/util/rust-attributes.cc3
-rw-r--r--gcc/testsuite/rust/compile/prelude_import.rs12
7 files changed, 29 insertions, 2 deletions
diff --git a/gcc/rust/checks/errors/rust-feature-gate.cc b/gcc/rust/checks/errors/rust-feature-gate.cc
index 0fe2edb..47e4ad8 100644
--- a/gcc/rust/checks/errors/rust-feature-gate.cc
+++ b/gcc/rust/checks/errors/rust-feature-gate.cc
@@ -217,4 +217,12 @@ FeatureGate::visit (AST::RangePattern &pattern)
"exclusive range pattern syntax is experimental");
}
+void
+FeatureGate::visit (AST::UseTreeGlob &use)
+{
+ // At the moment, UseTrees do not have outer attributes, but they should. we
+ // need to eventually gate `#[prelude_import]` on use-trees based on the
+ // #[feature(prelude_import)]
+}
+
} // namespace Rust
diff --git a/gcc/rust/checks/errors/rust-feature-gate.h b/gcc/rust/checks/errors/rust-feature-gate.h
index 5a063ea..5d02504 100644
--- a/gcc/rust/checks/errors/rust-feature-gate.h
+++ b/gcc/rust/checks/errors/rust-feature-gate.h
@@ -107,7 +107,7 @@ public:
void visit (AST::TypeBoundWhereClauseItem &item) override {}
void visit (AST::Module &module) override {}
void visit (AST::ExternCrate &crate) override {}
- void visit (AST::UseTreeGlob &use_tree) override {}
+ void visit (AST::UseTreeGlob &use_tree) override;
void visit (AST::UseTreeList &use_tree) override {}
void visit (AST::UseTreeRebind &use_tree) override {}
void visit (AST::UseDeclaration &use_decl) override {}
diff --git a/gcc/rust/checks/errors/rust-feature.cc b/gcc/rust/checks/errors/rust-feature.cc
index cd2df0f..587f0e5 100644
--- a/gcc/rust/checks/errors/rust-feature.cc
+++ b/gcc/rust/checks/errors/rust-feature.cc
@@ -58,6 +58,9 @@ Feature::create (Feature::Name name)
return Feature (Feature::Name::EXCLUSIVE_RANGE_PATTERN,
Feature::State::ACTIVE, "exclusive_range_pattern",
"1.11.0", 37854, tl::nullopt, "");
+ case Feature::Name::PRELUDE_IMPORT:
+ return Feature (Feature::Name::PRELUDE_IMPORT, Feature::State::ACTIVE,
+ "prelude_import", "1.0.0", 0, tl::nullopt, "");
default:
rust_unreachable ();
}
@@ -79,6 +82,7 @@ const std::map<std::string, Feature::Name> Feature::name_hash_map = {
{"dropck_eyepatch", Feature::Name::DROPCK_EYEPATCH},
{"raw_ref_op", Feature::Name::RAW_REF_OP},
{"exclusive_range_pattern", Feature::Name::EXCLUSIVE_RANGE_PATTERN},
+ {"prelude_import", Feature::Name::PRELUDE_IMPORT},
}; // namespace Rust
tl::optional<Feature::Name>
diff --git a/gcc/rust/checks/errors/rust-feature.h b/gcc/rust/checks/errors/rust-feature.h
index 89e58cf..482c933 100644
--- a/gcc/rust/checks/errors/rust-feature.h
+++ b/gcc/rust/checks/errors/rust-feature.h
@@ -50,6 +50,7 @@ public:
DROPCK_EYEPATCH,
RAW_REF_OP,
EXCLUSIVE_RANGE_PATTERN,
+ PRELUDE_IMPORT,
};
const std::string &as_string () { return m_name_str; }
diff --git a/gcc/rust/util/rust-attribute-values.h b/gcc/rust/util/rust-attribute-values.h
index 428a86f..fa316b4 100644
--- a/gcc/rust/util/rust-attribute-values.h
+++ b/gcc/rust/util/rust-attribute-values.h
@@ -56,6 +56,7 @@ public:
static constexpr auto &RUSTC_CONST_STABLE = "rustc_const_stable";
static constexpr auto &RUSTC_CONST_UNSTABLE = "rustc_const_unstable";
static constexpr auto &MAY_DANGLE = "may_dangle";
+ static constexpr auto &PRELUDE_IMPORT = "prelude_import";
};
} // namespace Values
} // namespace Rust
diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc
index 3316667..14f00bd 100644
--- a/gcc/rust/util/rust-attributes.cc
+++ b/gcc/rust/util/rust-attributes.cc
@@ -64,7 +64,8 @@ static const BuiltinAttrDefinition __definitions[]
{Attrs::UNSTABLE, STATIC_ANALYSIS},
// assuming we keep these for static analysis
{Attrs::RUSTC_CONST_STABLE, STATIC_ANALYSIS},
- {Attrs::RUSTC_CONST_UNSTABLE, STATIC_ANALYSIS}};
+ {Attrs::RUSTC_CONST_UNSTABLE, STATIC_ANALYSIS},
+ {Attrs::PRELUDE_IMPORT, NAME_RESOLUTION}};
BuiltinAttributeMappings *
BuiltinAttributeMappings::get ()
diff --git a/gcc/testsuite/rust/compile/prelude_import.rs b/gcc/testsuite/rust/compile/prelude_import.rs
new file mode 100644
index 0000000..569fb62
--- /dev/null
+++ b/gcc/testsuite/rust/compile/prelude_import.rs
@@ -0,0 +1,12 @@
+#![feature(prelude_import)]
+
+mod core {
+ mod prelude {
+ mod v1 {
+ // hehe
+ }
+ }
+}
+
+#[prelude_import]
+use core::prelude::v1::*;