-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Do not hard error on broken constants in type aliases #82700
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
@@ -311,7 +311,19 @@ pub fn eval_to_allocation_raw_provider<'tcx>( | |||
// <https://github.com/rust-lang/rust/issues/71800>. | |||
let emit_as_lint = if let Some(def) = def.as_local() { | |||
// (Associated) consts only emit a lint, since they might be unused. | |||
matches!(tcx.def_kind(def.did.to_def_id()), DefKind::Const | DefKind::AssocConst) | |||
matches!(tcx.def_kind(def.did.to_def_id()), DefKind::Const | DefKind::AssocConst) || { |
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.
afaict this also only emits this as a lint even if we are using the associated const which doesn't seem desirable to me
what's the result for the following with this change?
type Foo = [u8; 0 - 1];
fn foo() -> Foo {
todo!()
}
and
struct Q<const N: usize>;
type Foo = Q<{0 - 1}>;
impl Default for Foo {
fn default() -> Self {
Q
}
}
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.
Yes, these will become future incompat lints, too
Oh no, why does this error reporting logic just keep becoming more bespoke. :( What is the long-term plan for this? |
This comment has been minimized.
This comment has been minimized.
c4daa53
to
63aee75
Compare
Interpreting the thumbs up and comment on https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/erroneous.20constants.20in.20type.20alias/near/229492342 as we don't need this and can just hard error |
In #69741 @estebank was adding WF checks to type aliases. This will evaluate all constants in a type alias, which wasn't happening before, so that would be a breaking change. Thus I proactively excluded these constants from the hard error list, and we instead emit the future incompat lint. More context: #69741 (comment)
r? @lcnr
cc @rust-lang/wg-const-eval