Skip to content

Commit 00ce7ee

Browse files
committed
resolve type and region variables in "NLL dropck"
Fixes #47022.
1 parent 27ede55 commit 00ce7ee

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flo
214214
// associated types here and possibly recursively process.
215215
for ty in dtorck_types {
216216
let ty = self.cx.normalize(&ty, location);
217+
let ty = self.cx.infcx.resolve_type_and_region_vars_if_possible(&ty);
217218
match ty.sty {
218219
ty::TyParam(..) | ty::TyProjection(..) | ty::TyAnon(..) => {
219220
let cause = Cause::DropVar(dropped_local, location);

src/test/ui/nll/issue-47022.rs

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2017 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+
// must-compile-successfully
12+
13+
#![allow(warnings)]
14+
#![feature(nll)]
15+
16+
struct LoadedObject {
17+
bodies: Vec<Body>,
18+
color: Color,
19+
}
20+
21+
struct Body;
22+
23+
#[derive(Clone)]
24+
struct Color;
25+
26+
struct Graphic {
27+
color: Color,
28+
}
29+
30+
fn convert(objects: Vec<LoadedObject>) -> (Vec<Body>, Vec<Graphic>) {
31+
objects
32+
.into_iter()
33+
.flat_map(|LoadedObject { bodies, color, .. }| {
34+
bodies.into_iter().map(move |body| {
35+
(
36+
body,
37+
Graphic {
38+
color: color.clone(),
39+
},
40+
)
41+
})
42+
})
43+
.unzip()
44+
}
45+
46+
fn main() {}
47+

0 commit comments

Comments
 (0)