Skip to content

Commit b213c94

Browse files
committed
Auto merge of rust-lang#26558 - nham:fix_24357, r=alexcrichton
Fixes rust-lang#24357. Also adds a (totally separate) regression test, which Closes rust-lang#18119
2 parents 688b623 + db9af26 commit b213c94

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

src/librustc_borrowck/borrowck/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
734734
has type `{}`, which is {}",
735735
ol,
736736
moved_lp_msg,
737-
expr_ty,
737+
moved_lp.ty,
738738
suggestion));
739739
self.tcx.sess.fileline_help(expr_span, help);
740740
}

src/test/compile-fail/issue-18119.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
const X: u8 = 1;
12+
static Y: u8 = 1;
13+
fn foo() {}
14+
15+
impl X {}
16+
//~^ ERROR use of undeclared type name `X`
17+
impl Y {}
18+
//~^ ERROR use of undeclared type name `Y`
19+
impl foo {}
20+
//~^ ERROR use of undeclared type name `foo`
21+
22+
fn main() {}

src/test/compile-fail/issue-24357.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
struct NoCopy;
12+
fn main() {
13+
let x = NoCopy;
14+
let f = move || { let y = x; };
15+
//~^ NOTE `x` moved into closure environment here because it has type `NoCopy`
16+
let z = x;
17+
//~^ ERROR use of moved value: `x`
18+
}

0 commit comments

Comments
 (0)