Repository navigation
debug ice: E0423 suggests assoc fns inside macro_rules #118784
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.Status: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some wayThis issue requires a build of rustc or tooling with debug-assertions in some way
Description
Code
use std::collections::HashMap;
macro_rules! all_sync_send {
($ctor:expr, $($iter:expr),+) => ({
$(
let mut x = $ctor;
is_sync(x.$iter());
let mut y = $ctor;
is_send(y.$iter());
)+
})
}
fn main() {
all_sync_send!(HashMap, HashMap);
}Meta
rustc --version --verbose:
f967532a47eb728ada44473a5c4c2eca1a45fe30
Error output
This is the offending suggestion
error[E0423]: expected function, tuple struct or tuple variant, found struct `HashMap`
--> C066.rs:9:23
|
9 | is_send(y.$iter());
| ^^^^^^^
...
15 | all_sync_send!(HashMap, HashMap);
| -------------------------------- in this macro invocation
|
::: /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/collections/hash/map.rs:213:1
|
213 | pub struct HashMap<K, V, S = RandomState> {
| ----------------------------------------- `HashMap` defined here
|
= note: this error originates in the macro `all_sync_send` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you might have meant to use an associated function to build this type
|
9 | is_send(y.$iter()::new());
| ~~~~~~~
9 | is_send(y.$iter()::with_capacity(_));
| ~~~~~~~~~~~~~~~~~~
9 | is_send(y.$iter()::with_hasher(_));
| ~~~~~~~~~~~~~~~~
9 | is_send(y.$iter()::with_capacity_and_hasher(_, _));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: consider using the `Default` trait
|
9 | is_send(y.$iter() as std::default::Default>::default()<HashMap);
| + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
especially this is_send(y.$iter() as std::default::Default>::default()<HashMap); looks very weird
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.Status: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some wayThis issue requires a build of rustc or tooling with debug-assertions in some way
Activity
matthiaskrgr commentedon Dec 9, 2023
Backtrace
matthiaskrgr commentedon Dec 12, 2024
@rustbot label: +I-ICE +T-compiler +C-bug +S-bug-has-test +requires-debug-assertions