Skip to content

Commit e7fc53b

Browse files
committed
Auto merge of #39686 - frewsxcv:rollup, r=frewsxcv
Rollup of 5 pull requests - Successful merges: #39595, #39601, #39602, #39615, #39647 - Failed merges:
2 parents 1129ce5 + 116bdac commit e7fc53b

File tree

16 files changed

+279
-187
lines changed

16 files changed

+279
-187
lines changed

src/ci/docker/cross/Dockerfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1414
zlib1g-dev \
1515
g++-arm-linux-gnueabi \
1616
g++-arm-linux-gnueabihf \
17+
gcc-sparc64-linux-gnu \
18+
libc6-dev-sparc64-cross \
1719
bzip2 \
1820
patch
1921

@@ -60,9 +62,11 @@ ENV TARGETS=$TARGETS,mipsel-unknown-linux-musl
6062
ENV TARGETS=$TARGETS,arm-unknown-linux-musleabi
6163
ENV TARGETS=$TARGETS,arm-unknown-linux-musleabihf
6264
ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf
65+
ENV TARGETS=$TARGETS,sparc64-unknown-linux-gnu
6366

6467
ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
65-
CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc
68+
CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \
69+
CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc
6670

6771
# Suppress some warnings in the openwrt toolchains we downloaded
6872
ENV STAGING_DIR=/tmp

src/libcore/fmt/float.rs

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use fmt::{Formatter, Result, LowerExp, UpperExp, Display, Debug};
12+
use num::flt2dec;
13+
14+
// Common code of floating point Debug and Display.
15+
fn float_to_decimal_common<T>(fmt: &mut Formatter, num: &T, negative_zero: bool) -> Result
16+
where T: flt2dec::DecodableFloat
17+
{
18+
let force_sign = fmt.sign_plus();
19+
let sign = match (force_sign, negative_zero) {
20+
(false, false) => flt2dec::Sign::Minus,
21+
(false, true) => flt2dec::Sign::MinusRaw,
22+
(true, false) => flt2dec::Sign::MinusPlus,
23+
(true, true) => flt2dec::Sign::MinusPlusRaw,
24+
};
25+
26+
let mut buf = [0; 1024]; // enough for f32 and f64
27+
let mut parts = [flt2dec::Part::Zero(0); 16];
28+
let formatted = if let Some(precision) = fmt.precision {
29+
flt2dec::to_exact_fixed_str(flt2dec::strategy::grisu::format_exact, *num, sign,
30+
precision, false, &mut buf, &mut parts)
31+
} else {
32+
flt2dec::to_shortest_str(flt2dec::strategy::grisu::format_shortest, *num, sign,
33+
0, false, &mut buf, &mut parts)
34+
};
35+
fmt.pad_formatted_parts(&formatted)
36+
}
37+
38+
// Common code of floating point LowerExp and UpperExp.
39+
fn float_to_exponential_common<T>(fmt: &mut Formatter, num: &T, upper: bool) -> Result
40+
where T: flt2dec::DecodableFloat
41+
{
42+
let force_sign = fmt.sign_plus();
43+
let sign = match force_sign {
44+
false => flt2dec::Sign::Minus,
45+
true => flt2dec::Sign::MinusPlus,
46+
};
47+
48+
let mut buf = [0; 1024]; // enough for f32 and f64
49+
let mut parts = [flt2dec::Part::Zero(0); 16];
50+
let formatted = if let Some(precision) = fmt.precision {
51+
// 1 integral digit + `precision` fractional digits = `precision + 1` total digits
52+
flt2dec::to_exact_exp_str(flt2dec::strategy::grisu::format_exact, *num, sign,
53+
precision + 1, upper, &mut buf, &mut parts)
54+
} else {
55+
flt2dec::to_shortest_exp_str(flt2dec::strategy::grisu::format_shortest, *num, sign,
56+
(0, 0), upper, &mut buf, &mut parts)
57+
};
58+
fmt.pad_formatted_parts(&formatted)
59+
}
60+
61+
macro_rules! floating {
62+
($ty:ident) => (
63+
#[stable(feature = "rust1", since = "1.0.0")]
64+
impl Debug for $ty {
65+
fn fmt(&self, fmt: &mut Formatter) -> Result {
66+
float_to_decimal_common(fmt, self, true)
67+
}
68+
}
69+
70+
#[stable(feature = "rust1", since = "1.0.0")]
71+
impl Display for $ty {
72+
fn fmt(&self, fmt: &mut Formatter) -> Result {
73+
float_to_decimal_common(fmt, self, false)
74+
}
75+
}
76+
77+
#[stable(feature = "rust1", since = "1.0.0")]
78+
impl LowerExp for $ty {
79+
fn fmt(&self, fmt: &mut Formatter) -> Result {
80+
float_to_exponential_common(fmt, self, false)
81+
}
82+
}
83+
84+
#[stable(feature = "rust1", since = "1.0.0")]
85+
impl UpperExp for $ty {
86+
fn fmt(&self, fmt: &mut Formatter) -> Result {
87+
float_to_exponential_common(fmt, self, true)
88+
}
89+
}
90+
)
91+
}
92+
93+
floating! { f32 }
94+
floating! { f64 }

src/libcore/fmt/mod.rs

+4-83
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ use result;
2121
use slice;
2222
use str;
2323

24+
mod float;
25+
mod num;
26+
mod builders;
27+
2428
#[unstable(feature = "fmt_flags_align", issue = "27726")]
2529
/// Possible alignments returned by `Formatter::align`
2630
#[derive(Debug)]
@@ -38,9 +42,6 @@ pub enum Alignment {
3842
#[stable(feature = "debug_builders", since = "1.2.0")]
3943
pub use self::builders::{DebugStruct, DebugTuple, DebugSet, DebugList, DebugMap};
4044

41-
mod num;
42-
mod builders;
43-
4445
#[unstable(feature = "fmt_internals", reason = "internal to format_args!",
4546
issue = "0")]
4647
#[doc(hidden)]
@@ -1511,86 +1512,6 @@ impl<'a, T: ?Sized> Pointer for &'a mut T {
15111512
}
15121513
}
15131514

1514-
// Common code of floating point Debug and Display.
1515-
fn float_to_decimal_common<T>(fmt: &mut Formatter, num: &T, negative_zero: bool) -> Result
1516-
where T: flt2dec::DecodableFloat
1517-
{
1518-
let force_sign = fmt.sign_plus();
1519-
let sign = match (force_sign, negative_zero) {
1520-
(false, false) => flt2dec::Sign::Minus,
1521-
(false, true) => flt2dec::Sign::MinusRaw,
1522-
(true, false) => flt2dec::Sign::MinusPlus,
1523-
(true, true) => flt2dec::Sign::MinusPlusRaw,
1524-
};
1525-
1526-
let mut buf = [0; 1024]; // enough for f32 and f64
1527-
let mut parts = [flt2dec::Part::Zero(0); 16];
1528-
let formatted = if let Some(precision) = fmt.precision {
1529-
flt2dec::to_exact_fixed_str(flt2dec::strategy::grisu::format_exact, *num, sign,
1530-
precision, false, &mut buf, &mut parts)
1531-
} else {
1532-
flt2dec::to_shortest_str(flt2dec::strategy::grisu::format_shortest, *num, sign,
1533-
0, false, &mut buf, &mut parts)
1534-
};
1535-
fmt.pad_formatted_parts(&formatted)
1536-
}
1537-
1538-
// Common code of floating point LowerExp and UpperExp.
1539-
fn float_to_exponential_common<T>(fmt: &mut Formatter, num: &T, upper: bool) -> Result
1540-
where T: flt2dec::DecodableFloat
1541-
{
1542-
let force_sign = fmt.sign_plus();
1543-
let sign = match force_sign {
1544-
false => flt2dec::Sign::Minus,
1545-
true => flt2dec::Sign::MinusPlus,
1546-
};
1547-
1548-
let mut buf = [0; 1024]; // enough for f32 and f64
1549-
let mut parts = [flt2dec::Part::Zero(0); 16];
1550-
let formatted = if let Some(precision) = fmt.precision {
1551-
// 1 integral digit + `precision` fractional digits = `precision + 1` total digits
1552-
flt2dec::to_exact_exp_str(flt2dec::strategy::grisu::format_exact, *num, sign,
1553-
precision + 1, upper, &mut buf, &mut parts)
1554-
} else {
1555-
flt2dec::to_shortest_exp_str(flt2dec::strategy::grisu::format_shortest, *num, sign,
1556-
(0, 0), upper, &mut buf, &mut parts)
1557-
};
1558-
fmt.pad_formatted_parts(&formatted)
1559-
}
1560-
1561-
macro_rules! floating { ($ty:ident) => {
1562-
1563-
#[stable(feature = "rust1", since = "1.0.0")]
1564-
impl Debug for $ty {
1565-
fn fmt(&self, fmt: &mut Formatter) -> Result {
1566-
float_to_decimal_common(fmt, self, true)
1567-
}
1568-
}
1569-
1570-
#[stable(feature = "rust1", since = "1.0.0")]
1571-
impl Display for $ty {
1572-
fn fmt(&self, fmt: &mut Formatter) -> Result {
1573-
float_to_decimal_common(fmt, self, false)
1574-
}
1575-
}
1576-
1577-
#[stable(feature = "rust1", since = "1.0.0")]
1578-
impl LowerExp for $ty {
1579-
fn fmt(&self, fmt: &mut Formatter) -> Result {
1580-
float_to_exponential_common(fmt, self, false)
1581-
}
1582-
}
1583-
1584-
#[stable(feature = "rust1", since = "1.0.0")]
1585-
impl UpperExp for $ty {
1586-
fn fmt(&self, fmt: &mut Formatter) -> Result {
1587-
float_to_exponential_common(fmt, self, true)
1588-
}
1589-
}
1590-
} }
1591-
floating! { f32 }
1592-
floating! { f64 }
1593-
15941515
// Implementation of Display/Debug for various core types
15951516

15961517
#[stable(feature = "rust1", since = "1.0.0")]

src/libcoretest/fmt/float.rs

+25-7
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,29 @@
99
// except according to those terms.
1010

1111
#[test]
12-
fn test_format_float() {
13-
assert!("1" == format!("{:.0}", 1.0f64));
14-
assert!("9" == format!("{:.0}", 9.4f64));
15-
assert!("10" == format!("{:.0}", 9.9f64));
16-
assert!("9.8" == format!("{:.1}", 9.849f64));
17-
assert!("9.9" == format!("{:.1}", 9.851f64));
18-
assert!("1" == format!("{:.0}", 0.5f64));
12+
fn test_format_f64() {
13+
assert_eq!("1", format!("{:.0}", 1.0f64));
14+
assert_eq!("9", format!("{:.0}", 9.4f64));
15+
assert_eq!("10", format!("{:.0}", 9.9f64));
16+
assert_eq!("9.8", format!("{:.1}", 9.849f64));
17+
assert_eq!("9.9", format!("{:.1}", 9.851f64));
18+
assert_eq!("1", format!("{:.0}", 0.5f64));
19+
assert_eq!("1.23456789e6", format!("{:e}", 1234567.89f64));
20+
assert_eq!("1.23456789e3", format!("{:e}", 1234.56789f64));
21+
assert_eq!("1.23456789E6", format!("{:E}", 1234567.89f64));
22+
assert_eq!("1.23456789E3", format!("{:E}", 1234.56789f64));
23+
}
24+
25+
#[test]
26+
fn test_format_f32() {
27+
assert_eq!("1", format!("{:.0}", 1.0f32));
28+
assert_eq!("9", format!("{:.0}", 9.4f32));
29+
assert_eq!("10", format!("{:.0}", 9.9f32));
30+
assert_eq!("9.8", format!("{:.1}", 9.849f32));
31+
assert_eq!("9.9", format!("{:.1}", 9.851f32));
32+
assert_eq!("1", format!("{:.0}", 0.5f32));
33+
assert_eq!("1.2345679e6", format!("{:e}", 1234567.89f32));
34+
assert_eq!("1.2345679e3", format!("{:e}", 1234.56789f32));
35+
assert_eq!("1.2345679E6", format!("{:E}", 1234567.89f32));
36+
assert_eq!("1.2345679E3", format!("{:E}", 1234.56789f32));
1937
}

src/librustc/middle/mem_categorization.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ impl<'tcx> cmt_<'tcx> {
202202
Categorization::Downcast(ref cmt, _) => {
203203
if let Categorization::Local(_) = cmt.cat {
204204
if let ty::TyAdt(def, _) = self.ty.sty {
205-
return def.struct_variant().find_field_named(name).map(|x| x.did);
205+
if def.is_struct() {
206+
return def.struct_variant().find_field_named(name).map(|x| x.did);
207+
}
206208
}
207209
None
208210
} else {

src/librustc/ty/context.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use middle::resolve_lifetime;
2626
use middle::stability;
2727
use mir::Mir;
2828
use ty::subst::{Kind, Substs};
29+
use ty::ReprOptions;
2930
use traits;
3031
use ty::{self, TraitRef, Ty, TypeAndMut};
3132
use ty::{TyS, TypeVariants, Slice};
@@ -672,9 +673,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
672673
pub fn alloc_adt_def(self,
673674
did: DefId,
674675
kind: AdtKind,
675-
variants: Vec<ty::VariantDef>)
676+
variants: Vec<ty::VariantDef>,
677+
repr: ReprOptions)
676678
-> &'gcx ty::AdtDef {
677-
let def = ty::AdtDef::new(self, did, kind, variants);
679+
let def = ty::AdtDef::new(self, did, kind, variants, repr);
678680
self.global_arenas.adt_def.alloc(def)
679681
}
680682

0 commit comments

Comments
 (0)