diff options
| author | bors <bors@rust-lang.org> | 2018-04-29 16:25:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-04-29 16:25:04 +0000 |
| commit | 79252ff4e25d82f9fe856cb66f127b79cdace163 (patch) | |
| tree | a34c17b2313ffc870950c2421c6f18b805988862 /src/test/run-pass | |
| parent | 96e182833b5c17da2481e6edf5bfdb75ad004e6e (diff) | |
| parent | 0a1cb9b91422e38baf352993ad78446a29160ed8 (diff) | |
| download | rust-79252ff4e25d82f9fe856cb66f127b79cdace163.tar.gz rust-79252ff4e25d82f9fe856cb66f127b79cdace163.zip | |
Auto merge of #48605 - KiChjang:unused-mut-warning, r=nikomatsakis
Allow MIR borrowck to catch unused mutable locals Fixes #47279. r? @nikomatsakis
Diffstat (limited to 'src/test/run-pass')
| -rw-r--r-- | src/test/run-pass/borrowck/borrowck-unused-mut-locals.rs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/test/run-pass/borrowck/borrowck-unused-mut-locals.rs b/src/test/run-pass/borrowck/borrowck-unused-mut-locals.rs new file mode 100644 index 00000000000..7f1b6ed1701 --- /dev/null +++ b/src/test/run-pass/borrowck/borrowck-unused-mut-locals.rs @@ -0,0 +1,56 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] +#![deny(unused_mut)] + +#[derive(Debug)] +struct A {} + +fn init_a() -> A { + A {} +} + +#[derive(Debug)] +struct B<'a> { + ed: &'a mut A, +} + +fn init_b<'a>(ed: &'a mut A) -> B<'a> { + B { ed } +} + +#[derive(Debug)] +struct C<'a> { + pd: &'a mut B<'a>, +} + +fn init_c<'a>(pd: &'a mut B<'a>) -> C<'a> { + C { pd } +} + +#[derive(Debug)] +struct D<'a> { + sd: &'a mut C<'a>, +} + +fn init_d<'a>(sd: &'a mut C<'a>) -> D<'a> { + D { sd } +} + +fn main() { + let mut a = init_a(); + let mut b = init_b(&mut a); + let mut c = init_c(&mut b); + + let d = init_d(&mut c); + + println!("{:?}", d) +} |
