From be4b230dbc595435b6b8d5a187fb295c89e9f77e Mon Sep 17 00:00:00 2001 From: "lucas.plantrose" Date: Wed, 18 Dec 2024 10:46:01 +0100 Subject: [PATCH] gcc/rust/ChangeLog: * checks/errors/rust-feature-gate.cc (FeatureGate::visit): cleaning file. * checks/errors/rust-feature-gate.h: cleaning file. gcc/testsuite/ChangeLog: * rust/compile/features/associated_type_defaults_activated.rs: Changed test to code that used the tested feature. * rust/compile/features/associated_type_defaults_not_activated.rs: New test. Will be failing, but dg-error not set up yet. Signed-off-by: lucas.plantrose --- gcc/rust/checks/errors/rust-feature-gate.cc | 8 +------- gcc/rust/checks/errors/rust-feature-gate.h | 1 - gcc/rust/checks/errors/rust-feature.cc | 15 ++++++++++----- .../associated_type_defaults_activated.rs | 14 ++++++++++++++ .../associated_type_defaults_not_activated.rs | 15 +++++++++++++++ 5 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/rust/compile/features/associated_type_defaults_not_activated.rs diff --git a/gcc/rust/checks/errors/rust-feature-gate.cc b/gcc/rust/checks/errors/rust-feature-gate.cc index b2ef807371ef..2b15f1142a62 100644 --- a/gcc/rust/checks/errors/rust-feature-gate.cc +++ b/gcc/rust/checks/errors/rust-feature-gate.cc @@ -275,15 +275,9 @@ FeatureGate::visit (AST::ImplTraitTypeOneBound &type) void FeatureGate::visit (AST::Attribute &attr) { - if (attr.get_path().as_string() == "register_tool") + if (attr.get_path ().as_string () == "register_tool") gate (Feature::Name::REGISTER_TOOL, attr.get_locus (), "register tool is an experimental feature"); } -void -FeatureGate::visit (AST::TypeAlias &type) -{ - -} - } // namespace Rust diff --git a/gcc/rust/checks/errors/rust-feature-gate.h b/gcc/rust/checks/errors/rust-feature-gate.h index 73c448948b31..d5b5041de8b0 100644 --- a/gcc/rust/checks/errors/rust-feature-gate.h +++ b/gcc/rust/checks/errors/rust-feature-gate.h @@ -55,7 +55,6 @@ class FeatureGate : public AST::DefaultASTVisitor void visit (AST::ImplTraitType &type) override; void visit (AST::ImplTraitTypeOneBound &type) override; void visit (AST::Attribute &attr) override; - void visit (AST::TypeAlias &attr) override; private: void gate (Feature::Name name, location_t loc, const std::string &error_msg); diff --git a/gcc/rust/checks/errors/rust-feature.cc b/gcc/rust/checks/errors/rust-feature.cc index e02ef21c9268..5d0c2344f877 100644 --- a/gcc/rust/checks/errors/rust-feature.cc +++ b/gcc/rust/checks/errors/rust-feature.cc @@ -59,17 +59,22 @@ Feature::create (Feature::Name f) return Feature (f, Feature::State::ACTIVE, "optin_builtin_traits", "1.0.0", 13231); case Feature::Name::ARBITRARY_SELF_TYPES: - return Feature (f, Feature::State::ACCEPTED, "arbitrary_self_types", "1.49.0", 44874); + return Feature (f, Feature::State::ACCEPTED, "arbitrary_self_types", + "1.49.0", 44874); case Feature::Name::DOC_CFG: return Feature (f, Feature::State::ACCEPTED, "doc_cfg", "1.49.0", 43781); case Feature::Name::IMPL_TRAIT_IN_ASSOC_TYPE: - return Feature (f, Feature::State::ACCEPTED, "impl_trait_in_assoc_type", "1.49.0", 63063); + return Feature (f, Feature::State::ACCEPTED, "impl_trait_in_assoc_type", + "1.49.0", 63063); case Feature::Name::REGISTER_TOOL: - return Feature (f, Feature::State::ACCEPTED, "register_tool", "1.49.0", 66079); + return Feature (f, Feature::State::ACCEPTED, "register_tool", "1.49.0", + 66079); case Feature::Name::ASSOCIATED_TYPE_DEFAULTS: - return Feature (f, Feature::State::ACCEPTED, "associated_type_defaults", "1.49.0", 29661); + return Feature (f, Feature::State::ACCEPTED, "associated_type_defaults", + "1.49.0", 29661); case Feature::Name::CONST_TRAIT_IMPL: - return Feature (f, Feature::State::ACCEPTED, "const_trait_impl", "1.49.0", 67792); + return Feature (f, Feature::State::ACCEPTED, "const_trait_impl", "1.49.0", + 67792); default: rust_unreachable (); } diff --git a/gcc/testsuite/rust/compile/features/associated_type_defaults_activated.rs b/gcc/testsuite/rust/compile/features/associated_type_defaults_activated.rs index ab4d135b6626..90bb023f7055 100644 --- a/gcc/testsuite/rust/compile/features/associated_type_defaults_activated.rs +++ b/gcc/testsuite/rust/compile/features/associated_type_defaults_activated.rs @@ -1 +1,15 @@ +// check-pass + +// This is another instance of the "normalizations don't work" issue with +// defaulted associated types. + #![feature(associated_type_defaults)] + +pub trait Emitter<'a> { + type Ctxt: 'a; + type CtxtBrw: 'a = &'a Self::Ctxt; + + fn get_cx(&'a self) -> Self::CtxtBrw; +} + +fn main() {} diff --git a/gcc/testsuite/rust/compile/features/associated_type_defaults_not_activated.rs b/gcc/testsuite/rust/compile/features/associated_type_defaults_not_activated.rs new file mode 100644 index 000000000000..579703a1d132 --- /dev/null +++ b/gcc/testsuite/rust/compile/features/associated_type_defaults_not_activated.rs @@ -0,0 +1,15 @@ +// check-pass + +// This is another instance of the "normalizations don't work" issue with +// defaulted associated types. + +// #![feature(associated_type_defaults)] + +pub trait Emitter<'a> { + type Ctxt: 'a; + type CtxtBrw: 'a = &'a Self::Ctxt; + + fn get_cx(&'a self) -> Self::CtxtBrw; +} + +fn main() {}