#include "rust-feature-gate.h"
#include "rust-abi.h"
#include "rust-ast-visitor.h"
+#include "rust-feature.h"
namespace Rust {
"extern types are experimental");
}
+void
+FeatureGate::visit (AST::TraitImpl &impl)
+{
+ if (impl.is_exclam ())
+ gate (Feature::Name::NEGATIVE_IMPLS, impl.get_locus (),
+ "negative_impls are not yet implemented");
+};
+
} // namespace Rust
void visit (AST::StaticItem &static_item) override {}
void visit (AST::TraitItemConst &item) override {}
void visit (AST::TraitItemType &item) override {}
+ void visit (AST::TraitImpl &impl) override;
void visit (AST::Trait &trait) override {}
void visit (AST::ExternalTypeItem &item) override;
void visit (AST::ExternalStaticItem &item) override {}
case Feature::Name::EXTERN_TYPES:
return Feature (Feature::Name::EXTERN_TYPES, Feature::State::ACTIVE,
"extern_types", "1.23.0", 43467, tl::nullopt, "");
+ case Feature::Name::NEGATIVE_IMPLS:
+ return Feature (Feature::Name::NEGATIVE_IMPLS, Feature::State::ACTIVE,
+ "negative_impls", "1.0.0", 68318, tl::nullopt, "");
default:
rust_unreachable ();
}
{"intrinsics", Feature::Name::INTRINSICS},
{"rustc_attrs", Feature::Name::RUSTC_ATTRS},
{"decl_macro", Feature::Name::DECL_MACRO},
+ {"negative_impls", Feature::Name::NEGATIVE_IMPLS},
// TODO: Rename to "auto_traits" when supporting
// later Rust versions
{"optin_builtin_traits", Feature::Name::AUTO_TRAITS},
{
ASSOCIATED_TYPE_BOUNDS,
INTRINSICS,
+ NEGATIVE_IMPLS,
RUSTC_ATTRS,
DECL_MACRO,
AUTO_TRAITS,
--- /dev/null
+#![feature(negative_impls)]
+
+trait ExampleTrait {}
+
+impl !ExampleTrait for i32 {}
+
+
+fn main() {}
--- /dev/null
+// This test case should error out since we haven't included the negative_impls feature
+// Output from online rust compiler 2021 ver
+// Compiling playground v0.0.1 (/playground)
+// error[E0658]: negative trait bounds are not yet fully implemented; use marker types for now
+// --> src/main.rs:8:6
+// |
+// 8 | impl !ExampleTrait for i32 {}//
+// | ^^^^^^^^^^^^^
+// |
+// = note: see issue #68318 <https://github.com/rust-lang/rust/issues/68318> for more information
+
+// For more information about this error, try `rustc --explain E0658`.
+// error: could not compile `playground` (bin "playground") due to 1 previous error
+trait ExampleTrait {}
+
+impl !ExampleTrait for i32 {} // { dg-error "negative_impls are not yet implemented" }
\ No newline at end of file