Skip to content
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

Remove region variable leaks from higher_ranked_sub(). #28369

Merged
merged 2 commits into from Sep 22, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/librustc/middle/infer/equate.rs
Expand Up @@ -17,6 +17,7 @@ use middle::ty::{self, Ty};
use middle::ty::TyVar;
use middle::ty_relate::{Relate, RelateResult, TypeRelation};

/// Ensures `a` is made equal to `b`. Returns `a` on success.
pub struct Equate<'a, 'tcx: 'a> {
fields: CombineFields<'a, 'tcx>
}
Expand Down Expand Up @@ -68,7 +69,8 @@ impl<'a, 'tcx> TypeRelation<'a,'tcx> for Equate<'a, 'tcx> {
}

_ => {
combine::super_combine_tys(self.fields.infcx, self, a, b)
try!(combine::super_combine_tys(self.fields.infcx, self, a, b));
Ok(a)
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/middle/infer/sub.rs
Expand Up @@ -18,7 +18,7 @@ use middle::ty::TyVar;
use middle::ty_relate::{Cause, Relate, RelateResult, TypeRelation};
use std::mem;

/// "Greatest lower bound" (common subtype)
/// Ensures `a` is made a subtype of `b`. Returns `a` on success.
pub struct Sub<'a, 'tcx: 'a> {
fields: CombineFields<'a, 'tcx>,
}
Expand Down Expand Up @@ -90,7 +90,8 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> {
}

_ => {
combine::super_combine_tys(self.fields.infcx, self, a, b)
try!(combine::super_combine_tys(self.fields.infcx, self, a, b));
Ok(a)
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions src/test/run-pass/issue-28279.rs
@@ -0,0 +1,30 @@
// 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.

use std::rc::Rc;

fn test1() -> Rc<for<'a> Fn(&'a usize) + 'static> {
if let Some(_) = Some(1) {
loop{}
} else {
loop{}
}
}

fn test2() -> *mut for<'a> Fn(&'a usize) + 'static {
if let Some(_) = Some(1) {
loop{}
} else {
loop{}
}
}

fn main() {}