Skip to content

sort the existential bounds list in tydecode #28392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,9 +680,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 {
Expand Down
15 changes: 15 additions & 0 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,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>);

Expand Down
10 changes: 2 additions & 8 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
{
Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions src/test/auxiliary/issue-25467.rs
Original file line number Diff line number Diff line change
@@ -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=()>>>;
20 changes: 20 additions & 0 deletions src/test/run-pass/issue-25467.rs
Original file line number Diff line number Diff line change
@@ -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;
}