Skip to content

Rollup of 2 pull requests #34863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/librustc_lint/types.rs
Original file line number Diff line number Diff line change
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
20 changes: 9 additions & 11 deletions src/libstd/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,10 @@ fn default_hook(info: &PanicInfo) {
pub unsafe fn try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<Any + Send>> {
let mut slot = None;
let mut f = Some(f);
let ret;
let ret = PANIC_COUNT.with(|s| {
let prev = s.get();
s.set(0);

{
let mut to_run = || {
slot = Some(f.take().unwrap()());
};
Expand All @@ -247,21 +248,18 @@ pub unsafe fn try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<Any + Send>> {
dataptr,
&mut any_data,
&mut any_vtable);
s.set(prev);

if r == 0 {
ret = Ok(());
Ok(())
} else {
PANIC_COUNT.with(|s| {
let prev = s.get();
s.set(prev - 1);
});
ret = Err(mem::transmute(raw::TraitObject {
Err(mem::transmute(raw::TraitObject {
data: any_data as *mut _,
vtable: any_vtable as *mut _,
}));
}))
}
}
});

debug_assert!(PANIC_COUNT.with(|c| c.get() == 0));
return ret.map(|()| {
slot.take().unwrap()
});
Expand Down
31 changes: 31 additions & 0 deletions src/test/compile-fail/issue-34839.rs
Original file line number Diff line number Diff line change
@@ -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