Skip to content

Commit 60bb72e

Browse files
authored
Rollup merge of rust-lang#48061 - nikomatsakis:nll-do-not-run-mir-typeck-twice, r=eddyb
do not run MIR type checker twice The MIR type checker currently runs twice when NLL is enabled: once as a sanity check, and once "for real". No need for that.
2 parents 8240747 + bcd9968 commit 60bb72e

9 files changed

+416
-414
lines changed

src/librustc_mir/borrow_check/nll/type_check/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,12 @@ impl MirPass for TypeckMir {
15851585
let id = tcx.hir.as_local_node_id(def_id).unwrap();
15861586
debug!("run_pass: {:?}", def_id);
15871587

1588+
// When NLL is enabled, the borrow checker runs the typeck
1589+
// itself, so we don't need this MIR pass anymore.
1590+
if tcx.sess.nll() {
1591+
return;
1592+
}
1593+
15881594
if tcx.sess.err_count() > 0 {
15891595
// compiling a broken program can obviously result in a
15901596
// broken MIR, so try not to report duplicate errors.

src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,10 @@ fn overloaded_call_traits() {
105105
//[lxl]~^^^ ERROR use of moved value: `*f`
106106
//[nll]~^^^^ ERROR cannot move a value of type
107107
//[nll]~^^^^^ ERROR cannot move a value of type
108-
//[nll]~^^^^^^ ERROR cannot move a value of type
109-
//[nll]~^^^^^^^ ERROR cannot move a value of type
110-
//[nll]~^^^^^^^^ ERROR use of moved value: `*f`
111-
//[g2p]~^^^^^^^^^ ERROR cannot move a value of type
112-
//[g2p]~^^^^^^^^^^ ERROR cannot move a value of type
113-
//[g2p]~^^^^^^^^^^^ ERROR cannot move a value of type
114-
//[g2p]~^^^^^^^^^^^^ ERROR cannot move a value of type
115-
//[g2p]~^^^^^^^^^^^^^ ERROR use of moved value: `*f`
108+
//[nll]~^^^^^^ ERROR use of moved value: `*f`
109+
//[g2p]~^^^^^^^ ERROR cannot move a value of type
110+
//[g2p]~^^^^^^^^ ERROR cannot move a value of type
111+
//[g2p]~^^^^^^^^^ ERROR use of moved value: `*f`
116112
}
117113

118114
twice_ten_sm(&mut |x| x + 1);

src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr

+47-47
Original file line numberDiff line numberDiff line change
@@ -25,53 +25,6 @@ note: External requirements
2525
= note: number of external vids: 3
2626
= note: where <T as std::iter::Iterator>::Item: '_#2r
2727

28-
note: External requirements
29-
--> $DIR/projection-no-regions-closure.rs:46:23
30-
|
31-
46 | with_signature(x, |mut y| Box::new(y.next()))
32-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
33-
|
34-
= note: defining type: DefId(0/1:18 ~ projection_no_regions_closure[317d]::correct_region[0]::{{closure}}[0]) with closure substs [
35-
'_#1r,
36-
T,
37-
i32,
38-
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<Anything + '_#2r>
39-
]
40-
= note: number of external vids: 3
41-
= note: where <T as std::iter::Iterator>::Item: '_#2r
42-
43-
note: External requirements
44-
--> $DIR/projection-no-regions-closure.rs:54:23
45-
|
46-
54 | with_signature(x, |mut y| Box::new(y.next()))
47-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
48-
|
49-
= note: defining type: DefId(0/1:22 ~ projection_no_regions_closure[317d]::wrong_region[0]::{{closure}}[0]) with closure substs [
50-
'_#1r,
51-
'_#2r,
52-
T,
53-
i32,
54-
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<Anything + '_#3r>
55-
]
56-
= note: number of external vids: 4
57-
= note: where <T as std::iter::Iterator>::Item: '_#3r
58-
59-
note: External requirements
60-
--> $DIR/projection-no-regions-closure.rs:65:23
61-
|
62-
65 | with_signature(x, |mut y| Box::new(y.next()))
63-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
64-
|
65-
= note: defining type: DefId(0/1:26 ~ projection_no_regions_closure[317d]::outlives_region[0]::{{closure}}[0]) with closure substs [
66-
'_#1r,
67-
'_#2r,
68-
T,
69-
i32,
70-
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<Anything + '_#3r>
71-
]
72-
= note: number of external vids: 4
73-
= note: where <T as std::iter::Iterator>::Item: '_#3r
74-
7528
error[E0309]: the associated type `<T as std::iter::Iterator>::Item` may not live long enough
7629
--> $DIR/projection-no-regions-closure.rs:36:23
7730
|
@@ -97,6 +50,21 @@ note: No external requirements
9750
T
9851
]
9952

53+
note: External requirements
54+
--> $DIR/projection-no-regions-closure.rs:46:23
55+
|
56+
46 | with_signature(x, |mut y| Box::new(y.next()))
57+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
58+
|
59+
= note: defining type: DefId(0/1:18 ~ projection_no_regions_closure[317d]::correct_region[0]::{{closure}}[0]) with closure substs [
60+
'_#1r,
61+
T,
62+
i32,
63+
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<Anything + '_#2r>
64+
]
65+
= note: number of external vids: 3
66+
= note: where <T as std::iter::Iterator>::Item: '_#2r
67+
10068
note: No external requirements
10169
--> $DIR/projection-no-regions-closure.rs:42:1
10270
|
@@ -113,6 +81,22 @@ note: No external requirements
11381
T
11482
]
11583

84+
note: External requirements
85+
--> $DIR/projection-no-regions-closure.rs:54:23
86+
|
87+
54 | with_signature(x, |mut y| Box::new(y.next()))
88+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
89+
|
90+
= note: defining type: DefId(0/1:22 ~ projection_no_regions_closure[317d]::wrong_region[0]::{{closure}}[0]) with closure substs [
91+
'_#1r,
92+
'_#2r,
93+
T,
94+
i32,
95+
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<Anything + '_#3r>
96+
]
97+
= note: number of external vids: 4
98+
= note: where <T as std::iter::Iterator>::Item: '_#3r
99+
116100
error[E0309]: the associated type `<T as std::iter::Iterator>::Item` may not live long enough
117101
--> $DIR/projection-no-regions-closure.rs:54:23
118102
|
@@ -139,6 +123,22 @@ note: No external requirements
139123
T
140124
]
141125

126+
note: External requirements
127+
--> $DIR/projection-no-regions-closure.rs:65:23
128+
|
129+
65 | with_signature(x, |mut y| Box::new(y.next()))
130+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
131+
|
132+
= note: defining type: DefId(0/1:26 ~ projection_no_regions_closure[317d]::outlives_region[0]::{{closure}}[0]) with closure substs [
133+
'_#1r,
134+
'_#2r,
135+
T,
136+
i32,
137+
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<Anything + '_#3r>
138+
]
139+
= note: number of external vids: 4
140+
= note: where <T as std::iter::Iterator>::Item: '_#3r
141+
142142
note: No external requirements
143143
--> $DIR/projection-no-regions-closure.rs:60:1
144144
|

src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr

+51-51
Original file line numberDiff line numberDiff line change
@@ -32,57 +32,6 @@ note: External requirements
3232
= note: where T: '_#2r
3333
= note: where '_#1r: '_#2r
3434

35-
note: External requirements
36-
--> $DIR/projection-one-region-closure.rs:68:29
37-
|
38-
68 | with_signature(cell, t, |cell, t| require(cell, t));
39-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
40-
|
41-
= note: defining type: DefId(0/1:23 ~ projection_one_region_closure[317d]::no_relationships_early[0]::{{closure}}[0]) with closure substs [
42-
'_#1r,
43-
'_#2r,
44-
T,
45-
i32,
46-
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
47-
]
48-
= note: number of external vids: 4
49-
= note: where T: '_#3r
50-
= note: where '_#2r: '_#3r
51-
52-
note: External requirements
53-
--> $DIR/projection-one-region-closure.rs:90:29
54-
|
55-
90 | with_signature(cell, t, |cell, t| require(cell, t));
56-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
57-
|
58-
= note: defining type: DefId(0/1:27 ~ projection_one_region_closure[317d]::projection_outlives[0]::{{closure}}[0]) with closure substs [
59-
'_#1r,
60-
'_#2r,
61-
T,
62-
i32,
63-
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
64-
]
65-
= note: number of external vids: 4
66-
= note: where T: '_#3r
67-
= note: where '_#2r: '_#3r
68-
69-
note: External requirements
70-
--> $DIR/projection-one-region-closure.rs:103:29
71-
|
72-
103 | with_signature(cell, t, |cell, t| require(cell, t));
73-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
74-
|
75-
= note: defining type: DefId(0/1:31 ~ projection_one_region_closure[317d]::elements_outlive[0]::{{closure}}[0]) with closure substs [
76-
'_#1r,
77-
'_#2r,
78-
T,
79-
i32,
80-
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
81-
]
82-
= note: number of external vids: 4
83-
= note: where T: '_#3r
84-
= note: where '_#2r: '_#3r
85-
8635
error[E0309]: the parameter type `T` may not live long enough
8736
--> $DIR/projection-one-region-closure.rs:56:29
8837
|
@@ -114,6 +63,23 @@ note: No external requirements
11463
T
11564
]
11665

66+
note: External requirements
67+
--> $DIR/projection-one-region-closure.rs:68:29
68+
|
69+
68 | with_signature(cell, t, |cell, t| require(cell, t));
70+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
71+
|
72+
= note: defining type: DefId(0/1:23 ~ projection_one_region_closure[317d]::no_relationships_early[0]::{{closure}}[0]) with closure substs [
73+
'_#1r,
74+
'_#2r,
75+
T,
76+
i32,
77+
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
78+
]
79+
= note: number of external vids: 4
80+
= note: where T: '_#3r
81+
= note: where '_#2r: '_#3r
82+
11783
error[E0309]: the parameter type `T` may not live long enough
11884
--> $DIR/projection-one-region-closure.rs:68:29
11985
|
@@ -146,6 +112,23 @@ note: No external requirements
146112
T
147113
]
148114

115+
note: External requirements
116+
--> $DIR/projection-one-region-closure.rs:90:29
117+
|
118+
90 | with_signature(cell, t, |cell, t| require(cell, t));
119+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
120+
|
121+
= note: defining type: DefId(0/1:27 ~ projection_one_region_closure[317d]::projection_outlives[0]::{{closure}}[0]) with closure substs [
122+
'_#1r,
123+
'_#2r,
124+
T,
125+
i32,
126+
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
127+
]
128+
= note: number of external vids: 4
129+
= note: where T: '_#3r
130+
= note: where '_#2r: '_#3r
131+
149132
error[E0309]: the parameter type `T` may not live long enough
150133
--> $DIR/projection-one-region-closure.rs:90:29
151134
|
@@ -178,6 +161,23 @@ note: No external requirements
178161
T
179162
]
180163

164+
note: External requirements
165+
--> $DIR/projection-one-region-closure.rs:103:29
166+
|
167+
103 | with_signature(cell, t, |cell, t| require(cell, t));
168+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
169+
|
170+
= note: defining type: DefId(0/1:31 ~ projection_one_region_closure[317d]::elements_outlive[0]::{{closure}}[0]) with closure substs [
171+
'_#1r,
172+
'_#2r,
173+
T,
174+
i32,
175+
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
176+
]
177+
= note: number of external vids: 4
178+
= note: where T: '_#3r
179+
= note: where '_#2r: '_#3r
180+
181181
note: No external requirements
182182
--> $DIR/projection-one-region-closure.rs:97:1
183183
|

0 commit comments

Comments
 (0)