From 0f34e0dabb1251de6769576105a0cd34d6a1db44 Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Sat, 12 Jan 2019 01:53:47 +0900 Subject: [PATCH 01/12] Add fmt benchmarks --- src/libcore/benches/fmt.rs | 110 +++++++++++++++++++++++++++++++++++++ src/libcore/benches/lib.rs | 1 + 2 files changed, 111 insertions(+) create mode 100644 src/libcore/benches/fmt.rs diff --git a/src/libcore/benches/fmt.rs b/src/libcore/benches/fmt.rs new file mode 100644 index 00000000000..92f10c760c6 --- /dev/null +++ b/src/libcore/benches/fmt.rs @@ -0,0 +1,110 @@ +use std::io::{self, Write as IoWrite}; +use std::fmt::{self, Write as FmtWrite}; +use test::Bencher; + +#[bench] +fn write_vec_value(bh: &mut Bencher) { + bh.iter(|| { + let mut mem = Vec::new(); + for _ in 0..1000 { + mem.write_all("abc".as_bytes()).unwrap(); + } + }); +} + +#[bench] +fn write_vec_ref(bh: &mut Bencher) { + bh.iter(|| { + let mut mem = Vec::new(); + let wr = &mut mem as &mut dyn io::Write; + for _ in 0..1000 { + wr.write_all("abc".as_bytes()).unwrap(); + } + }); +} + +#[bench] +fn write_vec_macro1(bh: &mut Bencher) { + bh.iter(|| { + let mut mem = Vec::new(); + let wr = &mut mem as &mut dyn io::Write; + for _ in 0..1000 { + write!(wr, "abc").unwrap(); + } + }); +} + +#[bench] +fn write_vec_macro2(bh: &mut Bencher) { + bh.iter(|| { + let mut mem = Vec::new(); + let wr = &mut mem as &mut dyn io::Write; + for _ in 0..1000 { + write!(wr, "{}", "abc").unwrap(); + } + }); +} + +#[bench] +fn write_vec_macro_debug(bh: &mut Bencher) { + bh.iter(|| { + let mut mem = Vec::new(); + let wr = &mut mem as &mut dyn io::Write; + for _ in 0..1000 { + write!(wr, "{:?}", "☃").unwrap(); + } + }); +} + +#[bench] +fn write_str_value(bh: &mut Bencher) { + bh.iter(|| { + let mut mem = String::new(); + for _ in 0..1000 { + mem.write_str("abc").unwrap(); + } + }); +} + +#[bench] +fn write_str_ref(bh: &mut Bencher) { + bh.iter(|| { + let mut mem = String::new(); + let wr = &mut mem as &mut dyn fmt::Write; + for _ in 0..1000 { + wr.write_str("abc").unwrap(); + } + }); +} + +#[bench] +fn write_str_macro1(bh: &mut Bencher) { + bh.iter(|| { + let mut mem = String::new(); + for _ in 0..1000 { + write!(mem, "abc").unwrap(); + } + }); +} + +#[bench] +fn write_str_macro2(bh: &mut Bencher) { + bh.iter(|| { + let mut mem = String::new(); + let wr = &mut mem as &mut dyn fmt::Write; + for _ in 0..1000 { + write!(wr, "{}", "abc").unwrap(); + } + }); +} + +#[bench] +fn write_str_macro_debug(bh: &mut Bencher) { + bh.iter(|| { + let mut mem = String::new(); + let wr = &mut mem as &mut dyn fmt::Write; + for _ in 0..1000 { + write!(wr, "{:?}", "☃").unwrap(); + } + }); +} diff --git a/src/libcore/benches/lib.rs b/src/libcore/benches/lib.rs index 5b4971c81dd..48572af611a 100644 --- a/src/libcore/benches/lib.rs +++ b/src/libcore/benches/lib.rs @@ -11,3 +11,4 @@ mod iter; mod num; mod ops; mod slice; +mod fmt; From d7a7ce9edd487dc151426dcb6d89911cc741e605 Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Sat, 12 Jan 2019 01:53:59 +0900 Subject: [PATCH 02/12] Utilize specialized zip iterator impl name old ns/iter new ns/iter diff ns/iter diff % speedup fmt::write_str_macro1 13,927 12,489 -1,438 -10.33% x 1.12 fmt::write_str_macro2 24,633 23,418 -1,215 -4.93% x 1.05 fmt::write_str_macro_debug 234,633 233,092 -1,541 -0.66% x 1.01 fmt::write_str_ref 5,819 5,823 4 0.07% x 1.00 fmt::write_str_value 6,012 5,828 -184 -3.06% x 1.03 fmt::write_vec_macro1 18,550 17,143 -1,407 -7.58% x 1.08 fmt::write_vec_macro2 30,369 28,920 -1,449 -4.77% x 1.05 fmt::write_vec_macro_debug 244,338 244,901 563 0.23% x 1.00 fmt::write_vec_ref 5,952 5,885 -67 -1.13% x 1.01 fmt::write_vec_value 5,944 5,894 -50 -0.84% x 1.01 --- src/libcore/fmt/mod.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index ec1aeb8a7d1..306a715f02d 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -1026,28 +1026,30 @@ pub fn write(output: &mut dyn Write, args: Arguments) -> Result { curarg: args.args.iter(), }; - let mut pieces = args.pieces.iter(); + let mut idx = 0; match args.fmt { None => { // We can use default formatting parameters for all arguments. - for (arg, piece) in args.args.iter().zip(pieces.by_ref()) { + for (arg, piece) in args.args.iter().zip(args.pieces.iter()) { formatter.buf.write_str(*piece)?; (arg.formatter)(arg.value, &mut formatter)?; + idx += 1; } } Some(fmt) => { // Every spec has a corresponding argument that is preceded by // a string piece. - for (arg, piece) in fmt.iter().zip(pieces.by_ref()) { + for (arg, piece) in fmt.iter().zip(args.pieces.iter()) { formatter.buf.write_str(*piece)?; formatter.run(arg)?; + idx += 1; } } } // There can be only one trailing string piece left. - if let Some(piece) = pieces.next() { + if let Some(piece) = args.pieces.get(idx) { formatter.buf.write_str(*piece)?; } From 038d8372244ab088ea186e10704e2bfc4e83f477 Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Sat, 12 Jan 2019 13:30:03 +0900 Subject: [PATCH 03/12] Fix simple formatting optimization name old2 ns/iter new2 ns/iter diff ns/iter diff % speedup fmt::write_str_macro1 12,295 12,308 13 0.11% x 1.00 fmt::write_str_macro2 24,079 21,451 -2,628 -10.91% x 1.12 fmt::write_str_macro_debug 238,363 230,807 -7,556 -3.17% x 1.03 fmt::write_str_ref 6,203 6,064 -139 -2.24% x 1.02 fmt::write_str_value 6,225 6,075 -150 -2.41% x 1.02 fmt::write_vec_macro1 17,144 17,121 -23 -0.13% x 1.00 fmt::write_vec_macro2 29,845 26,703 -3,142 -10.53% x 1.12 fmt::write_vec_macro_debug 248,840 242,117 -6,723 -2.70% x 1.03 fmt::write_vec_ref 5,954 6,438 484 8.13% x 0.92 fmt::write_vec_value 5,959 6,439 480 8.06% x 0.93 --- src/libfmt_macros/lib.rs | 9 +++++++++ src/libsyntax_ext/format.rs | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 32ae878909f..da440cdd72f 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -72,6 +72,15 @@ pub enum Position<'a> { ArgumentNamed(&'a str), } +impl Position<'_> { + pub fn index(&self) -> Option { + match self { + ArgumentIs(i) | ArgumentImplicitlyIs(i) => Some(*i), + _ => None, + } + } +} + /// Enum of alignments which are supported. #[derive(Copy, Clone, PartialEq)] pub enum Alignment { diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 61722ba5516..0613c78e495 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -493,7 +493,10 @@ impl<'a, 'b> Context<'a, 'b> { let fill = arg.format.fill.unwrap_or(' '); - if *arg != simple_arg || fill != ' ' { + let pos_simple = + arg.position.index() == simple_arg.position.index(); + + if !pos_simple || arg.format != simple_arg.format || fill != ' ' { self.all_pieces_simple = false; } From 763392cb8ca09e0f332c1ab9b75376afbdafc18f Mon Sep 17 00:00:00 2001 From: Tatsuyuki Ishi Date: Wed, 16 Jan 2019 23:05:50 +0900 Subject: [PATCH 04/12] Fix memory leak in P::filter_map --- src/libsyntax/ptr.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index bb1744e2df1..3effe53cd29 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -101,6 +101,7 @@ impl P { // Recreate self from the raw pointer. Some(P { ptr: Box::from_raw(p) }) } else { + drop(Box::from_raw(p)); None } } From c7d25a2a4082e6d2601ea4c06ea01b632d196172 Mon Sep 17 00:00:00 2001 From: Alexis Hunt Date: Mon, 14 Jan 2019 08:10:45 -0500 Subject: [PATCH 05/12] Make `str` indexing generic on `SliceIndex`. --- src/libcore/ops/index.rs | 15 - src/libcore/slice/mod.rs | 16 +- src/libcore/str/mod.rs | 298 +++++++----------- src/test/ui/index-help.stderr | 2 +- src/test/ui/indexing-requires-a-uint.rs | 2 +- src/test/ui/indexing-requires-a-uint.stderr | 4 +- src/test/ui/integral-indexing.rs | 16 +- src/test/ui/integral-indexing.stderr | 32 +- .../ui/on-unimplemented/slice-index.stderr | 4 +- src/test/ui/str/str-idx.rs | 5 +- src/test/ui/str/str-idx.stderr | 38 ++- src/test/ui/str/str-mut-idx.rs | 8 +- src/test/ui/str/str-mut-idx.stderr | 36 ++- 13 files changed, 240 insertions(+), 236 deletions(-) diff --git a/src/libcore/ops/index.rs b/src/libcore/ops/index.rs index 6cfa36741d0..d4ed8614276 100644 --- a/src/libcore/ops/index.rs +++ b/src/libcore/ops/index.rs @@ -51,21 +51,6 @@ /// ``` #[lang = "index"] #[rustc_on_unimplemented( - on( - _Self="&str", - note="you can use `.chars().nth()` or `.bytes().nth()` -see chapter in The Book " - ), - on( - _Self="str", - note="you can use `.chars().nth()` or `.bytes().nth()` -see chapter in The Book " - ), - on( - _Self="std::string::String", - note="you can use `.chars().nth()` or `.bytes().nth()` -see chapter in The Book " - ), message="the type `{Self}` cannot be indexed by `{Idx}`", label="`{Self}` cannot be indexed by `{Idx}`", )] diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 7fdc2acb8cc..2245d48f889 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -2312,7 +2312,6 @@ impl [u8] { } #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "slice indices are of type `usize` or ranges of `usize`"] impl ops::Index for [T] where I: SliceIndex<[T]> { @@ -2325,7 +2324,6 @@ impl ops::Index for [T] } #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "slice indices are of type `usize` or ranges of `usize`"] impl ops::IndexMut for [T] where I: SliceIndex<[T]> { @@ -2376,7 +2374,19 @@ mod private_slice_index { /// A helper trait used for indexing operations. #[stable(feature = "slice_get_slice", since = "1.28.0")] -#[rustc_on_unimplemented = "slice indices are of type `usize` or ranges of `usize`"] +#[rustc_on_unimplemented( + on( + T = "str", + label = "string indices are ranges of `usize`", + ), + on( + all(any(T = "str", T = "&str", T = "std::string::String"), _Self="{integer}"), + note="you can use `.chars().nth()` or `.bytes().nth()` +see chapter in The Book " + ), + message = "the type `{T}` cannot be indexed by `{Self}`", + label = "slice indices are of type `usize` or ranges of `usize`", +)] pub trait SliceIndex: private_slice_index::Sealed { /// The output type returned by methods. #[stable(feature = "slice_get_slice", since = "1.28.0")] diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index bdde187d931..1ee8b7735c1 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1621,190 +1621,26 @@ mod traits { } } - /// Implements substring slicing with syntax `&self[begin .. end]`. - /// - /// Returns a slice of the given string from the byte range - /// [`begin`..`end`). - /// - /// This operation is `O(1)`. - /// - /// # Panics - /// - /// Panics if `begin` or `end` does not point to the starting - /// byte offset of a character (as defined by `is_char_boundary`). - /// Requires that `begin <= end` and `end <= len` where `len` is the - /// length of the string. - /// - /// # Examples - /// - /// ``` - /// let s = "Löwe 老虎 Léopard"; - /// assert_eq!(&s[0 .. 1], "L"); - /// - /// assert_eq!(&s[1 .. 9], "öwe 老"); - /// - /// // these will panic: - /// // byte 2 lies within `ö`: - /// // &s[2 ..3]; - /// - /// // byte 8 lies within `老` - /// // &s[1 .. 8]; - /// - /// // byte 100 is outside the string - /// // &s[3 .. 100]; - /// ``` #[stable(feature = "rust1", since = "1.0.0")] - impl ops::Index> for str { - type Output = str; + impl ops::Index for str + where + I: SliceIndex, + { + type Output = I::Output; + #[inline] - fn index(&self, index: ops::Range) -> &str { + fn index(&self, index: I) -> &I::Output { index.index(self) } } - /// Implements mutable substring slicing with syntax - /// `&mut self[begin .. end]`. - /// - /// Returns a mutable slice of the given string from the byte range - /// [`begin`..`end`). - /// - /// This operation is `O(1)`. - /// - /// # Panics - /// - /// Panics if `begin` or `end` does not point to the starting - /// byte offset of a character (as defined by `is_char_boundary`). - /// Requires that `begin <= end` and `end <= len` where `len` is the - /// length of the string. - #[stable(feature = "derefmut_for_string", since = "1.3.0")] - impl ops::IndexMut> for str { - #[inline] - fn index_mut(&mut self, index: ops::Range) -> &mut str { - index.index_mut(self) - } - } - - /// Implements substring slicing with syntax `&self[.. end]`. - /// - /// Returns a slice of the string from the beginning to byte offset - /// `end`. - /// - /// Equivalent to `&self[0 .. end]`. #[stable(feature = "rust1", since = "1.0.0")] - impl ops::Index> for str { - type Output = str; - + impl ops::IndexMut for str + where + I: SliceIndex, + { #[inline] - fn index(&self, index: ops::RangeTo) -> &str { - index.index(self) - } - } - - /// Implements mutable substring slicing with syntax `&mut self[.. end]`. - /// - /// Returns a mutable slice of the string from the beginning to byte offset - /// `end`. - /// - /// Equivalent to `&mut self[0 .. end]`. - #[stable(feature = "derefmut_for_string", since = "1.3.0")] - impl ops::IndexMut> for str { - #[inline] - fn index_mut(&mut self, index: ops::RangeTo) -> &mut str { - index.index_mut(self) - } - } - - /// Implements substring slicing with syntax `&self[begin ..]`. - /// - /// Returns a slice of the string from byte offset `begin` - /// to the end of the string. - /// - /// Equivalent to `&self[begin .. len]`. - #[stable(feature = "rust1", since = "1.0.0")] - impl ops::Index> for str { - type Output = str; - - #[inline] - fn index(&self, index: ops::RangeFrom) -> &str { - index.index(self) - } - } - - /// Implements mutable substring slicing with syntax `&mut self[begin ..]`. - /// - /// Returns a mutable slice of the string from byte offset `begin` - /// to the end of the string. - /// - /// Equivalent to `&mut self[begin .. len]`. - #[stable(feature = "derefmut_for_string", since = "1.3.0")] - impl ops::IndexMut> for str { - #[inline] - fn index_mut(&mut self, index: ops::RangeFrom) -> &mut str { - index.index_mut(self) - } - } - - /// Implements substring slicing with syntax `&self[..]`. - /// - /// Returns a slice of the whole string. This operation can - /// never panic. - /// - /// Equivalent to `&self[0 .. len]`. - #[stable(feature = "rust1", since = "1.0.0")] - impl ops::Index for str { - type Output = str; - - #[inline] - fn index(&self, _index: ops::RangeFull) -> &str { - self - } - } - - /// Implements mutable substring slicing with syntax `&mut self[..]`. - /// - /// Returns a mutable slice of the whole string. This operation can - /// never panic. - /// - /// Equivalent to `&mut self[0 .. len]`. - #[stable(feature = "derefmut_for_string", since = "1.3.0")] - impl ops::IndexMut for str { - #[inline] - fn index_mut(&mut self, _index: ops::RangeFull) -> &mut str { - self - } - } - - #[stable(feature = "inclusive_range", since = "1.26.0")] - impl ops::Index> for str { - type Output = str; - - #[inline] - fn index(&self, index: ops::RangeInclusive) -> &str { - index.index(self) - } - } - - #[stable(feature = "inclusive_range", since = "1.26.0")] - impl ops::Index> for str { - type Output = str; - - #[inline] - fn index(&self, index: ops::RangeToInclusive) -> &str { - index.index(self) - } - } - - #[stable(feature = "inclusive_range", since = "1.26.0")] - impl ops::IndexMut> for str { - #[inline] - fn index_mut(&mut self, index: ops::RangeInclusive) -> &mut str { - index.index_mut(self) - } - } - #[stable(feature = "inclusive_range", since = "1.26.0")] - impl ops::IndexMut> for str { - #[inline] - fn index_mut(&mut self, index: ops::RangeToInclusive) -> &mut str { + fn index_mut(&mut self, index: I) -> &mut I::Output { index.index_mut(self) } } @@ -1815,6 +1651,18 @@ mod traits { panic!("attempted to index str up to maximum usize"); } + /// Implements substring slicing with syntax `&self[..]` or `&mut self[..]`. + /// + /// Returns a slice of the whole string, i.e., returns `&self` or `&mut + /// self`. Equivalent to `&self[0 .. len]` or `&mut self[0 .. len]`. Unlike + /// other indexing operations, this can never panic. + /// + /// This operation is `O(1)`. + /// + /// Prior to 1.20.0, these indexing operations were still supported by + /// direct implementation of `Index` and `IndexMut`. + /// + /// Equivalent to `&self[0 .. len]` or `&mut self[0 .. len]`. #[stable(feature = "str_checked_slicing", since = "1.20.0")] impl SliceIndex for ops::RangeFull { type Output = str; @@ -1844,6 +1692,41 @@ mod traits { } } + /// Implements substring slicing with syntax `&self[begin .. end]` or `&mut + /// self[begin .. end]`. + /// + /// Returns a slice of the given string from the byte range + /// [`begin`, `end`). + /// + /// This operation is `O(1)`. + /// + /// Prior to 1.20.0, these indexing operations were still supported by + /// direct implementation of `Index` and `IndexMut`. + /// + /// # Panics + /// + /// Panics if `begin` or `end` does not point to the starting byte offset of + /// a character (as defined by `is_char_boundary`), if `begin > end`, or if + /// `end > len`. + /// + /// # Examples + /// + /// ``` + /// let s = "Löwe 老虎 Léopard"; + /// assert_eq!(&s[0 .. 1], "L"); + /// + /// assert_eq!(&s[1 .. 9], "öwe 老"); + /// + /// // these will panic: + /// // byte 2 lies within `ö`: + /// // &s[2 ..3]; + /// + /// // byte 8 lies within `老` + /// // &s[1 .. 8]; + /// + /// // byte 100 is outside the string + /// // &s[3 .. 100]; + /// ``` #[stable(feature = "str_checked_slicing", since = "1.20.0")] impl SliceIndex for ops::Range { type Output = str; @@ -1898,6 +1781,21 @@ mod traits { } } + /// Implements substring slicing with syntax `&self[.. end]` or `&mut + /// self[.. end]`. + /// + /// Returns a slice of the given string from the byte range [`0`, `end`). + /// Equivalent to `&self[0 .. end]` or `&mut self[0 .. end]`. + /// + /// This operation is `O(1)`. + /// + /// Prior to 1.20.0, these indexing operations were still supported by + /// direct implementation of `Index` and `IndexMut`. + /// + /// # Panics + /// + /// Panics if `end` does not point to the starting byte offset of a + /// character (as defined by `is_char_boundary`), or if `end > len`. #[stable(feature = "str_checked_slicing", since = "1.20.0")] impl SliceIndex for ops::RangeTo { type Output = str; @@ -1943,6 +1841,22 @@ mod traits { } } + /// Implements substring slicing with syntax `&self[begin ..]` or `&mut + /// self[begin ..]`. + /// + /// Returns a slice of the given string from the byte range [`begin`, + /// `len`). Equivalent to `&self[begin .. len]` or `&mut self[begin .. + /// len]`. + /// + /// This operation is `O(1)`. + /// + /// Prior to 1.20.0, these indexing operations were still supported by + /// direct implementation of `Index` and `IndexMut`. + /// + /// # Panics + /// + /// Panics if `begin` does not point to the starting byte offset of + /// a character (as defined by `is_char_boundary`), or if `begin >= len`. #[stable(feature = "str_checked_slicing", since = "1.20.0")] impl SliceIndex for ops::RangeFrom { type Output = str; @@ -1990,6 +1904,22 @@ mod traits { } } + /// Implements substring slicing with syntax `&self[begin ..= end]` or `&mut + /// self[begin ..= end]`. + /// + /// Returns a slice of the given string from the byte range + /// [`begin`, `end`]. Equivalent to `&self [begin .. end + 1]` or `&mut + /// self[begin .. end + 1]`, except if `end` has the maximum value for + /// `usize`. + /// + /// This operation is `O(1)`. + /// + /// # Panics + /// + /// Panics if `begin` does not point to the starting byte offset of + /// a character (as defined by `is_char_boundary`), if `end` does not point + /// to the ending byte offset of a character (`end + 1` is either a starting + /// byte offset or equal to `len`), if `begin > end`, or if `end >= len`. #[stable(feature = "inclusive_range", since = "1.26.0")] impl SliceIndex for ops::RangeInclusive { type Output = str; @@ -2023,8 +1953,20 @@ mod traits { } } - - + /// Implements substring slicing with syntax `&self[..= end]` or `&mut + /// self[..= end]`. + /// + /// Returns a slice of the given string from the byte range [0, `end`]. + /// Equivalent to `&self [0 .. end + 1]`, except if `end` has the maximum + /// value for `usize`. + /// + /// This operation is `O(1)`. + /// + /// # Panics + /// + /// Panics if `end` does not point to the ending byte offset of a character + /// (`end + 1` is either a starting byte offset as defined by + /// `is_char_boundary`, or equal to `len`), or if `end >= len`. #[stable(feature = "inclusive_range", since = "1.26.0")] impl SliceIndex for ops::RangeToInclusive { type Output = str; diff --git a/src/test/ui/index-help.stderr b/src/test/ui/index-help.stderr index c8b23d812e1..4c585a958c1 100644 --- a/src/test/ui/index-help.stderr +++ b/src/test/ui/index-help.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `i32: std::slice::SliceIndex<[{integer}]>` is not satisfied +error[E0277]: the type `[{integer}]` cannot be indexed by `i32` --> $DIR/index-help.rs:3:5 | LL | x[0i32]; //~ ERROR E0277 diff --git a/src/test/ui/indexing-requires-a-uint.rs b/src/test/ui/indexing-requires-a-uint.rs index 2db3c58ec51..dbe9b44a138 100644 --- a/src/test/ui/indexing-requires-a-uint.rs +++ b/src/test/ui/indexing-requires-a-uint.rs @@ -3,7 +3,7 @@ fn main() { fn bar(_: T) {} - [0][0u8]; //~ ERROR: the trait bound `u8: std::slice::SliceIndex<[{integer}]>` is not satisfied + [0][0u8]; //~ ERROR: the type `[{integer}]` cannot be indexed by `u8` [0][0]; // should infer to be a usize diff --git a/src/test/ui/indexing-requires-a-uint.stderr b/src/test/ui/indexing-requires-a-uint.stderr index 767f1af2c46..363c3d0d458 100644 --- a/src/test/ui/indexing-requires-a-uint.stderr +++ b/src/test/ui/indexing-requires-a-uint.stderr @@ -1,7 +1,7 @@ -error[E0277]: the trait bound `u8: std::slice::SliceIndex<[{integer}]>` is not satisfied +error[E0277]: the type `[{integer}]` cannot be indexed by `u8` --> $DIR/indexing-requires-a-uint.rs:6:5 | -LL | [0][0u8]; //~ ERROR: the trait bound `u8: std::slice::SliceIndex<[{integer}]>` is not satisfied +LL | [0][0u8]; //~ ERROR: the type `[{integer}]` cannot be indexed by `u8` | ^^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `std::slice::SliceIndex<[{integer}]>` is not implemented for `u8` diff --git a/src/test/ui/integral-indexing.rs b/src/test/ui/integral-indexing.rs index 7bdbc45879b..f076dfcb0a4 100644 --- a/src/test/ui/integral-indexing.rs +++ b/src/test/ui/integral-indexing.rs @@ -3,14 +3,14 @@ pub fn main() { let s: String = "abcdef".to_string(); v[3_usize]; v[3]; - v[3u8]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied - v[3i8]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied - v[3u32]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied - v[3i32]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied + v[3u8]; //~ERROR : the type `[isize]` cannot be indexed by `u8` + v[3i8]; //~ERROR : the type `[isize]` cannot be indexed by `i8` + v[3u32]; //~ERROR : the type `[isize]` cannot be indexed by `u32` + v[3i32]; //~ERROR : the type `[isize]` cannot be indexed by `i32` s.as_bytes()[3_usize]; s.as_bytes()[3]; - s.as_bytes()[3u8]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied - s.as_bytes()[3i8]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied - s.as_bytes()[3u32]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied - s.as_bytes()[3i32]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied + s.as_bytes()[3u8]; //~ERROR : the type `[u8]` cannot be indexed by `u8` + s.as_bytes()[3i8]; //~ERROR : the type `[u8]` cannot be indexed by `i8` + s.as_bytes()[3u32]; //~ERROR : the type `[u8]` cannot be indexed by `u32` + s.as_bytes()[3i32]; //~ERROR : the type `[u8]` cannot be indexed by `i32` } diff --git a/src/test/ui/integral-indexing.stderr b/src/test/ui/integral-indexing.stderr index 7f2dddcf7b8..efbad86c4d3 100644 --- a/src/test/ui/integral-indexing.stderr +++ b/src/test/ui/integral-indexing.stderr @@ -1,70 +1,70 @@ -error[E0277]: the trait bound `u8: std::slice::SliceIndex<[isize]>` is not satisfied +error[E0277]: the type `[isize]` cannot be indexed by `u8` --> $DIR/integral-indexing.rs:6:5 | -LL | v[3u8]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied +LL | v[3u8]; //~ERROR : the type `[isize]` cannot be indexed by `u8` | ^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `std::slice::SliceIndex<[isize]>` is not implemented for `u8` = note: required because of the requirements on the impl of `std::ops::Index` for `std::vec::Vec` -error[E0277]: the trait bound `i8: std::slice::SliceIndex<[isize]>` is not satisfied +error[E0277]: the type `[isize]` cannot be indexed by `i8` --> $DIR/integral-indexing.rs:7:5 | -LL | v[3i8]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied +LL | v[3i8]; //~ERROR : the type `[isize]` cannot be indexed by `i8` | ^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `std::slice::SliceIndex<[isize]>` is not implemented for `i8` = note: required because of the requirements on the impl of `std::ops::Index` for `std::vec::Vec` -error[E0277]: the trait bound `u32: std::slice::SliceIndex<[isize]>` is not satisfied +error[E0277]: the type `[isize]` cannot be indexed by `u32` --> $DIR/integral-indexing.rs:8:5 | -LL | v[3u32]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied +LL | v[3u32]; //~ERROR : the type `[isize]` cannot be indexed by `u32` | ^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `std::slice::SliceIndex<[isize]>` is not implemented for `u32` = note: required because of the requirements on the impl of `std::ops::Index` for `std::vec::Vec` -error[E0277]: the trait bound `i32: std::slice::SliceIndex<[isize]>` is not satisfied +error[E0277]: the type `[isize]` cannot be indexed by `i32` --> $DIR/integral-indexing.rs:9:5 | -LL | v[3i32]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied +LL | v[3i32]; //~ERROR : the type `[isize]` cannot be indexed by `i32` | ^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `std::slice::SliceIndex<[isize]>` is not implemented for `i32` = note: required because of the requirements on the impl of `std::ops::Index` for `std::vec::Vec` -error[E0277]: the trait bound `u8: std::slice::SliceIndex<[u8]>` is not satisfied +error[E0277]: the type `[u8]` cannot be indexed by `u8` --> $DIR/integral-indexing.rs:12:5 | -LL | s.as_bytes()[3u8]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied +LL | s.as_bytes()[3u8]; //~ERROR : the type `[u8]` cannot be indexed by `u8` | ^^^^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `std::slice::SliceIndex<[u8]>` is not implemented for `u8` = note: required because of the requirements on the impl of `std::ops::Index` for `[u8]` -error[E0277]: the trait bound `i8: std::slice::SliceIndex<[u8]>` is not satisfied +error[E0277]: the type `[u8]` cannot be indexed by `i8` --> $DIR/integral-indexing.rs:13:5 | -LL | s.as_bytes()[3i8]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied +LL | s.as_bytes()[3i8]; //~ERROR : the type `[u8]` cannot be indexed by `i8` | ^^^^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `std::slice::SliceIndex<[u8]>` is not implemented for `i8` = note: required because of the requirements on the impl of `std::ops::Index` for `[u8]` -error[E0277]: the trait bound `u32: std::slice::SliceIndex<[u8]>` is not satisfied +error[E0277]: the type `[u8]` cannot be indexed by `u32` --> $DIR/integral-indexing.rs:14:5 | -LL | s.as_bytes()[3u32]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied +LL | s.as_bytes()[3u32]; //~ERROR : the type `[u8]` cannot be indexed by `u32` | ^^^^^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `std::slice::SliceIndex<[u8]>` is not implemented for `u32` = note: required because of the requirements on the impl of `std::ops::Index` for `[u8]` -error[E0277]: the trait bound `i32: std::slice::SliceIndex<[u8]>` is not satisfied +error[E0277]: the type `[u8]` cannot be indexed by `i32` --> $DIR/integral-indexing.rs:15:5 | -LL | s.as_bytes()[3i32]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied +LL | s.as_bytes()[3i32]; //~ERROR : the type `[u8]` cannot be indexed by `i32` | ^^^^^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `std::slice::SliceIndex<[u8]>` is not implemented for `i32` diff --git a/src/test/ui/on-unimplemented/slice-index.stderr b/src/test/ui/on-unimplemented/slice-index.stderr index 3a32e13e0aa..7b45d848c97 100644 --- a/src/test/ui/on-unimplemented/slice-index.stderr +++ b/src/test/ui/on-unimplemented/slice-index.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `i32: std::slice::SliceIndex<[i32]>` is not satisfied +error[E0277]: the type `[i32]` cannot be indexed by `i32` --> $DIR/slice-index.rs:11:5 | LL | x[1i32]; //~ ERROR E0277 @@ -7,7 +7,7 @@ LL | x[1i32]; //~ ERROR E0277 = help: the trait `std::slice::SliceIndex<[i32]>` is not implemented for `i32` = note: required because of the requirements on the impl of `std::ops::Index` for `[i32]` -error[E0277]: the trait bound `std::ops::RangeTo: std::slice::SliceIndex<[i32]>` is not satisfied +error[E0277]: the type `[i32]` cannot be indexed by `std::ops::RangeTo` --> $DIR/slice-index.rs:12:5 | LL | x[..1i32]; //~ ERROR E0277 diff --git a/src/test/ui/str/str-idx.rs b/src/test/ui/str/str-idx.rs index 2ea80494e03..1b32ed5533d 100644 --- a/src/test/ui/str/str-idx.rs +++ b/src/test/ui/str/str-idx.rs @@ -1,4 +1,7 @@ pub fn main() { let s: &str = "hello"; - let c: u8 = s[4]; //~ ERROR the type `str` cannot be indexed by `{integer}` + let _: u8 = s[4]; //~ ERROR the type `str` cannot be indexed by `{integer}` + let _ = s.get(4); //~ ERROR the type `str` cannot be indexed by `{integer}` + let _ = s.get_unchecked(4); //~ ERROR the type `str` cannot be indexed by `{integer}` + let _: u8 = s['c']; //~ ERROR the type `str` cannot be indexed by `char` } diff --git a/src/test/ui/str/str-idx.stderr b/src/test/ui/str/str-idx.stderr index 71b17474923..99df85d92fd 100644 --- a/src/test/ui/str/str-idx.stderr +++ b/src/test/ui/str/str-idx.stderr @@ -1,13 +1,43 @@ error[E0277]: the type `str` cannot be indexed by `{integer}` --> $DIR/str-idx.rs:3:17 | -LL | let c: u8 = s[4]; //~ ERROR the type `str` cannot be indexed by `{integer}` - | ^^^^ `str` cannot be indexed by `{integer}` +LL | let _: u8 = s[4]; //~ ERROR the type `str` cannot be indexed by `{integer}` + | ^^^^ string indices are ranges of `usize` | - = help: the trait `std::ops::Index<{integer}>` is not implemented for `str` + = help: the trait `std::slice::SliceIndex` is not implemented for `{integer}` + = note: you can use `.chars().nth()` or `.bytes().nth()` + see chapter in The Book + = note: required because of the requirements on the impl of `std::ops::Index<{integer}>` for `str` + +error[E0277]: the type `str` cannot be indexed by `{integer}` + --> $DIR/str-idx.rs:4:15 + | +LL | let _ = s.get(4); //~ ERROR the type `str` cannot be indexed by `{integer}` + | ^^^ string indices are ranges of `usize` + | + = help: the trait `std::slice::SliceIndex` is not implemented for `{integer}` = note: you can use `.chars().nth()` or `.bytes().nth()` see chapter in The Book -error: aborting due to previous error +error[E0277]: the type `str` cannot be indexed by `{integer}` + --> $DIR/str-idx.rs:5:15 + | +LL | let _ = s.get_unchecked(4); //~ ERROR the type `str` cannot be indexed by `{integer}` + | ^^^^^^^^^^^^^ string indices are ranges of `usize` + | + = help: the trait `std::slice::SliceIndex` is not implemented for `{integer}` + = note: you can use `.chars().nth()` or `.bytes().nth()` + see chapter in The Book + +error[E0277]: the type `str` cannot be indexed by `char` + --> $DIR/str-idx.rs:6:17 + | +LL | let _: u8 = s['c']; //~ ERROR the type `str` cannot be indexed by `char` + | ^^^^^^ string indices are ranges of `usize` + | + = help: the trait `std::slice::SliceIndex` is not implemented for `char` + = note: required because of the requirements on the impl of `std::ops::Index` for `str` + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/str/str-mut-idx.rs b/src/test/ui/str/str-mut-idx.rs index cebbbc3ccbf..575a9eae859 100644 --- a/src/test/ui/str/str-mut-idx.rs +++ b/src/test/ui/str/str-mut-idx.rs @@ -5,7 +5,13 @@ fn mutate(s: &mut str) { //~^ ERROR the size for values of type //~| ERROR the size for values of type s[1usize] = bot(); - //~^ ERROR the type `str` cannot be mutably indexed by `usize` + //~^ ERROR the type `str` cannot be indexed by `usize` + s.get_mut(1); + //~^ ERROR the type `str` cannot be indexed by `{integer}` + s.get_unchecked_mut(1); + //~^ ERROR the type `str` cannot be indexed by `{integer}` + s['c']; + //~^ ERROR the type `str` cannot be indexed by `char` } pub fn main() {} diff --git a/src/test/ui/str/str-mut-idx.stderr b/src/test/ui/str/str-mut-idx.stderr index a1212c5a4fe..beb22724523 100644 --- a/src/test/ui/str/str-mut-idx.stderr +++ b/src/test/ui/str/str-mut-idx.stderr @@ -22,16 +22,44 @@ LL | s[1..2] = bot(); = note: to learn more, visit = note: the left-hand-side of an assignment must have a statically known size -error[E0277]: the type `str` cannot be mutably indexed by `usize` +error[E0277]: the type `str` cannot be indexed by `usize` --> $DIR/str-mut-idx.rs:7:5 | LL | s[1usize] = bot(); - | ^^^^^^^^^ `str` cannot be mutably indexed by `usize` + | ^^^^^^^^^ string indices are ranges of `usize` | - = help: the trait `std::ops::IndexMut` is not implemented for `str` + = help: the trait `std::slice::SliceIndex` is not implemented for `usize` + = note: required because of the requirements on the impl of `std::ops::Index` for `str` + +error[E0277]: the type `str` cannot be indexed by `{integer}` + --> $DIR/str-mut-idx.rs:9:7 + | +LL | s.get_mut(1); + | ^^^^^^^ string indices are ranges of `usize` + | + = help: the trait `std::slice::SliceIndex` is not implemented for `{integer}` = note: you can use `.chars().nth()` or `.bytes().nth()` see chapter in The Book -error: aborting due to 3 previous errors +error[E0277]: the type `str` cannot be indexed by `{integer}` + --> $DIR/str-mut-idx.rs:11:7 + | +LL | s.get_unchecked_mut(1); + | ^^^^^^^^^^^^^^^^^ string indices are ranges of `usize` + | + = help: the trait `std::slice::SliceIndex` is not implemented for `{integer}` + = note: you can use `.chars().nth()` or `.bytes().nth()` + see chapter in The Book + +error[E0277]: the type `str` cannot be indexed by `char` + --> $DIR/str-mut-idx.rs:13:5 + | +LL | s['c']; + | ^^^^^^ string indices are ranges of `usize` + | + = help: the trait `std::slice::SliceIndex` is not implemented for `char` + = note: required because of the requirements on the impl of `std::ops::Index` for `str` + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0277`. From 2200fd3c7caf19323e7bd4cf649e4ec53d1de369 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 12 Jan 2019 22:25:29 +0100 Subject: [PATCH 06/12] Add default rust logo for documentation --- src/librustdoc/html/layout.rs | 5 ++++- src/librustdoc/html/render.rs | 4 ++++ src/librustdoc/html/static/rust-logo.png | Bin 0 -> 5758 bytes src/librustdoc/html/static_files.rs | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/librustdoc/html/static/rust-logo.png diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index 987cec6fbfa..b7af28fbcc8 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -177,7 +177,10 @@ pub fn render( root_path = page.root_path, css_class = page.css_class, logo = if layout.logo.is_empty() { - String::new() + format!("\ + logo", + static_root_path=static_root_path, + suffix=page.resource_suffix) } else { format!("\ logo", diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 31e06cb1a04..d050b706f10 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -789,6 +789,10 @@ fn write_shared( themes.insert(theme.to_owned()); } + if (*cx.shared).layout.logo.is_empty() { + write(cx.dst.join(&format!("rust-logo{}.png", cx.shared.resource_suffix)), + static_files::RUST_LOGO)?; + } write(cx.dst.join(&format!("brush{}.svg", cx.shared.resource_suffix)), static_files::BRUSH_SVG)?; write(cx.dst.join(&format!("wheel{}.svg", cx.shared.resource_suffix)), diff --git a/src/librustdoc/html/static/rust-logo.png b/src/librustdoc/html/static/rust-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..74b4bd695045ebc52c21af95301adc9311ca881c GIT binary patch literal 5758 zcmeAS@N?(olHy`uVBq!ia0y~yU}ykg4i*LmhD`I74h#%puAVNAAr-go#&S;yIXZLS zA{!TVLxpoCcUSG&p8ws4d6&>+9XGR^8A|(__$4};HCo>MieSCiJ45*EkqROC89Qbj z{kl-GBMYs-EaO<6YO->H;Mp9}eyPWINHGEa|n;*Ez(H%&>L7~ga$sO;#; zbH|mZuuZoUFfgA!%lTus2_v`j$FocI;^3ON_@Z-;B0r3Mr@3ziy zeG;gXI`5y$^8Ia>f>!RTzWr>)jzdow*;xV{r~U3fVD8T)v+;)bk%?Uoub;W<5_f6W z^p}GEe?6D)ZwpdCEq8iJz$4e64;T5wKR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^0)=d%Tp;ov6pubZGQ74MfQ{b(}g16FLZBBogsZU zuUE&t+tt@xSm(p(q-~*_8~GaaFaI)ae>e5&ivRzfrX?==@q4T2zva588$8N0K0i%& zasOTwYWn4~?dKym_ixT+db!Nfdw<`j@GkpQo5L^nFDxiYOgdwxvr+4qkxhiq=83X1 zk4u=JxS^P`bLkszA&qzE>vzwV`J?$O{^YgU`y-SeJI^kWS^s$UjmS-BKm7alufkH3 zrMa2^Nc`v0pJx>(@AUZp|4H-0A8Gr&SNvlC*?&Af-}tEQ$`4KtS1QO~>`DB!KD^yk v#bP0l+XkK|AsFv literal 0 HcmV?d00001 diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index f340590e5fe..bd048d2ec97 100644 --- a/src/librustdoc/html/static_files.rs +++ b/src/librustdoc/html/static_files.rs @@ -51,6 +51,9 @@ pub static LICENSE_APACHE: &'static [u8] = include_bytes!("static/LICENSE-APACHE /// The contents of `LICENSE-MIT.txt`, the text of the MIT License. pub static LICENSE_MIT: &'static [u8] = include_bytes!("static/LICENSE-MIT.txt"); +/// The contents of `rust-logo.png`, the default icon of the documentation. +pub static RUST_LOGO: &'static [u8] = include_bytes!("static/rust-logo.png"); + /// The built-in themes given to every documentation site. pub mod themes { /// The "light" theme, selected by default when no setting is available. Used as the basis for From 98d4f33626c4a18092cd015b4e1cc15381989677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Wed, 16 Jan 2019 20:45:53 +0100 Subject: [PATCH 07/12] const_eval: Predetermine the layout of all locals when pushing a stack frame Usually the layout of any locals is required at least three times, once when it becomes live, once when it is written to, and once it is read from. By adding a cache for them, we can reduce the number of layout queries speeding up code that is heavy on const_eval. --- src/librustc_mir/const_eval.rs | 1 + src/librustc_mir/interpret/eval_context.rs | 19 ++++++++++++++----- src/librustc_mir/interpret/operand.rs | 18 ++++++------------ src/librustc_mir/interpret/snapshot.rs | 4 +++- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index f5f40481679..105856fecc7 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -72,6 +72,7 @@ fn mk_eval_cx_inner<'a, 'mir, 'tcx>( ecx.stack.push(interpret::Frame { block: mir::START_BLOCK, locals: IndexVec::new(), + local_layouts: IndexVec::new(), instance, span, mir, diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 19362b6cfdb..b2d3328a73f 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -1,3 +1,4 @@ +use std::cell::Cell; use std::fmt::Write; use std::mem; @@ -76,6 +77,7 @@ pub struct Frame<'mir, 'tcx: 'mir, Tag=(), Extra=()> { /// `None` represents a local that is currently dead, while a live local /// can either directly contain `Scalar` or refer to some part of an `Allocation`. pub locals: IndexVec>, + pub local_layouts: IndexVec>>>, //////////////////////////////////////////////////////////////////////////////// // Current position within the function @@ -290,9 +292,15 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc frame: &Frame<'mir, 'tcx, M::PointerTag, M::FrameExtra>, local: mir::Local ) -> EvalResult<'tcx, TyLayout<'tcx>> { - let local_ty = frame.mir.local_decls[local].ty; - let local_ty = self.monomorphize(local_ty, frame.instance.substs); - self.layout_of(local_ty) + let cell = &frame.local_layouts[local]; + if cell.get().is_none() { + let local_ty = frame.mir.local_decls[local].ty; + let local_ty = self.monomorphize(local_ty, frame.instance.substs); + let layout = self.layout_of(local_ty)?; + cell.set(Some(layout)); + } + + Ok(cell.get().unwrap()) } pub fn str_to_immediate(&mut self, s: &str) -> EvalResult<'tcx, Immediate> { @@ -426,6 +434,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc // empty local array, we fill it in below, after we are inside the stack frame and // all methods actually know about the frame locals: IndexVec::new(), + local_layouts: IndexVec::from_elem_n(Default::default(), mir.local_decls.len()), span, instance, stmt: 0, @@ -464,11 +473,11 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc }, } // Finally, properly initialize all those that still have the dummy value - for (local, decl) in locals.iter_mut().zip(mir.local_decls.iter()) { + for (idx, local) in locals.iter_enumerated_mut() { match *local { LocalValue::Live(_) => { // This needs to be peoperly initialized. - let layout = self.layout_of(self.monomorphize(decl.ty, instance.substs))?; + let layout = self.layout_of_local(self.frame(), idx)?; *local = LocalValue::Live(self.uninit_operand(layout)?); } LocalValue::Dead => { diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index 04e0955ad61..b2648480f20 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -457,36 +457,30 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> } /// This is used by [priroda](https://github.com/oli-obk/priroda) to get an OpTy from a local - /// - /// When you know the layout of the local in advance, you can pass it as last argument - pub fn access_local( + fn access_local( &self, frame: &super::Frame<'mir, 'tcx, M::PointerTag, M::FrameExtra>, local: mir::Local, - layout: Option>, ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { assert_ne!(local, mir::RETURN_PLACE); let op = *frame.locals[local].access()?; - let layout = from_known_layout(layout, - || self.layout_of_local(frame, local))?; + let layout = self.layout_of_local(frame, local)?; Ok(OpTy { op, layout }) } // Evaluate a place with the goal of reading from it. This lets us sometimes - // avoid allocations. If you already know the layout, you can pass it in - // to avoid looking it up again. + // avoid allocations. fn eval_place_to_op( &self, mir_place: &mir::Place<'tcx>, - layout: Option>, ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { use rustc::mir::Place::*; let op = match *mir_place { Local(mir::RETURN_PLACE) => return err!(ReadFromReturnPointer), - Local(local) => self.access_local(self.frame(), local, layout)?, + Local(local) => self.access_local(self.frame(), local)?, Projection(ref proj) => { - let op = self.eval_place_to_op(&proj.base, None)?; + let op = self.eval_place_to_op(&proj.base)?; self.operand_projection(op, &proj.elem)? } @@ -510,7 +504,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> // FIXME: do some more logic on `move` to invalidate the old location Copy(ref place) | Move(ref place) => - self.eval_place_to_op(place, layout)?, + self.eval_place_to_op(place)?, Constant(ref constant) => { let layout = from_known_layout(layout, || { diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index f9ce7b4319f..53105266b39 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -314,13 +314,14 @@ struct FrameSnapshot<'a, 'tcx: 'a> { stmt: usize, } -impl_stable_hash_for!(impl<'tcx, 'mir: 'tcx> for struct Frame<'mir, 'tcx> { +impl_stable_hash_for!(impl<'mir, 'tcx: 'mir> for struct Frame<'mir, 'tcx> { mir, instance, span, return_to_block, return_place -> (return_place.as_ref().map(|r| &**r)), locals, + local_layouts -> _, block, stmt, extra, @@ -339,6 +340,7 @@ impl<'a, 'mir, 'tcx, Ctx> Snapshot<'a, Ctx> for &'a Frame<'mir, 'tcx> return_to_block, return_place, locals, + local_layouts: _, block, stmt, extra: _, From b5d167f58a423cb0003714eceeb72172d1726473 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 12 Jan 2019 22:27:09 +0100 Subject: [PATCH 08/12] Add default favicon for documentation --- src/librustdoc/html/layout.rs | 4 +++- src/librustdoc/html/render.rs | 6 ++++-- src/librustdoc/html/static/favicon.ico | Bin 0 -> 23229 bytes src/librustdoc/html/static_files.rs | 2 ++ 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 src/librustdoc/html/static/favicon.ico diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index b7af28fbcc8..c34dcbbb672 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -191,7 +191,9 @@ pub fn render( description = page.description, keywords = page.keywords, favicon = if layout.favicon.is_empty() { - String::new() + format!(r#""#, + static_root_path=static_root_path, + suffix=page.resource_suffix) } else { format!(r#""#, layout.favicon) }, diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index d050b706f10..b64ac950963 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -793,6 +793,10 @@ fn write_shared( write(cx.dst.join(&format!("rust-logo{}.png", cx.shared.resource_suffix)), static_files::RUST_LOGO)?; } + if (*cx.shared).layout.favicon.is_empty() { + write(cx.dst.join(&format!("favicon{}.ico", cx.shared.resource_suffix)), + static_files::RUST_FAVICON)?; + } write(cx.dst.join(&format!("brush{}.svg", cx.shared.resource_suffix)), static_files::BRUSH_SVG)?; write(cx.dst.join(&format!("wheel{}.svg", cx.shared.resource_suffix)), @@ -1999,8 +2003,6 @@ impl Context { themes.push(PathBuf::from("settings.css")); let mut layout = self.shared.layout.clone(); layout.krate = String::new(); - layout.logo = String::new(); - layout.favicon = String::new(); try_err!(layout::render(&mut w, &layout, &page, &sidebar, &settings, self.shared.css_file_extension.is_some(), diff --git a/src/librustdoc/html/static/favicon.ico b/src/librustdoc/html/static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..b8ad23769ac8d06eb5973bfb3d2acbf385240f98 GIT binary patch literal 23229 zcmZQzU}RunIC2C;D=_SrXJBw+U|=vXfbdtSGBB_zFfb@6K=}d;3~OB(7z6|${0tTb zhR`quhRy&#cU~?jE(Qh$UQZ8~AO;48BOuJd#=yXEU|C-_1A}~E-~p& zUVB2ovC&|Q0)r0UQCm9N+SrmickyOqyik*B&&bGFSlH3lCWf7P?8se%tSc+D-n{Uhb3)_6 z?*oAk7td$9|7F$LX91o^-tInX<>GAOmm-foDV3?9&IvWmZaJ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cwdLiNozc?_ln+X4 zAp1#fe}n7>VQ6{)wFyCK7GxGW2CZd5Zet?LgY1=%cQHnH|2>w&hFK=lQv&H}|N2!q%lF|zufFn0_P z{r~^3`2YVeaR2{*fcZaYnBfQe1Nk5EzvMr}|Kk53|AYU-|Ns047#=V`V0gfOfZ+gh zd;7u0i&lB0o8dR3}VADNDUvdIZ(Z@Iebvv2%0}rlb2U!f?^OGBnFZL znFCS_Hv`FDP`<(0mxJ~tKx#l{ECsm%>R%8ag!e+*D4=!<468%;4}j7mNDQO~q!xr> zVFhC2!VdEC%AoQKn>;8?L17D$1C5b`%2yB@ghA`%6F~Fq^76`8kjkDid3ohrC?BL3 z6hGgfegU5eo zM_73TQU}_b(g;-t(hG_MkT@X>s<)b;dmUiu2%Mgg($8yXxesz9ItI04Kz_LiwHus% zpkV<@`=B%la>Ezsyqg+G4us|9l|lXmxfy0JNG&}5Le+rG0Obvk888eAUr;#1_#hgj z21PGOKMX_DGbmg@VGGg^!XP$C4D4T+S`hsMG Date: Sun, 20 Jan 2019 17:14:15 -0800 Subject: [PATCH 09/12] Add regression test for #54582 --- src/test/ui/issues/issue-54582.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/test/ui/issues/issue-54582.rs diff --git a/src/test/ui/issues/issue-54582.rs b/src/test/ui/issues/issue-54582.rs new file mode 100644 index 00000000000..c2dbf361911 --- /dev/null +++ b/src/test/ui/issues/issue-54582.rs @@ -0,0 +1,16 @@ +// run-pass + +pub trait Stage: Sync {} + +pub enum Enum { + A, + B, +} + +impl Stage for Enum {} + +pub static ARRAY: [(&Stage, &str); 1] = [ + (&Enum::A, ""), +]; + +fn main() {} From 58b02000c51c1bd460f089368481e1552e0f86ac Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 21 Jan 2019 18:50:54 +0100 Subject: [PATCH 10/12] Add powerpc64-unknown-freebsd --- src/librustc_target/spec/mod.rs | 1 + .../spec/powerpc64_unknown_freebsd.rs | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/librustc_target/spec/powerpc64_unknown_freebsd.rs diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 3a21ca19b17..e47da3cff95 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -367,6 +367,7 @@ supported_targets! { ("aarch64-unknown-freebsd", aarch64_unknown_freebsd), ("i686-unknown-freebsd", i686_unknown_freebsd), + ("powerpc64-unknown-freebsd", powerpc64_unknown_freebsd), ("x86_64-unknown-freebsd", x86_64_unknown_freebsd), ("i686-unknown-dragonfly", i686_unknown_dragonfly), diff --git a/src/librustc_target/spec/powerpc64_unknown_freebsd.rs b/src/librustc_target/spec/powerpc64_unknown_freebsd.rs new file mode 100644 index 00000000000..cc7b87bfdeb --- /dev/null +++ b/src/librustc_target/spec/powerpc64_unknown_freebsd.rs @@ -0,0 +1,22 @@ +use spec::{LinkerFlavor, Target, TargetResult}; + +pub fn target() -> TargetResult { + let mut base = super::freebsd_base::opts(); + base.cpu = "ppc64".to_string(); + base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string()); + base.max_atomic_width = Some(64); + + Ok(Target { + llvm_target: "powerpc64-unknown-freebsd".to_string(), + target_endian: "big".to_string(), + target_pointer_width: "64".to_string(), + target_c_int_width: "32".to_string(), + data_layout: "E-m:e-i64:64-n32:64".to_string(), + arch: "powerpc64".to_string(), + target_os: "freebsd".to_string(), + target_env: String::new(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + options: base, + }) +} From 400e28d27af3c4e0f7fca2274cb1817651d7ba37 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 21 Jan 2019 14:48:07 +0000 Subject: [PATCH 11/12] fix validation range printing when encountering undef --- src/librustc_mir/interpret/validity.rs | 9 +++++++-- src/test/ui/consts/const-eval/ub-nonnull.rs | 7 +++++++ src/test/ui/consts/const-eval/ub-nonnull.stderr | 14 +++++++++++--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index a5fb4458740..8f5a5bf8ee3 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -449,8 +449,13 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> } // At least one value is excluded. Get the bits. let value = try_validation!(value.not_undef(), - value, self.path, - format!("something in the range {:?}", layout.valid_range)); + value, + self.path, + format!( + "something {}", + wrapping_range_format(&layout.valid_range, max_hi), + ) + ); let bits = match value { Scalar::Ptr(ptr) => { if lo == 1 && hi == max_hi { diff --git a/src/test/ui/consts/const-eval/ub-nonnull.rs b/src/test/ui/consts/const-eval/ub-nonnull.rs index 7fbcab8245a..3e0b0948ef3 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.rs +++ b/src/test/ui/consts/const-eval/ub-nonnull.rs @@ -13,6 +13,13 @@ const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; //~^ ERROR it is undefined behavior to use this value +union Transmute { + uninit: (), + out: NonZeroU8, +} +const UNINIT: NonZeroU8 = unsafe { Transmute { uninit: () }.out }; +//~^ ERROR it is undefined behavior to use this value + // Also test other uses of rustc_layout_scalar_valid_range_start #[rustc_layout_scalar_valid_range_start(10)] diff --git a/src/test/ui/consts/const-eval/ub-nonnull.stderr b/src/test/ui/consts/const-eval/ub-nonnull.stderr index 5f8e0c73fbb..6230712ad6f 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.stderr +++ b/src/test/ui/consts/const-eval/ub-nonnull.stderr @@ -23,7 +23,15 @@ LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:21:1 + --> $DIR/ub-nonnull.rs:20:1 + | +LL | const UNINIT: NonZeroU8 = unsafe { Transmute { uninit: () }.out }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected something greater or equal to 1 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: it is undefined behavior to use this value + --> $DIR/ub-nonnull.rs:28:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 42, but expected something in the range 10..=30 @@ -31,13 +39,13 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:27:1 + --> $DIR/ub-nonnull.rs:34:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 20, but expected something less or equal to 10, or greater or equal to 30 | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0080`. From 051835b903181ac0a2e549327de9e8d89cf3d457 Mon Sep 17 00:00:00 2001 From: Marcel Hellwig Date: Mon, 21 Jan 2019 08:09:56 +0100 Subject: [PATCH 12/12] Corrected spelling inconsistency resolves #57773 --- src/librustc/hir/lowering.rs | 4 ++-- src/libsyntax/ast.rs | 8 ++++---- src/libsyntax/fold.rs | 12 ++++++------ src/libsyntax/parse/parser.rs | 4 ++-- ...ggestion.rs => parenthesized-deref-suggestion.rs} | 0 ....stderr => parenthesized-deref-suggestion.stderr} | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) rename src/test/ui/{parenthesised-deref-suggestion.rs => parenthesized-deref-suggestion.rs} (100%) rename src/test/ui/{parenthesised-deref-suggestion.stderr => parenthesized-deref-suggestion.stderr} (88%) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index f7af135bc76..905a3ceed81 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1931,7 +1931,7 @@ impl<'a> LoweringContext<'a> { fn lower_parenthesized_parameter_data( &mut self, - data: &ParenthesisedArgs, + data: &ParenthesizedArgs, ) -> (hir::GenericArgs, bool) { // Switch to `PassThrough` mode for anonymous lifetimes: this // means that we permit things like `&Ref`, where `Ref` has @@ -1941,7 +1941,7 @@ impl<'a> LoweringContext<'a> { self.with_anonymous_lifetime_mode( AnonymousLifetimeMode::PassThrough, |this| { - let &ParenthesisedArgs { ref inputs, ref output, span } = data; + let &ParenthesizedArgs { ref inputs, ref output, span } = data; let inputs = inputs .iter() .map(|ty| this.lower_ty_direct(ty, ImplTraitContext::disallowed())) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 405cf612543..798f14dcba9 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -136,7 +136,7 @@ pub enum GenericArgs { /// The `<'a, A,B,C>` in `foo::bar::baz::<'a, A,B,C>` AngleBracketed(AngleBracketedArgs), /// The `(A,B)` and `C` in `Foo(A,B) -> C` - Parenthesized(ParenthesisedArgs), + Parenthesized(ParenthesizedArgs), } impl GenericArgs { @@ -173,7 +173,7 @@ impl Into>> for AngleBracketedArgs { } } -impl Into>> for ParenthesisedArgs { +impl Into>> for ParenthesizedArgs { fn into(self) -> Option> { Some(P(GenericArgs::Parenthesized(self))) } @@ -181,7 +181,7 @@ impl Into>> for ParenthesisedArgs { /// A path like `Foo(A,B) -> C` #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub struct ParenthesisedArgs { +pub struct ParenthesizedArgs { /// Overall span pub span: Span, @@ -192,7 +192,7 @@ pub struct ParenthesisedArgs { pub output: Option>, } -impl ParenthesisedArgs { +impl ParenthesizedArgs { pub fn as_angle_bracketed_args(&self) -> AngleBracketedArgs { AngleBracketedArgs { span: self.span, diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index a4c3b38f691..fdcbbb939a6 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -207,8 +207,8 @@ pub trait Folder : Sized { noop_fold_angle_bracketed_parameter_data(p, self) } - fn fold_parenthesized_parameter_data(&mut self, p: ParenthesisedArgs) - -> ParenthesisedArgs + fn fold_parenthesized_parameter_data(&mut self, p: ParenthesizedArgs) + -> ParenthesizedArgs { noop_fold_parenthesized_parameter_data(p, self) } @@ -504,12 +504,12 @@ pub fn noop_fold_angle_bracketed_parameter_data(data: AngleBracketedA } } -pub fn noop_fold_parenthesized_parameter_data(data: ParenthesisedArgs, +pub fn noop_fold_parenthesized_parameter_data(data: ParenthesizedArgs, fld: &mut T) - -> ParenthesisedArgs + -> ParenthesizedArgs { - let ParenthesisedArgs { inputs, output, span } = data; - ParenthesisedArgs { + let ParenthesizedArgs { inputs, output, span } = data; + ParenthesizedArgs { inputs: inputs.move_map(|ty| fld.fold_ty(ty)), output: output.map(|ty| fld.fold_ty(ty)), span: fld.new_span(span) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 439eec5b0c4..09ea0995253 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1,5 +1,5 @@ use rustc_target::spec::abi::{self, Abi}; -use ast::{AngleBracketedArgs, ParenthesisedArgs, AttrStyle, BareFnTy}; +use ast::{AngleBracketedArgs, ParenthesizedArgs, AttrStyle, BareFnTy}; use ast::{GenericBound, TraitBoundModifier}; use ast::Unsafety; use ast::{Mod, AnonConst, Arg, Arm, Guard, Attribute, BindingMode, TraitItemKind}; @@ -2203,7 +2203,7 @@ impl<'a> Parser<'a> { } else { None }; - ParenthesisedArgs { inputs, output, span }.into() + ParenthesizedArgs { inputs, output, span }.into() }; PathSegment { ident, args, id: ast::DUMMY_NODE_ID } diff --git a/src/test/ui/parenthesised-deref-suggestion.rs b/src/test/ui/parenthesized-deref-suggestion.rs similarity index 100% rename from src/test/ui/parenthesised-deref-suggestion.rs rename to src/test/ui/parenthesized-deref-suggestion.rs diff --git a/src/test/ui/parenthesised-deref-suggestion.stderr b/src/test/ui/parenthesized-deref-suggestion.stderr similarity index 88% rename from src/test/ui/parenthesised-deref-suggestion.stderr rename to src/test/ui/parenthesized-deref-suggestion.stderr index 71a2bf67f06..fd9b0e8216b 100644 --- a/src/test/ui/parenthesised-deref-suggestion.stderr +++ b/src/test/ui/parenthesized-deref-suggestion.stderr @@ -1,5 +1,5 @@ error[E0609]: no field `opts` on type `*const Session` - --> $DIR/parenthesised-deref-suggestion.rs:7:30 + --> $DIR/parenthesized-deref-suggestion.rs:7:30 | LL | (sess as *const Session).opts; //~ ERROR no field `opts` on type `*const Session` | ^^^^ @@ -9,7 +9,7 @@ LL | (*(sess as *const Session)).opts; //~ ERROR no field `opts` on type `*c | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0609]: no field `0` on type `[u32; 1]` - --> $DIR/parenthesised-deref-suggestion.rs:10:21 + --> $DIR/parenthesized-deref-suggestion.rs:10:21 | LL | (x as [u32; 1]).0; //~ ERROR no field `0` on type `[u32; 1]` | ----------------^