Visitar URL original
Merge pull request #496 from bitflags/fix/rustc-ice · bitflags/bitflags@48f4f1a · GitHub
Skip to content

Commit 48f4f1a

Browse files
authored
Merge pull request #496 from bitflags/fix/rustc-ice
Re-pull const declarations outside of nested const
2 parents c3f8d31 + 2c0b042 commit 48f4f1a

3 files changed

Lines changed: 51 additions & 19 deletions

File tree

‎src/lib.rs‎

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,31 @@ macro_rules! bitflags {
494494
$vis struct $BitFlags
495495
}
496496

497+
// Workaround for: https://github.com/bitflags/bitflags/issues/320
498+
// Pulled outside of the `const _: () = {}` block to avoid triggering an ICE
499+
$crate::__impl_public_bitflags_consts! {
500+
#[allow(
501+
dead_code,
502+
deprecated,
503+
unused_doc_comments,
504+
unused_attributes,
505+
unused_mut,
506+
unused_imports,
507+
non_upper_case_globals,
508+
clippy::min_ident_chars,
509+
clippy::assign_op_pattern,
510+
clippy::indexing_slicing,
511+
clippy::same_name_method,
512+
clippy::iter_without_into_iter,
513+
)]
514+
$BitFlags: $T {
515+
$(
516+
$(#[$inner $($args)*])*
517+
const $Flag = $value;
518+
)*
519+
}
520+
}
521+
497522
#[allow(
498523
dead_code,
499524
deprecated,
@@ -515,15 +540,6 @@ macro_rules! bitflags {
515540
$vis struct InternalBitFlags: $T
516541
}
517542

518-
$crate::__impl_public_bitflags_consts! {
519-
$BitFlags: $T {
520-
$(
521-
$(#[$inner $($args)*])*
522-
const $Flag = $value;
523-
)*
524-
}
525-
}
526-
527543
$crate::__impl_internal_bitflags! {
528544
InternalBitFlags: $T, $BitFlags {
529545
$(
@@ -571,6 +587,29 @@ macro_rules! bitflags {
571587

572588
$($t:tt)*
573589
) => {
590+
// Workaround for: https://github.com/bitflags/bitflags/issues/320
591+
// Pulled outside of the `const _: () = {}` block to avoid triggering an ICE
592+
$crate::__impl_public_bitflags_consts! {
593+
#[allow(
594+
dead_code,
595+
deprecated,
596+
unused_doc_comments,
597+
unused_attributes,
598+
unused_mut,
599+
unused_imports,
600+
non_upper_case_globals,
601+
clippy::min_ident_chars,
602+
clippy::assign_op_pattern,
603+
clippy::iter_without_into_iter,
604+
)]
605+
$BitFlags: $T {
606+
$(
607+
$(#[$inner $($args)*])*
608+
const $Flag = $value;
609+
)*
610+
}
611+
}
612+
574613
#[allow(
575614
dead_code,
576615
deprecated,
@@ -584,15 +623,6 @@ macro_rules! bitflags {
584623
clippy::iter_without_into_iter,
585624
)]
586625
const _: () = {
587-
$crate::__impl_public_bitflags_consts! {
588-
$BitFlags: $T {
589-
$(
590-
$(#[$inner $($args)*])*
591-
const $Flag = $value;
592-
)*
593-
}
594-
}
595-
596626
$crate::__impl_public_bitflags! {
597627
$(#[$outer])*
598628
$BitFlags: $T, $BitFlags {

‎src/public.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ macro_rules! __impl_public_bitflags {
193193

194194
fn from_name(name) {
195195
mod __bitflags_flag_names {
196+
#[allow(unused_imports)]
196197
use super::*;
197198

198199
$(
@@ -549,6 +550,7 @@ macro_rules! __impl_public_bitflags_consts {
549550
impl $crate::Flags for $PublicBitFlags {
550551
const FLAGS: &'static [$crate::Flag<$PublicBitFlags>] = {
551552
mod __bitflags_flag_names {
553+
#[allow(unused_imports)]
552554
use super::*;
553555

554556
$(

‎src/tests.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ mod intersects;
2222
mod is_all;
2323
mod is_empty;
2424
mod iter;
25+
mod iter_equal_names;
2526
mod known_bits;
2627
mod parser;
2728
mod remove;
@@ -30,7 +31,6 @@ mod truncate;
3031
mod union;
3132
mod unknown;
3233
mod unknown_bits;
33-
mod iter_equal_names;
3434

3535
mod custom {
3636
pub const NAME: &'static str = "custom";

0 commit comments

Comments
 (0)