Auto merge of #10008 - Jarcho:issue_9882, r=Manishearth
Treat custom enum discriminant values as constants fixes #9882 changelog: All lints: Don't lint in enum discriminant values when the suggestion won't work in a const context
This commit is contained in:
commit
e16a8b93ba
@ -196,7 +196,7 @@ pub fn in_constant(cx: &LateContext<'_>, id: HirId) -> bool {
|
||||
let parent_id = cx.tcx.hir().get_parent_item(id).def_id;
|
||||
match cx.tcx.hir().get_by_def_id(parent_id) {
|
||||
Node::Item(&Item {
|
||||
kind: ItemKind::Const(..) | ItemKind::Static(..),
|
||||
kind: ItemKind::Const(..) | ItemKind::Static(..) | ItemKind::Enum(..),
|
||||
..
|
||||
})
|
||||
| Node::TraitItem(&TraitItem {
|
||||
|
@ -45,3 +45,9 @@ mod cast_lossless_in_impl {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[repr(i64)]
|
||||
enum Test {
|
||||
A = u32::MAX as i64 + 1,
|
||||
}
|
||||
|
@ -45,3 +45,9 @@ pub const fn convert(x: u32) -> u64 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[repr(i64)]
|
||||
enum Test {
|
||||
A = u32::MAX as i64 + 1,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user