Skip to content
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

another default method ICE involving missing item ids in the AST map #7675

Closed
thestinger opened this issue Jul 9, 2013 · 4 comments
Closed
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@thestinger
Copy link
Contributor

error: internal compiler error: type_uses_for: unbound item ID {crate: 0, node: 514135}

Here's a patch to trigger it:

diff --git a/src/libstd/container.rs b/src/libstd/container.rs
index d6f4c26..4cb52f0 100644
--- a/src/libstd/container.rs
+++ b/src/libstd/container.rs
@@ -19,7 +19,7 @@ pub trait Container {
     fn len(&self) -> uint;

     /// Return true if the container contains no elements
-    fn is_empty(&self) -> bool;
+    fn is_empty(&self) -> bool { self.len() == 0 }
 }

 /// A trait to represent mutable containers
diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs
index 6c93cd0..87e5082 100644
--- a/src/libstd/hashmap.rs
+++ b/src/libstd/hashmap.rs
@@ -285,9 +285,6 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
 impl<K:Hash + Eq,V> Container for HashMap<K, V> {
     /// Return the number of elements in the map
     fn len(&self) -> uint { self.size }
-
-    /// Return true if the map contains no elements
-    fn is_empty(&self) -> bool { self.len() == 0 }
 }

 impl<K:Hash + Eq,V> Mutable for HashMap<K, V> {
diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs
index 4f5f1bd..cffedd9 100644
--- a/src/libstd/iterator.rs
+++ b/src/libstd/iterator.rs
@@ -17,8 +17,6 @@ implementing the `Iterator` trait.

 */

-#[allow(default_methods)]; // solid enough for the use case here
-
 use cmp;
 use iter::Times;
 use num::{Zero, One};
diff --git a/src/libstd/std.rs b/src/libstd/std.rs
index 8f86216..b71d66c 100644
--- a/src/libstd/std.rs
+++ b/src/libstd/std.rs
@@ -60,6 +60,7 @@ they contained the following prologue:
 // Don't link to std. We are std.
 #[no_std];

+#[allow(default_methods)];
 #[deny(non_camel_case_types)];
 #[deny(missing_doc)];
@thestinger
Copy link
Contributor Author

cc @msullivan

@msullivan
Copy link
Contributor

type_use doesn't handle the default method case. Sigh. type_use.

Reduced test case

#[allow(default_methods)];

pub trait Container {
    fn is_empty(&self) -> bool { true }
}

pub struct HashMap<K,V>;

impl<K:Hash + Eq,V> Container for HashMap<K, V> {
}

pub struct HashSet<T> {
    priv map: HashMap<T, ()>
}


impl<T:Hash + Eq> Container for HashSet<T> {

    /// Return true if the set contains no elements
    fn is_empty(&self) -> bool { self.map.is_empty() }
}

fn argh(x: &HashSet<int>) -> bool {
    x.is_empty()
}

fn main () {}

@ghost ghost assigned msullivan Jul 11, 2013
@msullivan
Copy link
Contributor

I've got a fix for this that I'll land sometime soon.

@msullivan
Copy link
Contributor

This is part of #2794, by the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants