summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-09-14 05:08:27 +0000
committerbors <bors@rust-lang.org>2015-09-14 05:08:27 +0000
commit009f2cf7dd97d952b78bb68a95f661cecfb1562f (patch)
treea3ce07cb1bd9a3cf76afb2a8b8a7c261c605816e /src
parent341a91902a9cb030b67a4873aa8f4d93fa488c00 (diff)
parent8478acf695ccd3bf4abe8c65f153dfbc99f3d28c (diff)
downloadrust-009f2cf7dd97d952b78bb68a95f661cecfb1562f.tar.gz
rust-009f2cf7dd97d952b78bb68a95f661cecfb1562f.zip
Auto merge of #28392 - arielb1:sort-bounds-list, r=eddyb
The sort key is a (DefId, Name), which is *not* stable between
runs, so we must re-sort when loading.

Fixes #24063
Fixes #25467
Fixes #27222
Fixes #28377

r? @eddyb 
Diffstat (limited to 'src')
-rw-r--r--src/librustc/metadata/tydecode.rs5
-rw-r--r--src/librustc/middle/ty.rs15
-rw-r--r--src/librustc_typeck/astconv.rs10
-rw-r--r--src/test/auxiliary/issue-25467.rs20
-rw-r--r--src/test/run-pass/issue-25467.rs20
5 files changed, 59 insertions, 11 deletions
diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs
index 643cf132de2..7856890724c 100644
--- a/src/librustc/metadata/tydecode.rs
+++ b/src/librustc/metadata/tydecode.rs
@@ -682,9 +682,8 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
             }
         }
 
-        return ty::ExistentialBounds { region_bound: region_bound,
-                                       builtin_bounds: builtin_bounds,
-                                       projection_bounds: projection_bounds };
+        ty::ExistentialBounds::new(
+            region_bound, builtin_bounds, projection_bounds)
     }
 
     fn parse_builtin_bounds(&mut self) -> ty::BuiltinBounds {
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index 99d8c5c9301..7f61526a8f9 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -2143,6 +2143,21 @@ pub struct ExistentialBounds<'tcx> {
     pub projection_bounds: Vec<PolyProjectionPredicate<'tcx>>,
 }
 
+impl<'tcx> ExistentialBounds<'tcx> {
+    pub fn new(region_bound: ty::Region,
+               builtin_bounds: BuiltinBounds,
+               projection_bounds: Vec<PolyProjectionPredicate<'tcx>>)
+               -> Self {
+        let mut projection_bounds = projection_bounds;
+        ty::sort_bounds_list(&mut projection_bounds);
+        ExistentialBounds {
+            region_bound: region_bound,
+            builtin_bounds: builtin_bounds,
+            projection_bounds: projection_bounds
+        }
+    }
+}
+
 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
 pub struct BuiltinBounds(EnumSet<BuiltinBound>);
 
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index 6f2d8345142..fb61f1ef42d 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -2019,7 +2019,7 @@ pub fn conv_existential_bounds_from_partitioned_bounds<'tcx>(
     rscope: &RegionScope,
     span: Span,
     principal_trait_ref: ty::PolyTraitRef<'tcx>,
-    mut projection_bounds: Vec<ty::PolyProjectionPredicate<'tcx>>, // Empty for boxed closures
+    projection_bounds: Vec<ty::PolyProjectionPredicate<'tcx>>, // Empty for boxed closures
     partitioned_bounds: PartitionedBounds)
     -> ty::ExistentialBounds<'tcx>
 {
@@ -2058,13 +2058,7 @@ pub fn conv_existential_bounds_from_partitioned_bounds<'tcx>(
 
     debug!("region_bound: {:?}", region_bound);
 
-    ty::sort_bounds_list(&mut projection_bounds);
-
-    ty::ExistentialBounds {
-        region_bound: region_bound,
-        builtin_bounds: builtin_bounds,
-        projection_bounds: projection_bounds,
-    }
+    ty::ExistentialBounds::new(region_bound, builtin_bounds, projection_bounds)
 }
 
 /// Given the bounds on an object, determines what single region bound
diff --git a/src/test/auxiliary/issue-25467.rs b/src/test/auxiliary/issue-25467.rs
new file mode 100644
index 00000000000..e358cde1573
--- /dev/null
+++ b/src/test/auxiliary/issue-25467.rs
@@ -0,0 +1,20 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![crate_type="lib"]
+
+pub trait Trait {
+    // the issue is sensitive to interning order - so use names
+    // unlikely to appear in libstd.
+    type Issue25467FooT;
+    type Issue25467BarT;
+}
+
+pub type Object = Option<Box<Trait<Issue25467FooT=(),Issue25467BarT=()>>>;
diff --git a/src/test/run-pass/issue-25467.rs b/src/test/run-pass/issue-25467.rs
new file mode 100644
index 00000000000..47758768269
--- /dev/null
+++ b/src/test/run-pass/issue-25467.rs
@@ -0,0 +1,20 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:issue-25467.rs
+
+pub type Issue25467BarT = ();
+pub type Issue25467FooT = ();
+
+extern crate issue_25467 as aux;
+
+fn main() {
+    let o: aux::Object = None;
+}