rust/tests/ui/const-generics/issues/issue-86820.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
493 B
Rust
Raw Normal View History

// Regression test for the ICE described in #86820.
#![allow(unused, dead_code)]
use std::ops::BitAnd;
const C: fn() = || is_set();
fn is_set() {
0xffu8.bit::<0>();
}
trait Bits {
fn bit<const I: u8>(self) -> bool;
}
impl Bits for u8 {
fn bit<const I: usize>(self) -> bool {
2022-05-06 05:37:22 -05:00
//~^ ERROR: method `bit` has an incompatible generic parameter for trait `Bits` [E0053]
let i = 1 << I;
let mask = u8::from(i);
mask & self == mask
}
}
fn main() {}