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

require a method callee's type to outlive the call #29006

Merged
merged 1 commit into from
Oct 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: 4 additions & 1 deletion src/librustc/front/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,10 @@ impl<'ast> Map<'ast> {
NodeTraitItem(ti) => PathName(ti.name),
NodeVariant(v) => PathName(v.node.name),
NodeLifetime(lt) => PathName(lt.name),
NodeTyParam(tp) => PathName(tp.name),
NodeLocal(&Pat { node: PatIdent(_,l,_), .. }) => {
PathName(l.node.name)
},
_ => panic!("no path elem for {:?}", node)
}
}
Expand Down Expand Up @@ -987,4 +991,3 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
}
}
}

4 changes: 4 additions & 0 deletions src/librustc_typeck/check/regionck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
};

substs_wf_in_scope(rcx, origin, &callee.substs, expr.span, expr_region);
type_must_outlive(rcx, infer::ExprTypeIsNotInScope(callee.ty, expr.span),
callee.ty, expr_region);
}

// Check any autoderefs or autorefs that appear.
Expand Down Expand Up @@ -664,6 +666,8 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
}
}

debug!("regionck::visit_expr(e={:?}, repeating_scope={}) - visiting subexprs",
expr, rcx.repeating_scope);
match expr.node {
hir::ExprPath(..) => {
rcx.fcx.opt_node_ty_substs(expr.id, |item_substs| {
Expand Down
20 changes: 20 additions & 0 deletions src/test/run-pass/issue-28999.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.

pub struct Xyz<'a, V> {
pub v: (V, &'a u32),
}

pub fn eq<'a, 's, 't, V>(this: &'s Xyz<'a, V>, other: &'t Xyz<'a, V>) -> bool
where V: PartialEq {
this.v == other.v
}

fn main() {}