You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use std::collections::BTreeMap;
fn main() {
let mut q = BTreeMap::new;
for i in 0..1000_000_000 {
q.insert(i, [0u8; 65536]);
}
}
$ rustc heapoverflow.rs
heapoverflow.rs:6:11: 6:34 error: no method named `insert` found for type `fn() -> collections::btree::map::BTreeMap<_, _> {collections::btree::map::BTreeMap<K, V>::new}` in the current scope
heapoverflow.rs:6 q.insert(i, [0u8; 65536]);
^~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
At first I tried add instead of insert, then looked at docs, changed to insert again, then tried deliberately invalid inse3rt to ensure that error message does not change. Then I noticed fn() in error message and after little thinking found the issue.
Maybe such simple mistake should have friendlier error message? For example, if obj.method does not exist, but obj().method does, it can be mentioned somehow.