-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unwrap on a None
in librustc_mir/borrow_check/region_infer
when using rustc_args_required_const
#74599
Comments
The absolute smallest I was able to get it is this (playground) #![feature(rustc_attrs)]
extern {
// The external function & its parameters don't matter
#[rustc_args_required_const(0, 1)]
pub fn print_raw(data: *const u8, len: usize);
}
pub enum A {
B {},
C {},
D {},
}
fn main() {
// The variant used here doesn't matter
match (A::B {}) {
A::B {} => {
[()].iter().find(|v| *v == &());
}
A::C {} => {
print_raw(b"hello".as_ptr(), 5);
}
A::D {} => {}
}
} The specific external function doesn't seem to matter, nor do any variable names The panicking line of code is here, as the comment above it says, "Maybe everything is in the same SCC or something?" |
#![feature(rustc_attrs)]
#[rustc_args_required_const(1)]
fn intrinsic(a: u8){}
fn main() {
intrinsic(1);
} It appears this issue happens when in |
But in the original example, that's not true-- extern "C" {
#[rustc_args_required_const(0, 1)]
pub fn print_raw(data: *const u8, len: usize);
}
// later...
print_raw(b"hello".as_ptr(), 5); There are two parameters, and in the code I use both of them, yet the issue still seems to occur. |
I might've worded my response poorly, however I still stand my ground. I believe that whenever any of the indexes in #[rustc_args_required_const(0, 1)]
fn x(a: u8, b:u8) {} // won't error as 0 refers to `a`, and 1 refers to `b`
#[rustc_args_required_const(0, 1)]
fn y(a: u8) {} // will error as 1 refers to nonexistent parameter, i.e. parameter 1 doesn't exist (only parameter 0 exists) Does this match with your experience? |
This ICE's, it's the original example #![feature(rustc_attrs)]
extern "C" {
#[rustc_args_required_const(0, 1)]
pub fn print_raw(data: *const u8, len: usize);
}
pub enum Stmt {
Print {},
Let {},
Loop {}
}
pub fn interpret() {
match (Stmt::Print {}) {
Stmt::Let {} => {
[()].iter().find(|v| *v == &());
}
Stmt::Print {} => {
print_raw(b"hello".as_ptr(), 5);
}
Stmt::Loop {} => {}
}
} The indices line up with the function parameters, yet it still ICE's extern "C" {
#[rustc_args_required_const(0, 1)]
pub fn print_raw(data: *const u8, len: usize);
} |
Oh sorry, turns out I have misunderstood what @SuperTails meant. I guess I have accidentally found another ICE then. Edit: A bit minimized example this time of the correct ICE (playground) #![feature(rustc_attrs)]
#[rustc_args_required_const(0)]
pub fn print_raw(_: *const u8) {}
fn interpret() {
match true {
true => {
[()].iter().filter(|_| true);
}
false => {
print_raw("".as_ptr());
}
_ => {}
};
} |
The snippet in the original report starts ICE'ing on |
|
Code
Minimization by @Kixiron
Meta
This can only be built on nightly, since it requires an internal rustc attribute on
print_raw
.rustc +nightly --version --verbose
:Error output
When run with
RUST_BACKTRACE=1 rustc +nightly main.rs
Backtrace
The text was updated successfully, but these errors were encountered: