Skip to content

Commit 521d91c

Browse files
committed
Auto merge of #49008 - kennytm:rollup, r=kennytm
Rollup of 12 pull requests - Successful merges: #48765, #48831, #48840, #48964, #48970, #48971, #48981, #48988, #48991, #48966, #48993, #48874 - Failed merges:
2 parents e96e54d + beab2e6 commit 521d91c

File tree

24 files changed

+266
-546
lines changed

24 files changed

+266
-546
lines changed

src/doc/rustdoc/src/documentation-tests.md

+4
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@ running `rustdoc --test foo.rs` will extract this example, and then run it as a
1919
Please note that by default, if no language is set for the block code, `rustdoc`
2020
assumes it is `Rust` code. So the following:
2121

22+
``````markdown
2223
```rust
2324
let x = 5;
2425
```
26+
``````
2527

2628
is strictly equivalent to:
2729

30+
``````markdown
2831
```
2932
let x = 5;
3033
```
34+
``````
3135

3236
There's some subtlety though! Read on for more details.
3337

src/libcore/fmt/mod.rs

+134-2
Original file line numberDiff line numberDiff line change
@@ -1379,27 +1379,159 @@ impl<'a> Formatter<'a> {
13791379
}
13801380
}
13811381

1382-
/// Optionally specified integer width that the output should be
1382+
/// Optionally specified integer width that the output should be.
1383+
///
1384+
/// # Examples
1385+
///
1386+
/// ```
1387+
/// use std::fmt;
1388+
///
1389+
/// struct Foo(i32);
1390+
///
1391+
/// impl fmt::Display for Foo {
1392+
/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1393+
/// if let Some(width) = formatter.width() {
1394+
/// // If we received a width, we use it
1395+
/// write!(formatter, "{:width$}", &format!("Foo({})", self.0), width = width)
1396+
/// } else {
1397+
/// // Otherwise we do nothing special
1398+
/// write!(formatter, "Foo({})", self.0)
1399+
/// }
1400+
/// }
1401+
/// }
1402+
///
1403+
/// assert_eq!(&format!("{:10}", Foo(23)), "Foo(23) ");
1404+
/// assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
1405+
/// ```
13831406
#[stable(feature = "fmt_flags", since = "1.5.0")]
13841407
pub fn width(&self) -> Option<usize> { self.width }
13851408

1386-
/// Optionally specified precision for numeric types
1409+
/// Optionally specified precision for numeric types.
1410+
///
1411+
/// # Examples
1412+
///
1413+
/// ```
1414+
/// use std::fmt;
1415+
///
1416+
/// struct Foo(f32);
1417+
///
1418+
/// impl fmt::Display for Foo {
1419+
/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1420+
/// if let Some(precision) = formatter.precision() {
1421+
/// // If we received a precision, we use it.
1422+
/// write!(formatter, "Foo({1:.*})", precision, self.0)
1423+
/// } else {
1424+
/// // Otherwise we default to 2.
1425+
/// write!(formatter, "Foo({:.2})", self.0)
1426+
/// }
1427+
/// }
1428+
/// }
1429+
///
1430+
/// assert_eq!(&format!("{:.4}", Foo(23.2)), "Foo(23.2000)");
1431+
/// assert_eq!(&format!("{}", Foo(23.2)), "Foo(23.20)");
1432+
/// ```
13871433
#[stable(feature = "fmt_flags", since = "1.5.0")]
13881434
pub fn precision(&self) -> Option<usize> { self.precision }
13891435

13901436
/// Determines if the `+` flag was specified.
1437+
///
1438+
/// # Examples
1439+
///
1440+
/// ```
1441+
/// use std::fmt;
1442+
///
1443+
/// struct Foo(i32);
1444+
///
1445+
/// impl fmt::Display for Foo {
1446+
/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1447+
/// if formatter.sign_plus() {
1448+
/// write!(formatter,
1449+
/// "Foo({}{})",
1450+
/// if self.0 < 0 { '-' } else { '+' },
1451+
/// self.0)
1452+
/// } else {
1453+
/// write!(formatter, "Foo({})", self.0)
1454+
/// }
1455+
/// }
1456+
/// }
1457+
///
1458+
/// assert_eq!(&format!("{:+}", Foo(23)), "Foo(+23)");
1459+
/// assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
1460+
/// ```
13911461
#[stable(feature = "fmt_flags", since = "1.5.0")]
13921462
pub fn sign_plus(&self) -> bool { self.flags & (1 << FlagV1::SignPlus as u32) != 0 }
13931463

13941464
/// Determines if the `-` flag was specified.
1465+
///
1466+
/// # Examples
1467+
///
1468+
/// ```
1469+
/// use std::fmt;
1470+
///
1471+
/// struct Foo(i32);
1472+
///
1473+
/// impl fmt::Display for Foo {
1474+
/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1475+
/// if formatter.sign_minus() {
1476+
/// // You want a minus sign? Have one!
1477+
/// write!(formatter, "-Foo({})", self.0)
1478+
/// } else {
1479+
/// write!(formatter, "Foo({})", self.0)
1480+
/// }
1481+
/// }
1482+
/// }
1483+
///
1484+
/// assert_eq!(&format!("{:-}", Foo(23)), "-Foo(23)");
1485+
/// assert_eq!(&format!("{}", Foo(23)), "Foo(23)");
1486+
/// ```
13951487
#[stable(feature = "fmt_flags", since = "1.5.0")]
13961488
pub fn sign_minus(&self) -> bool { self.flags & (1 << FlagV1::SignMinus as u32) != 0 }
13971489

13981490
/// Determines if the `#` flag was specified.
1491+
///
1492+
/// # Examples
1493+
///
1494+
/// ```
1495+
/// use std::fmt;
1496+
///
1497+
/// struct Foo(i32);
1498+
///
1499+
/// impl fmt::Display for Foo {
1500+
/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1501+
/// if formatter.alternate() {
1502+
/// write!(formatter, "Foo({})", self.0)
1503+
/// } else {
1504+
/// write!(formatter, "{}", self.0)
1505+
/// }
1506+
/// }
1507+
/// }
1508+
///
1509+
/// assert_eq!(&format!("{:#}", Foo(23)), "Foo(23)");
1510+
/// assert_eq!(&format!("{}", Foo(23)), "23");
1511+
/// ```
13991512
#[stable(feature = "fmt_flags", since = "1.5.0")]
14001513
pub fn alternate(&self) -> bool { self.flags & (1 << FlagV1::Alternate as u32) != 0 }
14011514

14021515
/// Determines if the `0` flag was specified.
1516+
///
1517+
/// # Examples
1518+
///
1519+
/// ```
1520+
/// use std::fmt;
1521+
///
1522+
/// struct Foo(i32);
1523+
///
1524+
/// impl fmt::Display for Foo {
1525+
/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1526+
/// assert!(formatter.sign_aware_zero_pad());
1527+
/// assert_eq!(formatter.width(), Some(4));
1528+
/// // We ignore the formatter's options.
1529+
/// write!(formatter, "{}", self.0)
1530+
/// }
1531+
/// }
1532+
///
1533+
/// assert_eq!(&format!("{:04}", Foo(23)), "23");
1534+
/// ```
14031535
#[stable(feature = "fmt_flags", since = "1.5.0")]
14041536
pub fn sign_aware_zero_pad(&self) -> bool {
14051537
self.flags & (1 << FlagV1::SignAwareZeroPad as u32) != 0

src/librustc/hir/map/collector.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use dep_graph::{DepGraph, DepKind, DepNodeIndex};
1313
use hir::def_id::{LOCAL_CRATE, CrateNum};
1414
use hir::intravisit::{Visitor, NestedVisitorMap};
1515
use hir::svh::Svh;
16+
use ich::Fingerprint;
1617
use middle::cstore::CrateStore;
1718
use session::CrateDisambiguator;
1819
use std::iter::repeat;
@@ -121,21 +122,24 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
121122
collector
122123
}
123124

124-
pub(super) fn finalize_and_compute_crate_hash(self,
125+
pub(super) fn finalize_and_compute_crate_hash(mut self,
125126
crate_disambiguator: CrateDisambiguator,
126127
cstore: &dyn CrateStore,
127128
codemap: &CodeMap,
128129
commandline_args_hash: u64)
129130
-> (Vec<MapEntry<'hir>>, Svh) {
130-
let mut node_hashes: Vec<_> = self
131+
self
131132
.hir_body_nodes
132-
.iter()
133-
.map(|&(def_path_hash, dep_node_index)| {
134-
(def_path_hash, self.dep_graph.fingerprint_of(dep_node_index))
135-
})
136-
.collect();
133+
.sort_unstable_by(|&(ref d1, _), &(ref d2, _)| d1.cmp(d2));
137134

138-
node_hashes.sort_unstable_by(|&(ref d1, _), &(ref d2, _)| d1.cmp(d2));
135+
let node_hashes = self
136+
.hir_body_nodes
137+
.iter()
138+
.fold(Fingerprint::ZERO, |fingerprint , &(def_path_hash, dep_node_index)| {
139+
fingerprint.combine(
140+
def_path_hash.0.combine(self.dep_graph.fingerprint_of(dep_node_index))
141+
)
142+
});
139143

140144
let mut upstream_crates: Vec<_> = cstore.crates_untracked().iter().map(|&cnum| {
141145
let name = cstore.crate_name_untracked(cnum).as_str();

src/librustc/session/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
16411641
opt::multi_s(
16421642
"",
16431643
"remap-path-prefix",
1644-
"remap source names in output",
1644+
"Remap source names in all output (compiler messages and output files)",
16451645
"FROM=TO",
16461646
),
16471647
]);

src/librustc_back/target/mips_unknown_linux_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
2525
linker_flavor: LinkerFlavor::Gcc,
2626
options: TargetOptions {
2727
cpu: "mips32r2".to_string(),
28-
features: "+mips32r2".to_string(),
28+
features: "+mips32r2,+fpxx,+nooddspreg".to_string(),
2929
max_atomic_width: Some(32),
3030

3131
// see #36994

src/librustc_back/target/mipsel_unknown_linux_gnu.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pub fn target() -> TargetResult {
2525
linker_flavor: LinkerFlavor::Gcc,
2626

2727
options: TargetOptions {
28-
cpu: "mips32".to_string(),
29-
features: "+mips32".to_string(),
28+
cpu: "mips32r2".to_string(),
29+
features: "+mips32r2,+fpxx,+nooddspreg".to_string(),
3030
max_atomic_width: Some(32),
3131

3232
// see #36994

src/librustc_back/target/mipsel_unknown_linux_musl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use target::{Target, TargetResult};
1313

1414
pub fn target() -> TargetResult {
1515
let mut base = super::linux_musl_base::opts();
16-
base.cpu = "mips32".to_string();
17-
base.features = "+mips32,+soft-float".to_string();
16+
base.cpu = "mips32r2".to_string();
17+
base.features = "+mips32r2,+soft-float".to_string();
1818
base.max_atomic_width = Some(32);
1919
// see #36994
2020
base.exe_allocation_crate = None;

src/librustc_back/target/mipsel_unknown_linux_uclibc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pub fn target() -> TargetResult {
2525
linker_flavor: LinkerFlavor::Gcc,
2626

2727
options: TargetOptions {
28-
cpu: "mips32".to_string(),
29-
features: "+mips32,+soft-float".to_string(),
28+
cpu: "mips32r2".to_string(),
29+
features: "+mips32r2,+soft-float".to_string(),
3030
max_atomic_width: Some(32),
3131

3232
// see #36994

src/librustc_data_structures/indexed_set.rs

-64
Original file line numberDiff line numberDiff line change
@@ -224,70 +224,6 @@ impl<T: Idx> IdxSet<T> {
224224
_pd: PhantomData,
225225
}
226226
}
227-
228-
/// Calls `f` on each index value held in this set, up to the
229-
/// bound `max_bits` on the size of universe of indexes.
230-
pub fn each_bit<F>(&self, max_bits: usize, f: F) where F: FnMut(T) {
231-
each_bit(self, max_bits, f)
232-
}
233-
234-
/// Removes all elements from this set.
235-
pub fn reset_to_empty(&mut self) {
236-
for word in self.words_mut() { *word = 0; }
237-
}
238-
239-
pub fn elems(&self, universe_size: usize) -> Elems<T> {
240-
Elems { i: 0, set: self, universe_size: universe_size }
241-
}
242-
}
243-
244-
pub struct Elems<'a, T: Idx> { i: usize, set: &'a IdxSet<T>, universe_size: usize }
245-
246-
impl<'a, T: Idx> Iterator for Elems<'a, T> {
247-
type Item = T;
248-
fn next(&mut self) -> Option<T> {
249-
if self.i >= self.universe_size { return None; }
250-
let mut i = self.i;
251-
loop {
252-
if i >= self.universe_size {
253-
self.i = i; // (mark iteration as complete.)
254-
return None;
255-
}
256-
if self.set.contains(&T::new(i)) {
257-
self.i = i + 1; // (next element to start at.)
258-
return Some(T::new(i));
259-
}
260-
i = i + 1;
261-
}
262-
}
263-
}
264-
265-
fn each_bit<T: Idx, F>(words: &IdxSet<T>, max_bits: usize, mut f: F) where F: FnMut(T) {
266-
let usize_bits: usize = mem::size_of::<usize>() * 8;
267-
268-
for (word_index, &word) in words.words().iter().enumerate() {
269-
if word != 0 {
270-
let base_index = word_index * usize_bits;
271-
for offset in 0..usize_bits {
272-
let bit = 1 << offset;
273-
if (word & bit) != 0 {
274-
// NB: we round up the total number of bits
275-
// that we store in any given bit set so that
276-
// it is an even multiple of usize::BITS. This
277-
// means that there may be some stray bits at
278-
// the end that do not correspond to any
279-
// actual value; that's why we first check
280-
// that we are in range of bits_per_block.
281-
let bit_index = base_index + offset as usize;
282-
if bit_index >= max_bits {
283-
return;
284-
} else {
285-
f(Idx::new(bit_index));
286-
}
287-
}
288-
}
289-
}
290-
}
291227
}
292228

293229
pub struct Iter<'a, T: Idx> {

src/librustc_driver/lib.rs

+22
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,15 @@ fn usage(verbose: bool, include_unstable_options: bool) {
11471147
verbose_help);
11481148
}
11491149

1150+
fn print_wall_help() {
1151+
println!("
1152+
The flag `-Wall` does not exist in `rustc`. Most useful lints are enabled by
1153+
default. Use `rustc -W help` to see all available lints. It's more common to put
1154+
warning settings in the crate root using `#![warn(LINT_NAME)]` instead of using
1155+
the command line flag directly.
1156+
");
1157+
}
1158+
11501159
fn describe_lints(sess: &Session, lint_store: &lint::LintStore, loaded_plugins: bool) {
11511160
println!("
11521161
Available lint options:
@@ -1391,6 +1400,13 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
13911400
return None;
13921401
}
13931402

1403+
// Handle the special case of -Wall.
1404+
let wall = matches.opt_strs("W");
1405+
if wall.iter().any(|x| *x == "all") {
1406+
print_wall_help();
1407+
return None;
1408+
}
1409+
13941410
// Don't handle -W help here, because we might first load plugins.
13951411
let r = matches.opt_strs("Z");
13961412
if r.iter().any(|x| *x == "help") {
@@ -1468,6 +1484,12 @@ fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
14681484
args.push(arg.to_string_lossy().to_string());
14691485
}
14701486

1487+
// Avoid printing help because of empty args. This can suggest the compiler
1488+
// itself is not the program root (consider RLS).
1489+
if args.len() < 2 {
1490+
return None;
1491+
}
1492+
14711493
let matches = if let Some(matches) = handle_options(&args) {
14721494
matches
14731495
} else {

0 commit comments

Comments
 (0)