about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-07-26 10:39:18 +0000
committerbors <bors@rust-lang.org>2015-07-26 10:39:18 +0000
commita5c12f4e39d32af3c951b66bd2839bc0b5a1125b (patch)
treeafb98f99301745cd34143473f2b43573f0100863 /src/libsyntax
parent9a196aa173c7d08dc865c1814647b2c9f4d9f68a (diff)
parent5ad36cb887dadc7fe564cfed1ccac52d009a59c8 (diff)
downloadrust-a5c12f4e39d32af3c951b66bd2839bc0b5a1125b.tar.gz
rust-a5c12f4e39d32af3c951b66bd2839bc0b5a1125b.zip
Auto merge of #26870 - jroesch:default-typaram-fallback, r=nikomatsakis
This PR completes [RFC 213](https://github.com/rust-lang/rfcs/blob/master/text/0213-defaulted-type-params.md) by allowing default type parameters to influence inference. This is almost certainly a breaking change due to interactions between default type parameters and the old fallback algorithm used for integral and floating point literals.

The error messages still require polish but I wanted to get early review and feedback from others on the the changes, error messages, and test cases. I also imagine we will want to run anywhere from 1-3 versions of this on crater and evaluate the impact, and it would be best to get that ball rolling. 

The only outstanding issue I'm aware of is that type alias defaults don't work. It seems this may require significant restructuring, since during inference type aliases have already been expanded. @nikomatsakis might be able to provide some clarity here.

r? @nikomatsakis 

cc @eddyb @Gankro @aturon @brson 
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/feature_gate.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index ee895fb1a96..c3338f02ee4 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -163,6 +163,8 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
 
     // Allows the definition recursive static items.
     ("static_recursion", "1.3.0", Active),
+// Allows default type parameters to influence type inference.
+    ("default_type_parameter_fallback", "1.3.0", Active)
 ];
 // (changing above list without updating src/doc/reference.md makes @cmr sad)
 
@@ -341,7 +343,8 @@ pub struct Features {
     /// #![feature] attrs for non-language (library) features
     pub declared_lib_features: Vec<(InternedString, Span)>,
     pub const_fn: bool,
-    pub static_recursion: bool
+    pub static_recursion: bool,
+    pub default_type_parameter_fallback: bool,
 }
 
 impl Features {
@@ -366,7 +369,8 @@ impl Features {
             declared_stable_lang_features: Vec::new(),
             declared_lib_features: Vec::new(),
             const_fn: false,
-            static_recursion: false
+            static_recursion: false,
+            default_type_parameter_fallback: false,
         }
     }
 }
@@ -864,7 +868,8 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler,
         declared_stable_lang_features: accepted_features,
         declared_lib_features: unknown_features,
         const_fn: cx.has_feature("const_fn"),
-        static_recursion: cx.has_feature("static_recursion")
+        static_recursion: cx.has_feature("static_recursion"),
+        default_type_parameter_fallback: cx.has_feature("default_type_parameter_fallback"),
     }
 }