Skip to content

Commit 7ec5e9b

Browse files
committed
Auto merge of #47943 - MaloJaffre:beta-backport, r=Mark-Simulacrum
[beta] Backports Cherry-picked into beta: - #47762 - #47794 - #47891
2 parents ed9751a + 0a33981 commit 7ec5e9b

File tree

7 files changed

+78
-6
lines changed

7 files changed

+78
-6
lines changed

src/bootstrap/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,11 @@ impl Build {
771771
fn release(&self, num: &str) -> String {
772772
match &self.config.channel[..] {
773773
"stable" => num.to_string(),
774-
"beta" => format!("{}-beta.{}", num, self.beta_prerelease_version()),
774+
"beta" => if self.rust_info.is_git() {
775+
format!("{}-beta.{}", num, self.beta_prerelease_version())
776+
} else {
777+
format!("{}-beta", num)
778+
},
775779
"nightly" => format!("{}-nightly", num),
776780
_ => format!("{}-dev", num),
777781
}

src/librustc_trans/mir/constant.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ impl<'a, 'tcx> Const<'tcx> {
140140
}
141141
}
142142
_ => {
143-
const_get_elt(self.llval, layout.llvm_field_index(i))
143+
match layout.fields {
144+
layout::FieldPlacement::Union(_) => self.llval,
145+
_ => const_get_elt(self.llval, layout.llvm_field_index(i)),
146+
}
144147
}
145148
}
146149
}

src/librustc_trans/type_of.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ fn uncached_llvm_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
5757
ty::TyClosure(..) |
5858
ty::TyGenerator(..) |
5959
ty::TyAdt(..) |
60-
ty::TyDynamic(..) |
60+
// FIXME(eddyb) producing readable type names for trait objects can result
61+
// in problematically distinct types due to HRTB and subtyping (see #47638).
62+
// ty::TyDynamic(..) |
6163
ty::TyForeign(..) |
6264
ty::TyStr => {
6365
let mut name = String::with_capacity(32);

src/test/codegen/function-arguments.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ pub fn unsafe_slice(_: &[UnsafeInner]) {
122122
pub fn str(_: &[u8]) {
123123
}
124124

125-
// CHECK: @trait_borrow(%"core::ops::drop::Drop"* nonnull %arg0.0, {}* noalias nonnull readonly %arg0.1)
125+
// CHECK: @trait_borrow({}* nonnull %arg0.0, {}* noalias nonnull readonly %arg0.1)
126126
// FIXME #25759 This should also have `nocapture`
127127
#[no_mangle]
128128
pub fn trait_borrow(_: &Drop) {
129129
}
130130

131-
// CHECK: @trait_box(%"core::ops::drop::Drop"* noalias nonnull, {}* noalias nonnull readonly)
131+
// CHECK: @trait_box({}* noalias nonnull, {}* noalias nonnull readonly)
132132
#[no_mangle]
133133
pub fn trait_box(_: Box<Drop>) {
134134
}

src/test/run-pass/issue-47638.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2018 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+
fn id<'c, 'b>(f: &'c &'b Fn(&i32)) -> &'c &'b Fn(&'static i32) {
12+
f
13+
}
14+
15+
fn main() {
16+
let f: &Fn(&i32) = &|x| {};
17+
id(&f);
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2018 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+
#![feature(const_fn)]
12+
13+
type Field1 = i32;
14+
type Field2 = f32;
15+
type Field3 = i64;
16+
17+
union DummyUnion {
18+
field1: Field1,
19+
field2: Field2,
20+
field3: Field3,
21+
}
22+
23+
const FLOAT1_AS_I32: i32 = 1065353216;
24+
const UNION: DummyUnion = DummyUnion { field1: FLOAT1_AS_I32 };
25+
26+
const fn read_field1() -> Field1 {
27+
const FIELD1: Field1 = unsafe { UNION.field1 };
28+
FIELD1
29+
}
30+
31+
const fn read_field2() -> Field2 {
32+
const FIELD2: Field2 = unsafe { UNION.field2 };
33+
FIELD2
34+
}
35+
36+
const fn read_field3() -> Field3 {
37+
const FIELD3: Field3 = unsafe { UNION.field3 };
38+
FIELD3
39+
}
40+
41+
fn main() {
42+
assert_eq!(read_field1(), FLOAT1_AS_I32);
43+
assert_eq!(read_field2(), 1.0);
44+
assert_eq!(read_field3(), unsafe { UNION.field3 });
45+
}

0 commit comments

Comments
 (0)