Skip to content

Commit 06e74a9

Browse files
eddybMaloJaffre
authored andcommitted
rustc_trans: keep LLVM types for trait objects anonymous.
1 parent 90fe049 commit 06e74a9

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

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+
}

0 commit comments

Comments
 (0)