Skip to content

Commit 7a0e6a8

Browse files
committed
Auto merge of #51082 - kennytm:rollup, r=kennytm
Rollup of 11 pull requests Successful merges: - #50987 (Underline multiple suggested replacements in the same line) - #51014 (Add documentation about env! second argument) - #51034 (Remove unused lowering field and method) - #51047 (Use AllFacts from polonius-engine) - #51048 (Add more missing examples for Formatter) - #51056 (Mention and use `Once::new` instead of `ONCE_INIT`) - #51059 (What does an expression look like, that consists only of special characters?) - #51065 (Update nomicon link in transmute docs) - #51067 (Add inner links in documentation) - #51070 (Fail typecheck if we encounter a bogus break) - #51073 (Rename TokenStream::empty to TokenStream::new) Failed merges:
2 parents b4247d4 + 84b2e14 commit 7a0e6a8

File tree

31 files changed

+512
-295
lines changed

31 files changed

+512
-295
lines changed

src/Cargo.lock

+8
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,11 @@ name = "pkg-config"
14411441
version = "0.3.9"
14421442
source = "registry+https://github.com/rust-lang/crates.io-index"
14431443

1444+
[[package]]
1445+
name = "polonius-engine"
1446+
version = "0.1.1"
1447+
source = "registry+https://github.com/rust-lang/crates.io-index"
1448+
14441449
[[package]]
14451450
name = "precomputed-hash"
14461451
version = "0.1.1"
@@ -1763,6 +1768,7 @@ dependencies = [
17631768
"jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
17641769
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
17651770
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
1771+
"polonius-engine 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
17661772
"proc_macro 0.0.0",
17671773
"rustc_apfloat 0.0.0",
17681774
"rustc_data_structures 0.0.0",
@@ -2135,6 +2141,7 @@ dependencies = [
21352141
"graphviz 0.0.0",
21362142
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
21372143
"log_settings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
2144+
"polonius-engine 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
21382145
"rustc 0.0.0",
21392146
"rustc_apfloat 0.0.0",
21402147
"rustc_data_structures 0.0.0",
@@ -3134,6 +3141,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
31343141
"checksum phf_generator 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6b07ffcc532ccc85e3afc45865469bf5d9e4ef5bfcf9622e3cfe80c2d275ec03"
31353142
"checksum phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "07e24b0ca9643bdecd0632f2b3da6b1b89bbb0030e0b992afc1113b23a7bc2f2"
31363143
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
3144+
"checksum polonius-engine 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6201ffe79e3da53bd065fbec2a9b391e5a0dc21038b39bb300612ddc658eb7ee"
31373145
"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
31383146
"checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6"
31393147
"checksum proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "49b6a521dc81b643e9a51e0d1cf05df46d5a2f3c0280ea72bcb68276ba64a118"

src/liballoc/fmt.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@
340340
//!
341341
//! ## Fill/Alignment
342342
//!
343-
//! The fill character is provided normally in conjunction with the `width`
343+
//! The fill character is provided normally in conjunction with the
344+
//! [`width`](#width)
344345
//! parameter. This indicates that if the value being formatted is smaller than
345346
//! `width` some extra characters will be printed around it. The extra
346347
//! characters are specified by `fill`, and the alignment can be one of the
@@ -388,7 +389,8 @@
388389
//! padding specified by fill/alignment will be used to take up the required
389390
//! space.
390391
//!
391-
//! The default fill/alignment for non-numerics is a space and left-aligned. The
392+
//! The default [fill/alignment](#fillalignment) for non-numerics is a space and
393+
//! left-aligned. The
392394
//! defaults for numeric formatters is also a space but with right-alignment. If
393395
//! the `0` flag is specified for numerics, then the implicit fill character is
394396
//! `0`.

src/libcore/fmt/mod.rs

+78-3
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,23 @@ impl<'a> Formatter<'a> {
12021202
/// is longer than this length
12031203
///
12041204
/// Notably this function ignores the `flag` parameters.
1205+
///
1206+
/// # Examples
1207+
///
1208+
/// ```
1209+
/// use std::fmt;
1210+
///
1211+
/// struct Foo;
1212+
///
1213+
/// impl fmt::Display for Foo {
1214+
/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1215+
/// formatter.pad("Foo")
1216+
/// }
1217+
/// }
1218+
///
1219+
/// assert_eq!(&format!("{:<4}", Foo), "Foo ");
1220+
/// assert_eq!(&format!("{:0>4}", Foo), "0Foo");
1221+
/// ```
12051222
#[stable(feature = "rust1", since = "1.0.0")]
12061223
pub fn pad(&mut self, s: &str) -> Result {
12071224
// Make sure there's a fast path up front
@@ -1368,7 +1385,7 @@ impl<'a> Formatter<'a> {
13681385
self.buf.write_str(data)
13691386
}
13701387

1371-
/// Writes some formatted information into this instance
1388+
/// Writes some formatted information into this instance.
13721389
#[stable(feature = "rust1", since = "1.0.0")]
13731390
pub fn write_fmt(&mut self, fmt: Arguments) -> Result {
13741391
write(self.buf, fmt)
@@ -1381,11 +1398,69 @@ impl<'a> Formatter<'a> {
13811398
or `sign_aware_zero_pad` methods instead")]
13821399
pub fn flags(&self) -> u32 { self.flags }
13831400

1384-
/// Character used as 'fill' whenever there is alignment
1401+
/// Character used as 'fill' whenever there is alignment.
1402+
///
1403+
/// # Examples
1404+
///
1405+
/// ```
1406+
/// use std::fmt;
1407+
///
1408+
/// struct Foo;
1409+
///
1410+
/// impl fmt::Display for Foo {
1411+
/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1412+
/// let c = formatter.fill();
1413+
/// if let Some(width) = formatter.width() {
1414+
/// for _ in 0..width {
1415+
/// write!(formatter, "{}", c)?;
1416+
/// }
1417+
/// Ok(())
1418+
/// } else {
1419+
/// write!(formatter, "{}", c)
1420+
/// }
1421+
/// }
1422+
/// }
1423+
///
1424+
/// // We set alignment to the left with ">".
1425+
/// assert_eq!(&format!("{:G>3}", Foo), "GGG");
1426+
/// assert_eq!(&format!("{:t>6}", Foo), "tttttt");
1427+
/// ```
13851428
#[stable(feature = "fmt_flags", since = "1.5.0")]
13861429
pub fn fill(&self) -> char { self.fill }
13871430

1388-
/// Flag indicating what form of alignment was requested
1431+
/// Flag indicating what form of alignment was requested.
1432+
///
1433+
/// # Examples
1434+
///
1435+
/// ```
1436+
/// #![feature(fmt_flags_align)]
1437+
///
1438+
/// extern crate core;
1439+
///
1440+
/// use std::fmt;
1441+
/// use core::fmt::Alignment;
1442+
///
1443+
/// struct Foo;
1444+
///
1445+
/// impl fmt::Display for Foo {
1446+
/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1447+
/// let s = match formatter.align() {
1448+
/// Alignment::Left => "left",
1449+
/// Alignment::Right => "right",
1450+
/// Alignment::Center => "center",
1451+
/// Alignment::Unknown => "into the void",
1452+
/// };
1453+
/// write!(formatter, "{}", s)
1454+
/// }
1455+
/// }
1456+
///
1457+
/// fn main() {
1458+
/// assert_eq!(&format!("{:<}", Foo), "left");
1459+
/// assert_eq!(&format!("{:>}", Foo), "right");
1460+
/// assert_eq!(&format!("{:^}", Foo), "center");
1461+
/// assert_eq!(&format!("{}", Foo), "into the void");
1462+
/// }
1463+
/// ```
13891464
#[unstable(feature = "fmt_flags_align", reason = "method was just created",
13901465
issue = "27726")]
13911466
pub fn align(&self) -> Alignment {

src/libcore/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ extern "rust-intrinsic" {
717717
/// Reinterprets the bits of a value of one type as another type.
718718
///
719719
/// Both types must have the same size. Neither the original, nor the result,
720-
/// may be an [invalid value](../../nomicon/meet-safe-and-unsafe.html).
720+
/// may be an [invalid value](../../nomicon/what-unsafe-does.html).
721721
///
722722
/// `transmute` is semantically equivalent to a bitwise move of one type
723723
/// into another. It copies the bits from the source value into the

src/libproc_macro/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl !Sync for LexError {}
9393
impl TokenStream {
9494
/// Returns an empty `TokenStream` containing no token trees.
9595
#[unstable(feature = "proc_macro", issue = "38356")]
96-
pub fn empty() -> TokenStream {
96+
pub fn new() -> TokenStream {
9797
TokenStream(tokenstream::TokenStream::empty())
9898
}
9999

src/libproc_macro/quote.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ macro_rules! quote_tree {
7171
}
7272

7373
macro_rules! quote {
74-
() => { TokenStream::empty() };
74+
() => { TokenStream::new() };
7575
($($t:tt)*) => {
7676
[$(quote_tree!($t),)*].iter()
7777
.cloned()
@@ -104,7 +104,7 @@ impl<T: Quote> Quote for Option<T> {
104104
impl Quote for TokenStream {
105105
fn quote(self) -> TokenStream {
106106
if self.is_empty() {
107-
return quote!(::TokenStream::empty());
107+
return quote!(::TokenStream::new());
108108
}
109109
let mut after_dollar = false;
110110
let tokens = self.into_iter().filter_map(|tree| {

src/librustc/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ graphviz = { path = "../libgraphviz" }
1616
jobserver = "0.1"
1717
lazy_static = "1.0.0"
1818
log = { version = "0.4", features = ["release_max_level_info", "std"] }
19+
polonius-engine = "0.1.1"
1920
proc_macro = { path = "../libproc_macro" }
2021
rustc_apfloat = { path = "../librustc_apfloat" }
2122
rustc_target = { path = "../librustc_target" }

0 commit comments

Comments
 (0)