Skip to content

Commit

Permalink
Auto merge of #34846 - jonas-schievink:issue34839, r=eddyb
Browse files Browse the repository at this point in the history
Variant Size Differences: Erase regions before computing type layout

Fixes #34839
  • Loading branch information
bors committed Jul 16, 2016
2 parents 60564d0 + d148610 commit b5ad277
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustc_lint/types.rs
Expand Up @@ -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)
})
});
Expand Down
31 changes: 31 additions & 0 deletions 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

0 comments on commit b5ad277

Please sign in to comment.