Skip to content

Commit d8bdb3f

Browse files
committed
Auto merge of #66887 - dtolnay:rollup-uxowp8d, r=Centril
Rollup of 4 pull requests Successful merges: - #66818 (Format libstd/os with rustfmt) - #66819 (Format libstd/sys with rustfmt) - #66820 (Format libstd with rustfmt) - #66847 (Allow any identifier as format arg name) Failed merges: r? @ghost
2 parents 8f1bbd6 + b14d9c2 commit d8bdb3f

File tree

242 files changed

+6132
-5416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+6132
-5416
lines changed

src/libfmt_macros/lib.rs

+17-16
Original file line numberDiff line numberDiff line change
@@ -442,20 +442,9 @@ impl<'a> Parser<'a> {
442442
Some(ArgumentIs(i))
443443
} else {
444444
match self.cur.peek() {
445-
Some(&(_, c)) if c.is_alphabetic() => {
445+
Some(&(_, c)) if rustc_lexer::is_id_start(c) => {
446446
Some(ArgumentNamed(Symbol::intern(self.word())))
447447
}
448-
Some(&(pos, c)) if c == '_' => {
449-
let invalid_name = self.string(pos);
450-
self.err_with_note(format!("invalid argument name `{}`", invalid_name),
451-
"invalid argument name",
452-
"argument names cannot start with an underscore",
453-
self.to_span_index(pos).to(
454-
self.to_span_index(pos + invalid_name.len())
455-
),
456-
);
457-
Some(ArgumentNamed(Symbol::intern(invalid_name)))
458-
},
459448

460449
// This is an `ArgumentNext`.
461450
// Record the fact and do the resolution after parsing the
@@ -611,22 +600,34 @@ impl<'a> Parser<'a> {
611600
/// Rust identifier, except that it can't start with `_` character.
612601
fn word(&mut self) -> &'a str {
613602
let start = match self.cur.peek() {
614-
Some(&(pos, c)) if c != '_' && rustc_lexer::is_id_start(c) => {
603+
Some(&(pos, c)) if rustc_lexer::is_id_start(c) => {
615604
self.cur.next();
616605
pos
617606
}
618607
_ => {
619-
return &self.input[..0];
608+
return "";
620609
}
621610
};
611+
let mut end = None;
622612
while let Some(&(pos, c)) = self.cur.peek() {
623613
if rustc_lexer::is_id_continue(c) {
624614
self.cur.next();
625615
} else {
626-
return &self.input[start..pos];
616+
end = Some(pos);
617+
break;
627618
}
628619
}
629-
&self.input[start..self.input.len()]
620+
let end = end.unwrap_or(self.input.len());
621+
let word = &self.input[start..end];
622+
if word == "_" {
623+
self.err_with_note(
624+
"invalid argument name `_`",
625+
"invalid argument name",
626+
"argument name cannot be a single underscore",
627+
self.to_span_index(start).to(self.to_span_index(end)),
628+
);
629+
}
630+
word
630631
}
631632

632633
/// Optionally parses an integer at the current position. This doesn't deal

src/libstd/ascii.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#![stable(feature = "rust1", since = "1.0.0")]
1818

1919
#[stable(feature = "rust1", since = "1.0.0")]
20-
pub use core::ascii::{EscapeDefault, escape_default};
20+
pub use core::ascii::{escape_default, EscapeDefault};
2121

2222
/// Extension methods for ASCII-subset only operations.
2323
///

src/libstd/backtrace.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ use crate::env;
9595
use crate::fmt;
9696
use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst};
9797
use crate::sync::Mutex;
98-
use crate::sys_common::backtrace::{output_filename, lock};
98+
use crate::sys_common::backtrace::{lock, output_filename};
9999
use crate::vec::Vec;
100-
use backtrace_rs as backtrace;
101100
use backtrace::BytesOrWideString;
101+
use backtrace_rs as backtrace;
102102

103103
/// A captured OS thread stack backtrace.
104104
///

src/libstd/benches/hash/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![cfg(test)]
22

3-
use test::Bencher;
43
use std::collections::HashMap;
4+
use test::Bencher;
55

66
#[bench]
77
fn new_drop(b: &mut Bencher) {

src/libstd/collections/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -413,20 +413,20 @@
413413
#[doc(hidden)]
414414
pub use crate::ops::Bound;
415415
#[stable(feature = "rust1", since = "1.0.0")]
416-
pub use alloc_crate::collections::{BinaryHeap, BTreeMap, BTreeSet};
417-
#[stable(feature = "rust1", since = "1.0.0")]
418-
pub use alloc_crate::collections::{LinkedList, VecDeque};
419-
#[stable(feature = "rust1", since = "1.0.0")]
420416
pub use alloc_crate::collections::{binary_heap, btree_map, btree_set};
421417
#[stable(feature = "rust1", since = "1.0.0")]
422418
pub use alloc_crate::collections::{linked_list, vec_deque};
419+
#[stable(feature = "rust1", since = "1.0.0")]
420+
pub use alloc_crate::collections::{BTreeMap, BTreeSet, BinaryHeap};
421+
#[stable(feature = "rust1", since = "1.0.0")]
422+
pub use alloc_crate::collections::{LinkedList, VecDeque};
423423

424424
#[stable(feature = "rust1", since = "1.0.0")]
425425
pub use self::hash_map::HashMap;
426426
#[stable(feature = "rust1", since = "1.0.0")]
427427
pub use self::hash_set::HashSet;
428428

429-
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
429+
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
430430
pub use alloc_crate::collections::TryReserveError;
431431

432432
mod hash;

0 commit comments

Comments
 (0)