Skip to content

Commit 4b8e7cb

Browse files
committed
Rollup merge of #33539 - nikomatsakis:static-error, r=pnkfelix
fix DFS for region error reporting This was causing terrible error reports, because the algorithm was incorrectly identifying the constraints. r? @eddyb
2 parents 130e76b + de0906f commit 4b8e7cb

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

src/librustc/infer/region_inference/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1240,9 +1240,6 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
12401240
orig_node_idx,
12411241
node_idx);
12421242

1243-
// figure out the direction from which this node takes its
1244-
// values, and search for concrete regions etc in that direction
1245-
let dir = graph::INCOMING;
12461243
process_edges(self, &mut state, graph, node_idx, dir);
12471244
}
12481245

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2012 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+
// This test checks that the error messages you get for this example
12+
// at least mention `'a` and `'static`. The precise messages can drift
13+
// over time, but this test used to exhibit some pretty bogus messages
14+
// that were not remotely helpful.
15+
16+
// error-pattern:cannot infer
17+
// error-pattern:cannot outlive the lifetime 'a
18+
// error-pattern:must be valid for the static lifetime
19+
// error-pattern:cannot infer
20+
// error-pattern:cannot outlive the lifetime 'a
21+
// error-pattern:must be valid for the static lifetime
22+
23+
struct Invariant<'a>(Option<&'a mut &'a mut ()>);
24+
25+
fn mk_static() -> Invariant<'static> { Invariant(None) }
26+
27+
fn unify<'a>(x: Option<Invariant<'a>>, f: fn(Invariant<'a>)) {
28+
let bad = if x.is_some() {
29+
x.unwrap()
30+
} else {
31+
mk_static()
32+
};
33+
f(bad);
34+
}
35+
36+
fn main() {}

0 commit comments

Comments
 (0)