about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libcollections/btree/map.rs16
-rw-r--r--src/libcollections/btree/set.rs8
-rw-r--r--src/libcore/iter.rs4
-rw-r--r--src/librustc_typeck/collect.rs13
-rw-r--r--src/test/auxiliary/default_ty_param_cross_crate_crate.rs1
-rw-r--r--src/test/compile-fail/issue-26812.rs2
6 files changed, 30 insertions, 14 deletions
diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs
index de9c8a2feaf..f87f5e6c2e6 100644
--- a/src/libcollections/btree/map.rs
+++ b/src/libcollections/btree/map.rs
@@ -1591,10 +1591,10 @@ impl<K: Ord, V> BTreeMap<K, V> {
     #[unstable(feature = "btree_range",
                reason = "matches collection reform specification, waiting for dust to settle",
                issue = "27787")]
-    pub fn range<Min: ?Sized + Ord = K, Max: ?Sized + Ord = K>(&self,
-                                                               min: Bound<&Min>,
-                                                               max: Bound<&Max>)
-                                                               -> Range<K, V>
+    pub fn range<Min: ?Sized + Ord, Max: ?Sized + Ord>(&self,
+                                                       min: Bound<&Min>,
+                                                       max: Bound<&Max>)
+                                                       -> Range<K, V>
         where K: Borrow<Min> + Borrow<Max>
     {
         range_impl!(&self.root,
@@ -1633,10 +1633,10 @@ impl<K: Ord, V> BTreeMap<K, V> {
     #[unstable(feature = "btree_range",
                reason = "matches collection reform specification, waiting for dust to settle",
                issue = "27787")]
-    pub fn range_mut<Min: ?Sized + Ord = K, Max: ?Sized + Ord = K>(&mut self,
-                                                                   min: Bound<&Min>,
-                                                                   max: Bound<&Max>)
-                                                                   -> RangeMut<K, V>
+    pub fn range_mut<Min: ?Sized + Ord, Max: ?Sized + Ord>(&mut self,
+                                                           min: Bound<&Min>,
+                                                           max: Bound<&Max>)
+                                                           -> RangeMut<K, V>
         where K: Borrow<Min> + Borrow<Max>
     {
         range_impl!(&mut self.root,
diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs
index 12d3465e518..55e9e3a1c34 100644
--- a/src/libcollections/btree/set.rs
+++ b/src/libcollections/btree/set.rs
@@ -154,10 +154,10 @@ impl<T: Ord> BTreeSet<T> {
     #[unstable(feature = "btree_range",
                reason = "matches collection reform specification, waiting for dust to settle",
                issue = "27787")]
-    pub fn range<'a, Min: ?Sized + Ord = T, Max: ?Sized + Ord = T>(&'a self,
-                                                                   min: Bound<&Min>,
-                                                                   max: Bound<&Max>)
-                                                                   -> Range<'a, T>
+    pub fn range<'a, Min: ?Sized + Ord, Max: ?Sized + Ord>(&'a self,
+                                                           min: Bound<&Min>,
+                                                           max: Bound<&Max>)
+                                                           -> Range<'a, T>
         where T: Borrow<Min> + Borrow<Max>
     {
         fn first<A, B>((a, _): (A, B)) -> A {
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs
index 6f052f964c6..a30e5b1372a 100644
--- a/src/libcore/iter.rs
+++ b/src/libcore/iter.rs
@@ -2132,7 +2132,7 @@ pub trait Iterator {
     /// ```
     #[unstable(feature = "iter_arith", reason = "bounds recently changed",
                issue = "27739")]
-    fn sum<S=<Self as Iterator>::Item>(self) -> S where
+    fn sum<S>(self) -> S where
         S: Add<Self::Item, Output=S> + Zero,
         Self: Sized,
     {
@@ -2157,7 +2157,7 @@ pub trait Iterator {
     /// ```
     #[unstable(feature="iter_arith", reason = "bounds recently changed",
                issue = "27739")]
-    fn product<P=<Self as Iterator>::Item>(self) -> P where
+    fn product<P>(self) -> P where
         P: Mul<Self::Item, Output=P> + One,
         Self: Sized,
     {
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index eaaa2c77379..2b3ee9fe6dc 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -92,6 +92,7 @@ use syntax::abi;
 use syntax::ast;
 use syntax::attr;
 use syntax::codemap::Span;
+use syntax::feature_gate::{GateIssue, emit_feature_err};
 use syntax::parse::token::special_idents;
 use syntax::ptr::P;
 use rustc_front::hir;
@@ -1933,6 +1934,18 @@ fn get_or_create_type_parameter_def<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
 
     let parent = tcx.map.get_parent(param.id);
 
+    if space != TypeSpace && default.is_some() {
+        if !tcx.sess.features.borrow().default_type_parameter_fallback {
+            emit_feature_err(&tcx.sess.parse_sess.span_diagnostic,
+                             "default_type_parameter_fallback",
+                             param.span,
+                             GateIssue::Language,
+                             "other than on a `struct` or `enum` definition, \
+                              defaults for type parameters are experimental \
+                              and known to be buggy");
+        }
+    }
+
     let def = ty::TypeParameterDef {
         space: space,
         index: index,
diff --git a/src/test/auxiliary/default_ty_param_cross_crate_crate.rs b/src/test/auxiliary/default_ty_param_cross_crate_crate.rs
index 270cfdcb7f6..4bd8ecacb96 100644
--- a/src/test/auxiliary/default_ty_param_cross_crate_crate.rs
+++ b/src/test/auxiliary/default_ty_param_cross_crate_crate.rs
@@ -10,6 +10,7 @@
 
 #![crate_type = "lib"]
 #![crate_name = "default_param_test"]
+#![feature(default_type_parameter_fallback)]
 
 use std::marker::PhantomData;
 
diff --git a/src/test/compile-fail/issue-26812.rs b/src/test/compile-fail/issue-26812.rs
index c1ccfe269cd..060a66846d3 100644
--- a/src/test/compile-fail/issue-26812.rs
+++ b/src/test/compile-fail/issue-26812.rs
@@ -8,5 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(default_type_parameter_fallback)]
+
 fn avg<T=T::Item>(_: T) {} //~ ERROR associated type `Item` not found for `T`
 fn main() {}