-
Notifications
You must be signed in to change notification settings - Fork 13.5k
correctly lower impl const
to bind to host effect param
#114545
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
Merged
+463
−371
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1349,7 +1349,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
} | ||
} | ||
GenericParamDefKind::Const { has_default } => { | ||
if !infer_args && has_default { | ||
if !infer_args | ||
&& has_default | ||
&& !tcx.has_attr(param.def_id, sym::rustc_host) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this work for desugared params? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. desugared params get this attribute as well: link |
||
{ | ||
tcx.const_param_default(param.def_id) | ||
.instantiate(tcx, args.unwrap()) | ||
.into() | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 35 additions & 7 deletions
42
tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,39 @@ | ||
error: const `impl` for trait `Add` which is not marked with `#[const_trait]` | ||
--> $DIR/unify-op-with-fn-call.rs:10:12 | ||
error[E0741]: `Foo` must implement `ConstParamTy` to be used as the type of a const generic parameter | ||
--> $DIR/unify-op-with-fn-call.rs:18:29 | ||
| | ||
LL | impl const std::ops::Add for Foo { | ||
| ^^^^^^^^^^^^^ | ||
LL | struct Evaluatable<const N: Foo>; | ||
| ^^^ | ||
| | ||
help: add `#[derive(ConstParamTy)]` to the struct | ||
| | ||
LL + #[derive(ConstParamTy)] | ||
LL | struct Foo(u8); | ||
| | ||
|
||
error[E0741]: `Foo` must implement `ConstParamTy` to be used as the type of a const generic parameter | ||
--> $DIR/unify-op-with-fn-call.rs:20:17 | ||
| | ||
LL | fn foo<const N: Foo>(a: Evaluatable<{ N + N }>) { | ||
| ^^^ | ||
| | ||
help: add `#[derive(ConstParamTy)]` to the struct | ||
| | ||
LL + #[derive(ConstParamTy)] | ||
LL | struct Foo(u8); | ||
| | ||
|
||
error[E0741]: `Foo` must implement `ConstParamTy` to be used as the type of a const generic parameter | ||
--> $DIR/unify-op-with-fn-call.rs:24:17 | ||
| | ||
LL | fn bar<const N: Foo>() {} | ||
| ^^^ | ||
| | ||
help: add `#[derive(ConstParamTy)]` to the struct | ||
| | ||
LL + #[derive(ConstParamTy)] | ||
LL | struct Foo(u8); | ||
| | ||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` | ||
= note: adding a non-const method body in the future would be a breaking change | ||
|
||
error: aborting due to previous error | ||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0741`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]` | ||
--> $DIR/const-try.rs:15:12 | ||
error[E0015]: `?` cannot determine the branch of `TryMe` in constant functions | ||
--> $DIR/const-try.rs:33:5 | ||
| | ||
LL | impl const FromResidual<Error> for TryMe { | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | TryMe?; | ||
| ^^^^^^ | ||
| | ||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` | ||
= note: adding a non-const method body in the future would be a breaking change | ||
|
||
error: const `impl` for trait `Try` which is not marked with `#[const_trait]` | ||
--> $DIR/const-try.rs:21:12 | ||
note: impl defined here, but it is not `const` | ||
--> $DIR/const-try.rs:21:1 | ||
| | ||
LL | impl const Try for TryMe { | ||
| ^^^ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
||
error[E0015]: `?` cannot convert from residual of `TryMe` in constant functions | ||
--> $DIR/const-try.rs:33:5 | ||
| | ||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` | ||
= note: adding a non-const method body in the future would be a breaking change | ||
LL | TryMe?; | ||
| ^^^^^^ | ||
| | ||
note: impl defined here, but it is not `const` | ||
--> $DIR/const-try.rs:15:1 | ||
| | ||
LL | impl const FromResidual<Error> for TryMe { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0015`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/ui/rfcs/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#![feature(const_trait_impl)] | ||
#![feature(const_trait_impl, effects)] | ||
|
||
#[const_trait] | ||
pub trait MyTrait { | ||
|
2 changes: 1 addition & 1 deletion
2
tests/ui/rfcs/rfc-2632-const-trait-impl/auxiliary/staged-api.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
error[E0015]: cannot call non-const fn `<u32 as Plus>::plus` in constant functions | ||
error[E0277]: the trait bound `u32: ~const Plus` is not satisfied | ||
--> $DIR/call-const-trait-method-fail.rs:25:7 | ||
| | ||
LL | a.plus(b) | ||
| ^^^^^^^ | ||
| ^^^^ the trait `Plus` is not implemented for `u32` | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
= help: the trait `Plus` is implemented for `u32` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0015`. | ||
For more information about this error, try `rustc --explain E0277`. |
28 changes: 16 additions & 12 deletions
28
tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
error: const `impl` for trait `Add` which is not marked with `#[const_trait]` | ||
--> $DIR/call-const-trait-method-pass.rs:7:12 | ||
error[E0015]: cannot call non-const fn `<i32 as Plus>::plus` in constant functions | ||
--> $DIR/call-const-trait-method-pass.rs:36:7 | ||
| | ||
LL | impl const std::ops::Add for Int { | ||
| ^^^^^^^^^^^^^ | ||
LL | a.plus(b) | ||
| ^^^^^^^ | ||
| | ||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` | ||
= note: adding a non-const method body in the future would be a breaking change | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
||
error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` | ||
--> $DIR/call-const-trait-method-pass.rs:15:12 | ||
error[E0015]: cannot call non-const operator in constants | ||
--> $DIR/call-const-trait-method-pass.rs:39:22 | ||
| | ||
LL | const ADD_INT: Int = Int(1i32) + Int(2i32); | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
LL | impl const PartialEq for Int { | ||
| ^^^^^^^^^ | ||
note: impl defined here, but it is not `const` | ||
--> $DIR/call-const-trait-method-pass.rs:7:1 | ||
| | ||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` | ||
= note: adding a non-const method body in the future would be a breaking change | ||
LL | impl const std::ops::Add for Int { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0015`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 1 addition & 10 deletions
11
tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,8 @@ | ||
error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` | ||
--> $DIR/call-generic-method-pass.rs:9:12 | ||
| | ||
LL | impl const PartialEq for S { | ||
| ^^^^^^^^^ | ||
| | ||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` | ||
= note: adding a non-const method body in the future would be a breaking change | ||
|
||
error: ~const can only be applied to `#[const_trait]` traits | ||
--> $DIR/call-generic-method-pass.rs:18:32 | ||
| | ||
LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool { | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to previous error | ||
|
27 changes: 16 additions & 11 deletions
27
tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
error: const `impl` for trait `Add` which is not marked with `#[const_trait]` | ||
--> $DIR/const-and-non-const-impl.rs:7:12 | ||
error[E0117]: only traits defined in the current crate can be implemented for primitive types | ||
--> $DIR/const-and-non-const-impl.rs:7:1 | ||
| | ||
LL | impl const std::ops::Add for i32 { | ||
| ^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^-------------^^^^^--- | ||
| | | | | ||
| | | `i32` is not defined in the current crate | ||
| | `i32` is not defined in the current crate | ||
| impl doesn't use only types from inside the current crate | ||
| | ||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` | ||
= note: adding a non-const method body in the future would be a breaking change | ||
= note: define and implement a trait or new type instead | ||
|
||
error: const `impl` for trait `Add` which is not marked with `#[const_trait]` | ||
--> $DIR/const-and-non-const-impl.rs:23:12 | ||
error[E0119]: conflicting implementations of trait `Add` for type `Int` | ||
--> $DIR/const-and-non-const-impl.rs:23:1 | ||
| | ||
LL | impl std::ops::Add for Int { | ||
| -------------------------- first implementation here | ||
... | ||
LL | impl const std::ops::Add for Int { | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` | ||
= note: adding a non-const method body in the future would be a breaking change | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Int` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0117, E0119. | ||
For more information about an error, try `rustc --explain E0117`. |
2 changes: 1 addition & 1 deletion
2
tests/ui/rfcs/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#![feature(const_trait_impl)] | ||
#![feature(const_trait_impl, effects)] | ||
|
||
struct S; | ||
#[const_trait] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
error[E0015]: cannot call non-const fn `<NonConstImpl as ConstDefaultFn>::a` in constant functions | ||
error[E0277]: the trait bound `NonConstImpl: ~const ConstDefaultFn` is not satisfied | ||
--> $DIR/const-default-method-bodies.rs:24:18 | ||
| | ||
LL | NonConstImpl.a(); | ||
| ^^^ | ||
| ^ the trait `ConstDefaultFn` is not implemented for `NonConstImpl` | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
= help: the trait `ConstDefaultFn` is implemented for `NonConstImpl` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0015`. | ||
For more information about this error, try `rustc --explain E0277`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 3 additions & 20 deletions
23
tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,11 @@ | ||
error[E0015]: cannot call non-const fn `<T as A>::a` in constant functions | ||
--> $DIR/const-drop-fail-2.rs:25:9 | ||
| | ||
LL | T::a(); | ||
| ^^^^^^ | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
||
error[E0493]: destructor of `T` cannot be evaluated at compile-time | ||
--> $DIR/const-drop-fail-2.rs:29:36 | ||
--> $DIR/const-drop-fail-2.rs:21:36 | ||
| | ||
LL | const fn check<T: ~const Destruct>(_: T) {} | ||
| ^ - value is dropped here | ||
| | | ||
| the destructor for this type cannot be evaluated in constant functions | ||
|
||
error[E0015]: cannot call non-const fn `<T as A>::a` in constant functions | ||
--> $DIR/const-drop-fail-2.rs:39:9 | ||
| | ||
LL | T::a(); | ||
| ^^^^^^ | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
||
error: aborting due to 3 previous errors | ||
error: aborting due to previous error | ||
|
||
Some errors have detailed explanations: E0015, E0493. | ||
For more information about an error, try `rustc --explain E0015`. | ||
For more information about this error, try `rustc --explain E0493`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-requires-const-trait.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
#![feature(const_trait_impl)] | ||
// known-bug: #110395 | ||
|
||
#![feature(const_trait_impl, effects)] | ||
|
||
pub trait A {} | ||
//~^ HELP: mark `A` as const | ||
// FIXME ~^ HELP: mark `A` as const | ||
|
||
impl const A for () {} | ||
//~^ ERROR: const `impl` for trait `A` which is not marked with `#[const_trait]` | ||
// FIXME ~^ ERROR: const `impl` for trait `A` which is not marked with `#[const_trait]` | ||
|
||
fn main() {} |
2 changes: 1 addition & 1 deletion
2
tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-requires-const-trait.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#[derive_const(Default)] //~ ERROR use of unstable library feature | ||
//~^ ERROR not marked with `#[const_trait]` | ||
pub struct S; | ||
|
||
fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// known-bug: #110395 | ||
#![feature(derive_const)] | ||
#![feature(derive_const, effects)] | ||
|
||
pub struct A; | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
error[E0015]: cannot call non-const fn `<cross_crate::NonConst as cross_crate::MyTrait>::func` in constant functions | ||
error[E0277]: the trait bound `cross_crate::NonConst: ~const cross_crate::MyTrait` is not satisfied | ||
--> $DIR/cross-crate.rs:17:14 | ||
| | ||
LL | NonConst.func(); | ||
| ^^^^^^ | ||
| ^^^^ the trait `cross_crate::MyTrait` is not implemented for `cross_crate::NonConst` | ||
| | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
= help: the trait `cross_crate::MyTrait` is implemented for `cross_crate::NonConst` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0015`. | ||
For more information about this error, try `rustc --explain E0277`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/ui/rfcs/rfc-2632-const-trait-impl/do-not-const-check-override.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 11 additions & 6 deletions
17
tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
error: const `impl` for trait `Add` which is not marked with `#[const_trait]` | ||
--> $DIR/generic-bound.rs:16:15 | ||
error[E0015]: cannot call non-const operator in constant functions | ||
--> $DIR/generic-bound.rs:25:5 | ||
| | ||
LL | impl<T> const std::ops::Add for S<T> { | ||
| ^^^^^^^^^^^^^ | ||
LL | arg + arg | ||
| ^^^^^^^^^ | ||
| | ||
note: impl defined here, but it is not `const` | ||
--> $DIR/generic-bound.rs:16:1 | ||
| | ||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` | ||
= note: adding a non-const method body in the future would be a breaking change | ||
LL | impl<T> const std::ops::Add for S<T> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0015`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 21 additions & 12 deletions
33
tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
error: const `impl` for trait `Try` which is not marked with `#[const_trait]` | ||
--> $DIR/trait-default-body-stability.rs:18:12 | ||
error[E0015]: `?` cannot determine the branch of `T` in constant functions | ||
--> $DIR/trait-default-body-stability.rs:44:9 | ||
| | ||
LL | impl const Try for T { | ||
| ^^^ | ||
LL | T? | ||
| ^^ | ||
| | ||
note: impl defined here, but it is not `const` | ||
--> $DIR/trait-default-body-stability.rs:18:1 | ||
| | ||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` | ||
= note: adding a non-const method body in the future would be a breaking change | ||
LL | impl const Try for T { | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
||
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]` | ||
--> $DIR/trait-default-body-stability.rs:33:12 | ||
error[E0015]: `?` cannot convert from residual of `T` in constant functions | ||
--> $DIR/trait-default-body-stability.rs:44:9 | ||
| | ||
LL | impl const FromResidual for T { | ||
| ^^^^^^^^^^^^ | ||
LL | T? | ||
| ^^ | ||
| | ||
note: impl defined here, but it is not `const` | ||
--> $DIR/trait-default-body-stability.rs:33:1 | ||
| | ||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` | ||
= note: adding a non-const method body in the future would be a breaking change | ||
LL | impl const FromResidual for T { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0015`. |
2 changes: 1 addition & 1 deletion
2
tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-run.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe assert that you are actually removing the
host
param, and not something else that snuck inThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This turns out to be a bit more complicated and I didn't want to look inside bodies, so I just added the attr to all automatically generated bodies and asserted that the attr exists instead.