Skip to content

Commit

Permalink
Revert "Use implicit capture syntax in format_args"
Browse files Browse the repository at this point in the history
This reverts commit 72a25d0.
  • Loading branch information
Dylan-DPC committed Mar 17, 2022
1 parent 2184c7c commit 7a40b31
Show file tree
Hide file tree
Showing 177 changed files with 734 additions and 724 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,12 +1093,12 @@ impl HandlerInner {
let warnings = match self.deduplicated_warn_count {
0 => String::new(),
1 => "1 warning emitted".to_string(),
count => format!("{count} warnings emitted"),
count => format!("{} warnings emitted", count),
};
let errors = match self.deduplicated_err_count {
0 => String::new(),
1 => "aborting due to previous error".to_string(),
count => format!("aborting due to {count} previous errors"),
count => format!("aborting due to {} previous errors", count),
};
if self.treat_err_as_bug() {
return;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3400,7 +3400,7 @@ declare_lint! {
/// // ^^^^^^^^
/// // This call to try_into matches both Foo:try_into and TryInto::try_into as
/// // `TryInto` has been added to the Rust prelude in 2021 edition.
/// println!("{x}");
/// println!("{}", x);
/// }
/// ```
///
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ pub struct CaptureInfo {
/// let mut t = (0,1);
///
/// let c = || {
/// println!("{t}"); // L1
/// println!("{}",t); // L1
/// t.1 = 4; // L2
/// };
/// ```
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_typeck/src/check/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// let s: String; // hir_id_s
/// let mut p: Point; // his_id_p
/// let c = || {
/// println!("{s}"); // L1
/// println!("{}", s); // L1
/// p.x += 10; // L2
/// println!("{}" , p.y); // L3
/// println!("{p}"); // L4
/// println!("{}" , p.y) // L3
/// println!("{}", p) // L4
/// drop(s); // L5
/// };
/// ```
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ pub mod __alloc_error_handler {
// if there is no `#[alloc_error_handler]`
#[rustc_std_internal_symbol]
pub unsafe extern "C-unwind" fn __rdl_oom(size: usize, _align: usize) -> ! {
panic!("memory allocation of {size} bytes failed")
panic!("memory allocation of {} bytes failed", size)
}

// if there is an `#[alloc_error_handler]`
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ where
/// let readonly = [1, 2];
/// let borrowed = Items::new((&readonly[..]).into());
/// match borrowed {
/// Items { values: Cow::Borrowed(b) } => println!("borrowed {b:?}"),
/// Items { values: Cow::Borrowed(b) } => println!("borrowed {:?}", b),
/// _ => panic!("expect borrowed value"),
/// }
///
Expand Down
12 changes: 6 additions & 6 deletions library/alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
//! }
//!
//! let list: List<i32> = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Nil))));
//! println!("{list:?}");
//! println!("{:?}", list);
//! ```
//!
//! This will print `Cons(1, Cons(2, Nil))`.
Expand Down Expand Up @@ -1407,7 +1407,7 @@ impl<T: Copy> From<&[T]> for Box<[T]> {
/// let slice: &[u8] = &[104, 101, 108, 108, 111];
/// let boxed_slice: Box<[u8]> = Box::from(slice);
///
/// println!("{boxed_slice:?}");
/// println!("{:?}", boxed_slice);
/// ```
fn from(slice: &[T]) -> Box<[T]> {
let len = slice.len();
Expand Down Expand Up @@ -1449,7 +1449,7 @@ impl From<&str> for Box<str> {
///
/// ```rust
/// let boxed: Box<str> = Box::from("hello");
/// println!("{boxed}");
/// println!("{}", boxed);
/// ```
#[inline]
fn from(s: &str) -> Box<str> {
Expand All @@ -1474,14 +1474,14 @@ impl From<Cow<'_, str>> for Box<str> {
///
/// let unboxed = Cow::Borrowed("hello");
/// let boxed: Box<str> = Box::from(unboxed);
/// println!("{boxed}");
/// println!("{}", boxed);
/// ```
///
/// ```rust
/// # use std::borrow::Cow;
/// let unboxed = Cow::Owned("hello".to_string());
/// let boxed: Box<str> = Box::from(unboxed);
/// println!("{boxed}");
/// println!("{}", boxed);
/// ```
#[inline]
fn from(cow: Cow<'_, str>) -> Box<str> {
Expand Down Expand Up @@ -1528,7 +1528,7 @@ impl<T, const N: usize> From<[T; N]> for Box<[T]> {
///
/// ```rust
/// let boxed: Box<[u8]> = Box::from([4, 2]);
/// println!("{boxed:?}");
/// println!("{:?}", boxed);
/// ```
fn from(array: [T; N]) -> Box<[T]> {
box array
Expand Down
10 changes: 5 additions & 5 deletions library/alloc/src/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ use super::SpecExtend;
/// // We can iterate over the items in the heap, although they are returned in
/// // a random order.
/// for x in &heap {
/// println!("{x}");
/// println!("{}", x);
/// }
///
/// // If we instead pop these scores, they should come back in order.
Expand Down Expand Up @@ -830,7 +830,7 @@ impl<T> BinaryHeap<T> {
///
/// // Print 1, 2, 3, 4 in arbitrary order
/// for x in heap.iter() {
/// println!("{x}");
/// println!("{}", x);
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1110,7 +1110,7 @@ impl<T> BinaryHeap<T> {
///
/// // Will print in some order
/// for x in vec {
/// println!("{x}");
/// println!("{}", x);
/// }
/// ```
#[must_use = "`self` will be dropped if the result is not used"]
Expand Down Expand Up @@ -1179,7 +1179,7 @@ impl<T> BinaryHeap<T> {
/// assert!(!heap.is_empty());
///
/// for x in heap.drain() {
/// println!("{x}");
/// println!("{}", x);
/// }
///
/// assert!(heap.is_empty());
Expand Down Expand Up @@ -1624,7 +1624,7 @@ impl<T> IntoIterator for BinaryHeap<T> {
/// // Print 1, 2, 3, 4 in arbitrary order
/// for x in heap.into_iter() {
/// // x has type i32, not &i32
/// println!("{x}");
/// println!("{}", x);
/// }
/// ```
fn into_iter(self) -> IntoIter<T> {
Expand Down
12 changes: 6 additions & 6 deletions library/alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT;
/// let to_find = ["Up!", "Office Space"];
/// for movie in &to_find {
/// match movie_reviews.get(movie) {
/// Some(review) => println!("{movie}: {review}"),
/// None => println!("{movie} is unreviewed.")
/// Some(review) => println!("{}: {}", movie, review),
/// None => println!("{} is unreviewed.", movie)
/// }
/// }
///
Expand All @@ -114,7 +114,7 @@ pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT;
///
/// // iterate over everything.
/// for (movie, review) in &movie_reviews {
/// println!("{movie}: \"{review}\"");
/// println!("{}: \"{}\"", movie, review);
/// }
/// ```
///
Expand Down Expand Up @@ -1061,7 +1061,7 @@ impl<K, V> BTreeMap<K, V> {
/// map.insert(5, "b");
/// map.insert(8, "c");
/// for (&key, &value) in map.range((Included(&4), Included(&8))) {
/// println!("{key}: {value}");
/// println!("{}: {}", key, value);
/// }
/// assert_eq!(Some((&5, &"b")), map.range(4..).next());
/// ```
Expand Down Expand Up @@ -1104,7 +1104,7 @@ impl<K, V> BTreeMap<K, V> {
/// *balance += 100;
/// }
/// for (name, balance) in &map {
/// println!("{name} => {balance}");
/// println!("{} => {}", name, balance);
/// }
/// ```
#[stable(feature = "btree_range", since = "1.17.0")]
Expand Down Expand Up @@ -2088,7 +2088,7 @@ impl<K, V> BTreeMap<K, V> {
/// map.insert(1, "a");
///
/// for (key, value) in map.iter() {
/// println!("{key}: {value}");
/// println!("{}: {}", key, value);
/// }
///
/// let (first_key, first_value) = map.iter().next().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/collections/btree/map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,7 @@ fn test_ord_absence() {
}

fn map_debug<K: Debug>(mut map: BTreeMap<K, ()>) {
format!("{map:?}");
format!("{:?}", map);
format!("{:?}", map.iter());
format!("{:?}", map.iter_mut());
format!("{:?}", map.keys());
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ use super::Recover;
///
/// // Iterate over everything.
/// for book in &books {
/// println!("{book}");
/// println!("{}", book);
/// }
/// ```
///
Expand Down Expand Up @@ -284,7 +284,7 @@ impl<T> BTreeSet<T> {
/// set.insert(5);
/// set.insert(8);
/// for &elem in set.range((Included(&4), Included(&8))) {
/// println!("{elem}");
/// println!("{}", elem);
/// }
/// assert_eq!(Some(&5), set.range(4..).next());
/// ```
Expand Down
6 changes: 3 additions & 3 deletions library/alloc/src/collections/btree/set/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,10 @@ fn test_show() {
set.insert(1);
set.insert(2);

let set_str = format!("{set:?}");
let set_str = format!("{:?}", set);

assert_eq!(set_str, "{1, 2}");
assert_eq!(format!("{empty:?}"), "{}");
assert_eq!(format!("{:?}", empty), "{}");
}

#[test]
Expand Down Expand Up @@ -649,7 +649,7 @@ fn test_ord_absence() {
}

fn set_debug<K: Debug>(set: BTreeSet<K>) {
format!("{set:?}");
format!("{:?}", set);
format!("{:?}", set.iter());
format!("{:?}", set.into_iter());
}
Expand Down
6 changes: 3 additions & 3 deletions library/alloc/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,9 @@
//! fn main() {
//! let myvector = Vector2D { x: 3, y: 4 };
//!
//! println!("{myvector}"); // => "(3, 4)"
//! println!("{myvector:?}"); // => "Vector2D {x: 3, y:4}"
//! println!("{myvector:10.3b}"); // => " 5.000"
//! println!("{}", myvector); // => "(3, 4)"
//! println!("{:?}", myvector); // => "Vector2D {x: 3, y:4}"
//! println!("{:10.3b}", myvector); // => " 5.000"
//! }
//! ```
//!
Expand Down
6 changes: 3 additions & 3 deletions library/alloc/src/rc/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ fn test_cowrc_clone_weak() {
#[test]
fn test_show() {
let foo = Rc::new(75);
assert_eq!(format!("{foo:?}"), "75");
assert_eq!(format!("{:?}", foo), "75");
}

#[test]
Expand All @@ -324,7 +324,7 @@ fn test_maybe_thin_unsized() {
use std::ffi::{CStr, CString};

let x: Rc<CStr> = Rc::from(CString::new("swordfish").unwrap().into_boxed_c_str());
assert_eq!(format!("{x:?}"), "\"swordfish\"");
assert_eq!(format!("{:?}", x), "\"swordfish\"");
let y: Weak<CStr> = Rc::downgrade(&x);
drop(x);

Expand Down Expand Up @@ -451,7 +451,7 @@ fn test_from_box_trait_zero_sized() {
let b: Box<dyn Debug> = box ();
let r: Rc<dyn Debug> = Rc::from(b);

assert_eq!(format!("{r:?}"), "()");
assert_eq!(format!("{:?}", r), "()");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
//! ```
//! let numbers = &[0, 1, 2];
//! for n in numbers {
//! println!("{n} is a number!");
//! println!("{} is a number!", n);
//! }
//! ```
//!
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2718,7 +2718,7 @@ impl From<String> for Vec<u8> {
/// let v1 = Vec::from(s1);
///
/// for b in v1 {
/// println!("{b}");
/// println!("{}", b);
/// }
/// ```
fn from(string: String) -> Vec<u8> {
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ macro_rules! acquire {
/// let five = Arc::clone(&five);
///
/// thread::spawn(move || {
/// println!("{five:?}");
/// println!("{:?}", five);
/// });
/// }
/// ```
Expand All @@ -221,7 +221,7 @@ macro_rules! acquire {
///
/// thread::spawn(move || {
/// let v = val.fetch_add(1, Ordering::SeqCst);
/// println!("{v:?}");
/// println!("{:?}", v);
/// });
/// }
/// ```
Expand Down
8 changes: 4 additions & 4 deletions library/alloc/src/sync/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ fn test_weak_count() {
#[test]
fn show_arc() {
let a = Arc::new(5);
assert_eq!(format!("{a:?}"), "5");
assert_eq!(format!("{:?}", a), "5");
}

// Make sure deriving works with Arc<T>
Expand All @@ -347,7 +347,7 @@ struct Foo {
#[test]
fn test_unsized() {
let x: Arc<[i32]> = Arc::new([1, 2, 3]);
assert_eq!(format!("{x:?}"), "[1, 2, 3]");
assert_eq!(format!("{:?}", x), "[1, 2, 3]");
let y = Arc::downgrade(&x.clone());
drop(x);
assert!(y.upgrade().is_none());
Expand All @@ -359,7 +359,7 @@ fn test_maybe_thin_unsized() {
use std::ffi::{CStr, CString};

let x: Arc<CStr> = Arc::from(CString::new("swordfish").unwrap().into_boxed_c_str());
assert_eq!(format!("{x:?}"), "\"swordfish\"");
assert_eq!(format!("{:?}", x), "\"swordfish\"");
let y: Weak<CStr> = Arc::downgrade(&x);
drop(x);

Expand Down Expand Up @@ -509,7 +509,7 @@ fn test_from_box_trait_zero_sized() {
let b: Box<dyn Debug> = box ();
let r: Arc<dyn Debug> = Arc::from(b);

assert_eq!(format!("{r:?}"), "()");
assert_eq!(format!("{:?}", r), "()");
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions library/alloc/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ fn any_move() {
fn test_show() {
let a = Box::new(8) as Box<dyn Any>;
let b = Box::new(Test) as Box<dyn Any>;
let a_str = format!("{a:?}");
let b_str = format!("{b:?}");
let a_str = format!("{:?}", a);
let b_str = format!("{:?}", b);
assert_eq!(a_str, "Any { .. }");
assert_eq!(b_str, "Any { .. }");

static EIGHT: usize = 8;
static TEST: Test = Test;
let a = &EIGHT as &dyn Any;
let b = &TEST as &dyn Any;
let s = format!("{a:?}");
let s = format!("{:?}", a);
assert_eq!(s, "Any { .. }");
let s = format!("{b:?}");
let s = format!("{:?}", b);
assert_eq!(s, "Any { .. }");
}

Expand Down
Loading

0 comments on commit 7a40b31

Please sign in to comment.