-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Do not resolve associated const when there is no provided value #99449
Merged
bors
merged 1 commit into
rust-lang:master
from
compiler-errors:assoc-const-missing-item
Jul 24, 2022
Merged
Changes from all commits
Commits
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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#![feature(const_trait_impl)] | ||
|
||
trait Trait { | ||
const N: usize; | ||
} | ||
|
||
impl const Trait for i32 {} | ||
//~^ ERROR not all trait items implemented, missing: `N` | ||
|
||
fn f() | ||
where | ||
[(); <i32 as Trait>::N]:, | ||
{} | ||
|
||
fn main() {} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0046]: not all trait items implemented, missing: `N` | ||
--> $DIR/issue-98629.rs:7:1 | ||
| | ||
LL | const N: usize; | ||
| -------------- `N` from trait | ||
... | ||
LL | impl const Trait for i32 {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ missing `N` in implementation | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0046`. |
This file contains 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 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 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.
TooGeneric
here is a bit of a misnomer, since it really should be "not concrete" or something.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.
🤔 it's weird that we have to actually deal with
TooGeneric
here 🤔this should already be guarded against by the
uniify_failure_kind
. Do any tests change if you always useThere 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.
I changed this to always delay a bug, and not specially deal with
TooGeneric
in the case of infer/param types:and I get two ICEs, see this gist: https://gist.github.com/compiler-errors/146cd973d15ddc7fcfee6ff28a9ac5e0
Was that what you were asking me to try, @lcnr?
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.
yeah, so
InferCtxt::const_eval_resolve
is not not doing what we need for thisrust/compiler/rustc_infer/src/infer/mod.rs
Lines 1664 to 1671 in 03d488b
I guess what we should do is:
match on
AbstractConst::new(self.tcx, unevaluated.shrink());
Ok(None)
is already correct.Err(emitted)
->NotConstEvaluatable::Error(emitted)
Ok(Some(x))
-> the inference vars aren't used in the anon const, replace them with placeholdersfeel free to do that in this PR, otherwise r=me
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.
@lcnr: I'm gonna do it in a follow-up PR, since this solution doesn't really rely on that change, does it?