Skip to content

Commit cdefef2

Browse files
committed
Rollup merge of rust-lang#29006 - arielb1:callee-outlives-call, r=pnkfelix
This rather crucial requirement was not checked. In most cases, that didn't cause any trouble because the argument types are required to outlive the call and are subtypes of a subformula of the callee type. However, binary ops are taken by ref only indirectly, without it being marked in the argument types, which led to the argument types not being constrained anywhere causing spurious errors (as these are basically unconstrainable, I don't think this change can break code). Of course, the old way was also incorrent with contravariance, but that is still unsound for other reasons. This also improves rustc::front to get RUST_LOG to *somewhat* work. Fixes rust-lang#28999. That issue is one of the several regression introduced by rust-lang#28669. r? @pnkfelix
2 parents 8f3e05d + ed2a11d commit cdefef2

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/librustc/front/map/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,10 @@ impl<'ast> Map<'ast> {
528528
NodeTraitItem(ti) => PathName(ti.name),
529529
NodeVariant(v) => PathName(v.node.name),
530530
NodeLifetime(lt) => PathName(lt.name),
531+
NodeTyParam(tp) => PathName(tp.name),
532+
NodeLocal(&Pat { node: PatIdent(_,l,_), .. }) => {
533+
PathName(l.node.name)
534+
},
531535
_ => panic!("no path elem for {:?}", node)
532536
}
533537
}
@@ -988,4 +992,3 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
988992
}
989993
}
990994
}
991-

src/librustc_typeck/check/regionck.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,8 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
592592
};
593593

594594
substs_wf_in_scope(rcx, origin, &callee.substs, expr.span, expr_region);
595+
type_must_outlive(rcx, infer::ExprTypeIsNotInScope(callee.ty, expr.span),
596+
callee.ty, expr_region);
595597
}
596598

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

669+
debug!("regionck::visit_expr(e={:?}, repeating_scope={}) - visiting subexprs",
670+
expr, rcx.repeating_scope);
667671
match expr.node {
668672
hir::ExprPath(..) => {
669673
rcx.fcx.opt_node_ty_substs(expr.id, |item_substs| {

src/test/run-pass/issue-28999.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+
pub struct Xyz<'a, V> {
12+
pub v: (V, &'a u32),
13+
}
14+
15+
pub fn eq<'a, 's, 't, V>(this: &'s Xyz<'a, V>, other: &'t Xyz<'a, V>) -> bool
16+
where V: PartialEq {
17+
this.v == other.v
18+
}
19+
20+
fn main() {}

0 commit comments

Comments
 (0)