about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJonas Schievink <jonas@schievink.net>2016-07-16 10:45:13 +0200
committerJonas Schievink <jonas@schievink.net>2016-07-16 10:45:13 +0200
commitd1486108bc517edf8fb401da587e1fac22ffffb0 (patch)
tree19035c82561d10f0bbd7da7976c85b7dd44636d4 /src
parent145f0ec88caaae531d7ba0232c4ef39704a23af2 (diff)
downloadrust-d1486108bc517edf8fb401da587e1fac22ffffb0.tar.gz
rust-d1486108bc517edf8fb401da587e1fac22ffffb0.zip
Erase regions before computing type layout
Fixes #34839
Diffstat (limited to 'src')
-rw-r--r--src/librustc_lint/types.rs3
-rw-r--r--src/test/compile-fail/issue-34839.rs31
2 files changed, 33 insertions, 1 deletions
diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs
index 9b08ddcafab..f688bd80ee9 100644
--- a/src/librustc_lint/types.rs
+++ b/src/librustc_lint/types.rs
@@ -698,7 +698,8 @@ impl LateLintPass for VariantSizeDifferences {
             if gens.ty_params.is_empty() {  // sizes only make sense for non-generic types
                 let t = cx.tcx.node_id_to_type(it.id);
                 let layout = cx.tcx.normalizing_infer_ctxt(ProjectionMode::Any).enter(|infcx| {
-                    t.layout(&infcx).unwrap_or_else(|e| {
+                    let ty = cx.tcx.erase_regions(&t);
+                    ty.layout(&infcx).unwrap_or_else(|e| {
                         bug!("failed to get layout for `{}`: {}", t, e)
                     })
                 });
diff --git a/src/test/compile-fail/issue-34839.rs b/src/test/compile-fail/issue-34839.rs
new file mode 100644
index 00000000000..be7e7820020
--- /dev/null
+++ b/src/test/compile-fail/issue-34839.rs
@@ -0,0 +1,31 @@
+// Copyright 2016 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.
+
+#![feature(rustc_attrs)]
+#![allow(dead_code)]
+
+trait RegularExpression: Sized {
+    type Text;
+}
+
+struct ExecNoSyncStr<'a>(&'a u8);
+
+impl<'c> RegularExpression for ExecNoSyncStr<'c> {
+    type Text = u8;
+}
+
+struct FindCaptures<'t, R>(&'t R::Text) where R: RegularExpression, R::Text: 't;
+
+enum FindCapturesInner<'r, 't> {
+    Dynamic(FindCaptures<'t, ExecNoSyncStr<'r>>),
+}
+
+#[rustc_error]
+fn main() {}    //~ ERROR compilation successful