From d79dee0b62fb33bcb2febac60ced71f28dccc602 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 10 May 2018 12:06:51 +0300 Subject: rustc_mir: also promote interior borrows, not just whole temps. --- src/test/run-pass/issue-49955.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/test/run-pass/issue-49955.rs (limited to 'src/test/run-pass') diff --git a/src/test/run-pass/issue-49955.rs b/src/test/run-pass/issue-49955.rs new file mode 100644 index 00000000000..2d36806ef4f --- /dev/null +++ b/src/test/run-pass/issue-49955.rs @@ -0,0 +1,30 @@ +// 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. + +// compile-flags: -Z borrowck=compare + +const ALL_THE_NUMS: [u32; 1] = [ + 1 +]; + +#[inline(never)] +fn array(i: usize) -> &'static u32 { + return &ALL_THE_NUMS[i]; +} + +#[inline(never)] +fn tuple_field() -> &'static u32 { + &(42,).0 +} + +fn main() { + assert_eq!(tuple_field().to_string(), "42"); + // assert_eq!(array(0).to_string(), "1"); +} -- cgit 1.4.1-3-g733a5