Skip to content

Commit 009f2cf

Browse files
committed
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
2 parents 341a919 + 8478acf commit 009f2cf

File tree

5 files changed

+59
-11
lines changed

5 files changed

+59
-11
lines changed

src/librustc/metadata/tydecode.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,8 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
682682
}
683683
}
684684

685-
return ty::ExistentialBounds { region_bound: region_bound,
686-
builtin_bounds: builtin_bounds,
687-
projection_bounds: projection_bounds };
685+
ty::ExistentialBounds::new(
686+
region_bound, builtin_bounds, projection_bounds)
688687
}
689688

690689
fn parse_builtin_bounds(&mut self) -> ty::BuiltinBounds {

src/librustc/middle/ty.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,6 +2143,21 @@ pub struct ExistentialBounds<'tcx> {
21432143
pub projection_bounds: Vec<PolyProjectionPredicate<'tcx>>,
21442144
}
21452145

2146+
impl<'tcx> ExistentialBounds<'tcx> {
2147+
pub fn new(region_bound: ty::Region,
2148+
builtin_bounds: BuiltinBounds,
2149+
projection_bounds: Vec<PolyProjectionPredicate<'tcx>>)
2150+
-> Self {
2151+
let mut projection_bounds = projection_bounds;
2152+
ty::sort_bounds_list(&mut projection_bounds);
2153+
ExistentialBounds {
2154+
region_bound: region_bound,
2155+
builtin_bounds: builtin_bounds,
2156+
projection_bounds: projection_bounds
2157+
}
2158+
}
2159+
}
2160+
21462161
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
21472162
pub struct BuiltinBounds(EnumSet<BuiltinBound>);
21482163

src/librustc_typeck/astconv.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,7 @@ pub fn conv_existential_bounds_from_partitioned_bounds<'tcx>(
20192019
rscope: &RegionScope,
20202020
span: Span,
20212021
principal_trait_ref: ty::PolyTraitRef<'tcx>,
2022-
mut projection_bounds: Vec<ty::PolyProjectionPredicate<'tcx>>, // Empty for boxed closures
2022+
projection_bounds: Vec<ty::PolyProjectionPredicate<'tcx>>, // Empty for boxed closures
20232023
partitioned_bounds: PartitionedBounds)
20242024
-> ty::ExistentialBounds<'tcx>
20252025
{
@@ -2058,13 +2058,7 @@ pub fn conv_existential_bounds_from_partitioned_bounds<'tcx>(
20582058

20592059
debug!("region_bound: {:?}", region_bound);
20602060

2061-
ty::sort_bounds_list(&mut projection_bounds);
2062-
2063-
ty::ExistentialBounds {
2064-
region_bound: region_bound,
2065-
builtin_bounds: builtin_bounds,
2066-
projection_bounds: projection_bounds,
2067-
}
2061+
ty::ExistentialBounds::new(region_bound, builtin_bounds, projection_bounds)
20682062
}
20692063

20702064
/// Given the bounds on an object, determines what single region bound

src/test/auxiliary/issue-25467.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_type="lib"]
12+
13+
pub trait Trait {
14+
// the issue is sensitive to interning order - so use names
15+
// unlikely to appear in libstd.
16+
type Issue25467FooT;
17+
type Issue25467BarT;
18+
}
19+
20+
pub type Object = Option<Box<Trait<Issue25467FooT=(),Issue25467BarT=()>>>;

src/test/run-pass/issue-25467.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:issue-25467.rs
12+
13+
pub type Issue25467BarT = ();
14+
pub type Issue25467FooT = ();
15+
16+
extern crate issue_25467 as aux;
17+
18+
fn main() {
19+
let o: aux::Object = None;
20+
}

0 commit comments

Comments
 (0)