From 21a9770d38483eb95d5045b50547058bc7ff7e65 Mon Sep 17 00:00:00 2001 From: bobtwinkles Date: Tue, 13 Mar 2018 14:21:51 -0400 Subject: [PATCH 1/2] Adds a test for #48070 Resolves #48070. The bug itself was fixed by #48770, but that PR didn't add a test for it. --- src/test/run-pass/issue-48070.rs | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/run-pass/issue-48070.rs diff --git a/src/test/run-pass/issue-48070.rs b/src/test/run-pass/issue-48070.rs new file mode 100644 index 0000000000000..c2253aa8b4c25 --- /dev/null +++ b/src/test/run-pass/issue-48070.rs @@ -0,0 +1,34 @@ +// Copyright 2018 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: lxl nll + +#![cfg_attr(nll, feature(nll))] + +struct Foo { + x: u32 +} + +impl Foo { + fn twiddle(&mut self) -> &mut Self { self } + fn twaddle(&mut self) -> &mut Self { self } + fn emit(&mut self) { + self.x += 1; + } +} + +fn main() { + let mut foo = Foo { x: 0 }; + match 22 { + 22 => &mut foo, + 44 => foo.twiddle(), + _ => foo.twaddle(), + }.emit(); +} From 52bb99dcc7c918cc9568a3bd26801da07c1ce103 Mon Sep 17 00:00:00 2001 From: bobtwinkles Date: Tue, 13 Mar 2018 14:52:11 -0400 Subject: [PATCH 2/2] Move 48070 test to ui --- src/test/{run-pass => ui/nll}/issue-48070.rs | 1 + 1 file changed, 1 insertion(+) rename src/test/{run-pass => ui/nll}/issue-48070.rs (98%) diff --git a/src/test/run-pass/issue-48070.rs b/src/test/ui/nll/issue-48070.rs similarity index 98% rename from src/test/run-pass/issue-48070.rs rename to src/test/ui/nll/issue-48070.rs index c2253aa8b4c25..71d92c3702e63 100644 --- a/src/test/run-pass/issue-48070.rs +++ b/src/test/ui/nll/issue-48070.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// run-pass // revisions: lxl nll #![cfg_attr(nll, feature(nll))]