rustc_trans: don't apply noalias on returned references.
This commit is contained in:
parent
cc6b88ccb2
commit
5eed95ede9
@ -792,7 +792,8 @@ impl<'a, 'tcx> FnType<'tcx> {
|
|||||||
// dependencies rather than pointer equality
|
// dependencies rather than pointer equality
|
||||||
let no_alias = match kind {
|
let no_alias = match kind {
|
||||||
PointerKind::Shared => false,
|
PointerKind::Shared => false,
|
||||||
PointerKind::Frozen | PointerKind::UniqueOwned => true,
|
PointerKind::UniqueOwned => true,
|
||||||
|
PointerKind::Frozen |
|
||||||
PointerKind::UniqueBorrowed => !is_return
|
PointerKind::UniqueBorrowed => !is_return
|
||||||
};
|
};
|
||||||
if no_alias {
|
if no_alias {
|
||||||
|
5
src/test/run-make/issue-46239/Makefile
Normal file
5
src/test/run-make/issue-46239/Makefile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
-include ../tools.mk
|
||||||
|
|
||||||
|
all:
|
||||||
|
$(RUSTC) main.rs -C opt-level=1
|
||||||
|
$(call RUN,main)
|
18
src/test/run-make/issue-46239/main.rs
Normal file
18
src/test/run-make/issue-46239/main.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
fn project<T>(x: &(T,)) -> &T { &x.0 }
|
||||||
|
|
||||||
|
fn dummy() {}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let f = (dummy as fn(),);
|
||||||
|
(*project(&f))();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user