From 1060513ddc9a8689730a993c8a91e574c4879607 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Wed, 10 Jul 2019 05:18:01 +0200 Subject: [PATCH] Get out of bootstrapping pickle. --- src/librustc_target/abi/mod.rs | 29 ++++++++++++++++++++++------- src/librustc_typeck/check/mod.rs | 4 +++- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index 4a4c6799c00..80fcb45d0b9 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -105,20 +105,34 @@ pub fn parse(target: &Target) -> Result { let mut dl = TargetDataLayout::default(); let mut i128_align_src = 64; for spec in target.data_layout.split('-') { - match spec.split(':').collect::>()[..] { + let spec_parts = spec.split(':').collect::>(); + + match &*spec_parts { ["e"] => dl.endian = Endian::Little, ["E"] => dl.endian = Endian::Big, [p] if p.starts_with("P") => { dl.instruction_address_space = parse_address_space(&p[1..], "P")? } - ["a", ref a..] => dl.aggregate_align = align(a, "a")?, - ["f32", ref a..] => dl.f32_align = align(a, "f32")?, - ["f64", ref a..] => dl.f64_align = align(a, "f64")?, - [p @ "p", s, ref a..] | [p @ "p0", s, ref a..] => { + // FIXME: Ping cfg(bootstrap) -- Use `ref a @ ..` with new bootstrap compiler. + ["a", ..] => { + let a = &spec_parts[1..]; // FIXME inline into pattern. + dl.aggregate_align = align(a, "a")? + } + ["f32", ..] => { + let a = &spec_parts[1..]; // FIXME inline into pattern. + dl.f32_align = align(a, "f32")? + } + ["f64", ..] => { + let a = &spec_parts[1..]; // FIXME inline into pattern. + dl.f64_align = align(a, "f64")? + } + [p @ "p", s, ..] | [p @ "p0", s, ..] => { + let a = &spec_parts[2..]; // FIXME inline into pattern. dl.pointer_size = size(s, p)?; dl.pointer_align = align(a, p)?; } - [s, ref a..] if s.starts_with("i") => { + [s, ..] if s.starts_with("i") => { + let a = &spec_parts[1..]; // FIXME inline into pattern. let bits = match s[1..].parse::() { Ok(bits) => bits, Err(_) => { @@ -142,7 +156,8 @@ pub fn parse(target: &Target) -> Result { dl.i128_align = a; } } - [s, ref a..] if s.starts_with("v") => { + [s, ..] if s.starts_with("v") => { + let a = &spec_parts[1..]; // FIXME inline into pattern. let v_size = size(&s[1..], "v")?; let a = align(a, s)?; if let Some(v) = dl.vector_align.iter_mut().find(|v| v.0 == v_size) { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 36977b878dd..66c726b2485 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1818,7 +1818,9 @@ fn bad_variant_count<'tcx>(tcx: TyCtxt<'tcx>, adt: &'tcx ty::AdtDef, sp: Span, d ); let mut err = struct_span_err!(tcx.sess, sp, E0731, "transparent enum {}", msg); err.span_label(sp, &msg); - if let &[ref start.., ref end] = &variant_spans[..] { + if let &[.., ref end] = &variant_spans[..] { + // FIXME: Ping cfg(bootstrap) -- Use `ref start @ ..` with new bootstrap compiler. + let start = &variant_spans[..variant_spans.len() - 1]; for variant_span in start { err.span_label(*variant_span, ""); }