mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 23:20:39 +00:00
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
3 changed files with 13 additions and 1 deletions
|
@ -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 @@ mod cast_lossless_in_impl {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[repr(i64)]
|
||||
enum Test {
|
||||
A = u32::MAX as i64 + 1,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue