about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Schneider <github35764891676564198441@oli-obk.de>2018-08-26 22:21:20 +0200
committerOliver Schneider <github35764891676564198441@oli-obk.de>2018-08-28 13:15:22 +0200
commit0ed8e16195658b839f6ff8f7b8ae719a42d2827e (patch)
treeca94f8bfd7db556acb2027fd5f53f27df69d5e11
parent59e52b1b969545e6b7b8595913dc2e1a741d495d (diff)
downloadrust-0ed8e16195658b839f6ff8f7b8ae719a42d2827e.tar.gz
rust-0ed8e16195658b839f6ff8f7b8ae719a42d2827e.zip
Use partial but correct vtable layout
-rw-r--r--src/librustc/ty/layout.rs12
-rw-r--r--src/test/codegen/function-arguments.rs4
-rw-r--r--src/test/ui/consts/const-eval/issue-53401.rs21
3 files changed, 25 insertions, 12 deletions
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs
index d485b9b32d4..c93ca836bef 100644
--- a/src/librustc/ty/layout.rs
+++ b/src/librustc/ty/layout.rs
@@ -1621,18 +1621,10 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
                 match tcx.struct_tail(pointee).sty {
                     ty::Slice(_) |
                     ty::Str => tcx.types.usize,
-                    ty::Dynamic(data, _) => {
-                        let trait_def_id = data.principal().unwrap().def_id();
-                        let num_fns: u64 = crate::traits::supertrait_def_ids(tcx, trait_def_id)
-                            .map(|trait_def_id| {
-                                tcx.associated_items(trait_def_id)
-                                    .filter(|item| item.kind == ty::AssociatedKind::Method)
-                                    .count() as u64
-                            })
-                            .sum();
+                    ty::Dynamic(_, _) => {
                         tcx.mk_imm_ref(
                             tcx.types.re_static,
-                            tcx.mk_array(tcx.types.usize, 3 + num_fns),
+                            tcx.mk_array(tcx.types.usize, 3),
                         )
                         /* FIXME use actual fn pointers
                         tcx.mk_tup(&[
diff --git a/src/test/codegen/function-arguments.rs b/src/test/codegen/function-arguments.rs
index 09031508da1..0bd021f8ae2 100644
--- a/src/test/codegen/function-arguments.rs
+++ b/src/test/codegen/function-arguments.rs
@@ -120,13 +120,13 @@ pub fn unsafe_slice(_: &[UnsafeInner]) {
 pub fn str(_: &[u8]) {
 }
 
-// CHECK: @trait_borrow({}* nonnull %arg0.0, [4 x [[USIZE]]]* noalias readonly dereferenceable({{.*}}) %arg0.1)
+// CHECK: @trait_borrow({}* nonnull %arg0.0, [3 x [[USIZE]]]* noalias readonly dereferenceable({{.*}}) %arg0.1)
 // FIXME #25759 This should also have `nocapture`
 #[no_mangle]
 pub fn trait_borrow(_: &Drop) {
 }
 
-// CHECK: @trait_box({}* noalias nonnull, [4 x [[USIZE]]]* noalias readonly dereferenceable({{.*}}))
+// CHECK: @trait_box({}* noalias nonnull, [3 x [[USIZE]]]* noalias readonly dereferenceable({{.*}}))
 #[no_mangle]
 pub fn trait_box(_: Box<Drop>) {
 }
diff --git a/src/test/ui/consts/const-eval/issue-53401.rs b/src/test/ui/consts/const-eval/issue-53401.rs
new file mode 100644
index 00000000000..cb74f4f8f75
--- /dev/null
+++ b/src/test/ui/consts/const-eval/issue-53401.rs
@@ -0,0 +1,21 @@
+// 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 <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.
+
+// compile-pass
+
+pub const STATIC_TRAIT: &Test = &();
+
+fn main() {}
+
+pub trait Test {
+    fn test() where Self: Sized {}
+}
+
+impl Test for () {}