-
Notifications
You must be signed in to change notification settings - Fork 13k
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
ICE: #cfg usage in a macro call #73663
Comments
You are using I can't reproduce with your provided repository:
|
I'm going to remove |
Here is a smaller self-contained example failing on 1.46.0-nightly: // test.rs
use std::collections::BTreeMap;
#[derive(PartialEq, Eq, PartialOrd, Ord)]
struct KeyType;
struct Value;
trait IntoCborKey {
fn into_cbor_key(self) -> KeyType;
}
trait IntoCborValue {
fn into_cbor_value(self) -> Value;
}
impl IntoCborValue for i32 {
fn into_cbor_value(self) -> Value {
Value
}
}
impl IntoCborKey for i32 {
fn into_cbor_key(self) -> KeyType {
KeyType
}
}
macro_rules! cbor_map {
( $( $key:expr => $value:expr, )+ ) => {
cbor_map! ( $($key => $value),+ )
};
( $( $key:expr => $value:expr ),* ) => {
{
let mut _map = BTreeMap::new();
$(
_map.insert($key.into_cbor_key(), $value.into_cbor_value());
)*
_map
}
};
}
fn main() {
let _ = cbor_map! {
1 => 1,
2 => 2,
3 => 3,
#[cfg(test)]
4 => 4,
};
}
|
@spastorino Is the minimal example provided by @ia0 sufficient to put back this issue in the
@jyn514 FYI, this error was due to a git submodule that must be initialized in that repository before starting the compilation. |
Further minimized macro_rules! cbor_map {
($key:expr) => {
$key.signum();
};
}
fn main() {
cbor_map! { #[cfg(test)] 4};
} |
This is a fun case. AST represents The parser shouldn't do that because it changes observable behavior. fn main() {
let x = #[cfg(test)] 4; // error: removing an expression is not supported in this position
} So, merging the receiver and the arguments loses the part-of-the-list-ness property and should not be done until HIR. |
Assigning |
Issue: rust-lang/rust#73663
Issue: rust-lang/rust#73663
I get an ICE when trying to use
#[cfg(feature = "with_ctap2_1")]
inside a map-like macro call.I tried this code:
https://github.com/kaczmarczyck/OpenSK/commits/internal-compiler-error
The last commit does NOT reproduce the error, but shows the 2 line diff to commit
kaczmarczyck/OpenSK@4fec405
that is reproducing the problem.
Please clone the branch above, run ./setup.sh if you want to check that everything works, then execute:
RUST_BACKTRACE=1 cargo test --release --features std --verbose
I expected a regular compiler error (or a successful test).
Instead, the above mentioned ICE occurred.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: