Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark const_trait_impl as active #87179

Merged
merged 1 commit into from
Jul 16, 2021
Merged
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
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ declare_features! (
(active, bindings_after_at, "1.41.0", Some(65490), None),

/// Allows `impl const Trait for T` syntax.
(incomplete, const_trait_impl, "1.42.0", Some(67792), None),
(active, const_trait_impl, "1.42.0", Some(67792), None),

/// Allows `T: ?const Trait` syntax in bounds.
(incomplete, const_trait_bound_opt_out, "1.42.0", Some(67794), None),
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/const-float-classify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#![feature(const_float_bits_conv)]
#![feature(const_float_classify)]
#![feature(const_trait_impl)]
#![allow(incomplete_features)]

// Don't promote
const fn nop<T>(x: T) -> T { x }
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/rustc-impl-const-stability.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// build-pass

#![crate_type = "lib"]
#![allow(incomplete_features)]
#![feature(staged_api)]
#![feature(const_trait_impl)]
#![stable(feature = "foo", since = "1.0.0")]
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// FIXME: This test should fail since, within a const impl of `Foo`, the bound on `Foo::Bar` should
// require a const impl of `Add` for the associated type.

#![allow(incomplete_features)]
#![feature(const_trait_impl)]

struct NonConstAdd(i32);
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rfc-2632-const-trait-impl/attr-misuse.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(const_trait_impl)]
#![allow(incomplete_features)]

#[default_method_body_is_const] //~ ERROR attribute should be applied
trait A {
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/rfc-2632-const-trait-impl/attr-misuse.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: attribute should be applied to a trait method with body
--> $DIR/attr-misuse.rs:4:1
--> $DIR/attr-misuse.rs:3:1
|
LL | #[default_method_body_is_const]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -13,15 +13,15 @@ LL | | }
| |_- not a trait method or missing a body

error: attribute should be applied to a trait method with body
--> $DIR/attr-misuse.rs:13:1
--> $DIR/attr-misuse.rs:12:1
|
LL | #[default_method_body_is_const]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | fn main() {}
| ------------ not a trait method or missing a body

error: attribute should be applied to a trait method with body
--> $DIR/attr-misuse.rs:6:5
--> $DIR/attr-misuse.rs:5:5
|
LL | #[default_method_body_is_const]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(const_trait_impl)]
#![allow(incomplete_features)]

pub trait MyTrait {
fn func(self);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(const_trait_impl)]
#![allow(incomplete_features)]

#![feature(staged_api)]
#![stable(feature = "rust1", since = "1.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(incomplete_features)]
#![feature(const_trait_impl)]

pub trait Plus {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/call-const-trait-method-fail.rs:25:5
--> $DIR/call-const-trait-method-fail.rs:24:5
|
LL | a.plus(b)
| ^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass

#![allow(incomplete_features)]
#![feature(const_trait_impl)]

struct Int(i32);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#![feature(const_trait_impl)]
#![feature(const_fn_trait_bound)]
#![allow(incomplete_features)]

struct S;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// ignore-test

#![feature(const_trait_impl)]
#![allow(incomplete_features)]

struct S;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#![feature(const_trait_impl)]
#![feature(const_fn_trait_bound)]
#![allow(incomplete_features)]

struct S;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(incomplete_features)]
#![feature(const_trait_impl)]

pub struct Int(i32);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `std::ops::Add` for type `i32`
--> $DIR/const-and-non-const-impl.rs:6:1
--> $DIR/const-and-non-const-impl.rs:5:1
|
LL | impl const std::ops::Add for i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -8,7 +8,7 @@ LL | impl const std::ops::Add for i32 {
- impl Add for i32;

error[E0119]: conflicting implementations of trait `std::ops::Add` for type `Int`
--> $DIR/const-and-non-const-impl.rs:24:1
--> $DIR/const-and-non-const-impl.rs:23:1
|
LL | impl std::ops::Add for Int {
| -------------------------- first implementation here
Expand All @@ -17,7 +17,7 @@ LL | impl const std::ops::Add for Int {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Int`

error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/const-and-non-const-impl.rs:6:1
--> $DIR/const-and-non-const-impl.rs:5:1
|
LL | impl const std::ops::Add for i32 {
| ^^^^^^^^^^^-------------^^^^^---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(incomplete_features)]
#![feature(const_trait_impl)]

struct S;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/const-check-fns-in-const-impl.rs:12:16
--> $DIR/const-check-fns-in-const-impl.rs:11:16
|
LL | fn foo() { non_const() }
| ^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![feature(const_trait_impl)]
#![feature(const_fn_trait_bound)] // FIXME is this needed?
#![allow(incomplete_features)]

trait ConstDefaultFn: Sized {
fn b(self);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/const-default-method-bodies.rs:26:5
--> $DIR/const-default-method-bodies.rs:25:5
|
LL | NonConstImpl.a();
| ^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(const_trait_impl)]
#![allow(incomplete_features)]

struct Foo;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected identifier, found keyword `impl`
--> $DIR/const-impl-norecover.rs:6:7
--> $DIR/const-impl-norecover.rs:5:7
|
LL | const impl Foo {
| ^^^^ expected identifier, found keyword
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(const_trait_impl)]
#![allow(incomplete_features)]

trait Foo {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected identifier, found keyword `impl`
--> $DIR/const-impl-recovery.rs:6:7
--> $DIR/const-impl-recovery.rs:5:7
|
LL | const impl Foo for i32 {}
| ^^^^ expected identifier, found keyword
Expand All @@ -10,7 +10,7 @@ LL | impl const Foo for i32 {}
|-- ^^^^^

error: expected identifier, found keyword `impl`
--> $DIR/const-impl-recovery.rs:10:7
--> $DIR/const-impl-recovery.rs:9:7
|
LL | const impl<T: Foo> Bar for T {}
| ^^^^ expected identifier, found keyword
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/cross-crate.rs:16:5
--> $DIR/cross-crate.rs:15:5
|
LL | NonConst.func();
| ^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rfc-2632-const-trait-impl/cross-crate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// revisions: stock gated
#![cfg_attr(gated, feature(const_trait_impl))]
#![allow(incomplete_features)]

// aux-build: cross-crate.rs
extern crate cross_crate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/cross-crate.rs:16:5
--> $DIR/cross-crate.rs:15:5
|
LL | NonConst.func();
| ^^^^^^^^^^^^^^^

error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/cross-crate.rs:18:5
--> $DIR/cross-crate.rs:17:5
|
LL | Const.func();
| ^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: fatal error triggered by #[rustc_error]
--> $DIR/feature-gate.rs:14:1
--> $DIR/feature-gate.rs:13:1
|
LL | fn main() {}
| ^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rfc-2632-const-trait-impl/feature-gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// gate-test-const_trait_impl

#![cfg_attr(gated, feature(const_trait_impl))]
#![allow(incomplete_features)]
#![feature(rustc_attrs)]

struct S;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: const trait impls are experimental
--> $DIR/feature-gate.rs:10:6
--> $DIR/feature-gate.rs:9:6
|
LL | impl const T for S {}
| ^^^^^
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rfc-2632-const-trait-impl/generic-bound.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass

#![allow(incomplete_features)]
#![feature(const_trait_impl)]
#![feature(const_fn_trait_bound)]

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Regression test for #69615.

#![feature(const_trait_impl)]
#![allow(incomplete_features)]

pub trait MyTrait {
fn method(&self) -> Option<()>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0744]: `?` is not allowed in a `const fn`
--> $DIR/hir-const-check.rs:12:9
--> $DIR/hir-const-check.rs:11:9
|
LL | Some(())?;
| ^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(const_trait_impl)]
#![allow(incomplete_features)]

trait Tr {
fn req(&self);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: const trait implementations may not use non-const default functions
--> $DIR/impl-with-default-fn.rs:18:1
--> $DIR/impl-with-default-fn.rs:17:1
|
LL | / impl const Tr for S {
LL | | fn req(&self) {}
Expand All @@ -9,7 +9,7 @@ LL | | }
= note: `prov` not implemented

error: const trait implementations may not use non-const default functions
--> $DIR/impl-with-default-fn.rs:33:1
--> $DIR/impl-with-default-fn.rs:32:1
|
LL | / impl const Tr for u32 {
LL | | fn req(&self) {}
Expand All @@ -20,7 +20,7 @@ LL | | }
= note: `prov` not implemented

error[E0046]: not all trait items implemented, missing: `req`
--> $DIR/impl-with-default-fn.rs:27:1
--> $DIR/impl-with-default-fn.rs:26:1
|
LL | fn req(&self);
| -------------- `req` from trait
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rfc-2632-const-trait-impl/stability.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(incomplete_features)]
#![feature(allow_internal_unstable)]
#![feature(const_add)]
#![feature(const_trait_impl)]
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/rfc-2632-const-trait-impl/stability.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: trait methods cannot be stable const fn
--> $DIR/stability.rs:14:5
--> $DIR/stability.rs:13:5
|
LL | / fn sub(self, rhs: Self) -> Self {
LL | |
Expand All @@ -8,7 +8,7 @@ LL | | }
| |_____^

error: `<Int as Add>::add` is not yet stable as a const fn
--> $DIR/stability.rs:32:5
--> $DIR/stability.rs:31:5
|
LL | Int(1i32) + Int(2i32)
| ^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rfc-2632-const-trait-impl/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#![feature(const_trait_bound_opt_out)]
#![feature(const_trait_impl)]
#![allow(incomplete_features)]

// For now, this parses since an error does not occur until AST lowering.
impl ?const T {}