libstd: Remove "dual impls" from the language and enforce coherence rules. r=brson
"Dual impls" are impls that are both type implementations and trait implementations. They can lead to ambiguity and so this patch removes them from the language. This also enforces coherence rules. Without this patch, records can implement traits not defined in the current crate. This patch fixes this, and updates all of rustc to adhere to the new enforcement. Most of this patch is fixing rustc to obey the coherence rules, which involves converting a bunch of records to structs.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
#[forbid(deprecated_mode)];
|
||||
|
||||
use map;
|
||||
use map::Map;
|
||||
use map::StdMap;
|
||||
|
||||
use core::dvec::DVec;
|
||||
use core::ops;
|
||||
@@ -81,7 +81,7 @@ pub pure fn contains_key<T: Copy>(self: SmallIntMap<T>, key: uint) -> bool {
|
||||
}
|
||||
|
||||
/// Implements the map::map interface for smallintmap
|
||||
impl<V: Copy> SmallIntMap<V>: map::Map<uint, V> {
|
||||
impl<V: Copy> SmallIntMap<V>: map::StdMap<uint, V> {
|
||||
pure fn size() -> uint {
|
||||
let mut sz = 0u;
|
||||
for self.v.each |item| {
|
||||
@@ -165,8 +165,8 @@ impl<V: Copy> SmallIntMap<V>: ops::Index<uint, V> {
|
||||
}
|
||||
|
||||
/// Cast the given smallintmap to a map::map
|
||||
pub fn as_map<V: Copy>(s: SmallIntMap<V>) -> map::Map<uint, V> {
|
||||
s as map::Map::<uint, V>
|
||||
pub fn as_map<V: Copy>(s: SmallIntMap<V>) -> map::StdMap<uint, V> {
|
||||
s as map::StdMap::<uint, V>
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user