Skip to content

Commit

Permalink
Auto merge of rust-lang#2753 - RalfJung:rustup, r=RalfJung
Browse files Browse the repository at this point in the history
Rustup

Pulls in rust-lang#104658
  • Loading branch information
bors committed Jan 9, 2023
2 parents 87a202e + 236ae26 commit d61d359
Show file tree
Hide file tree
Showing 807 changed files with 11,180 additions and 6,270 deletions.
539 changes: 434 additions & 105 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"library/std",
"library/test",
"src/rustdoc-json-types",
"src/tools/build_helper",
"src/tools/cargotest",
"src/tools/clippy",
"src/tools/clippy/clippy_dev",
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2170,10 +2170,10 @@ impl fmt::Display for InlineAsmTemplatePiece {
Ok(())
}
Self::Placeholder { operand_idx, modifier: Some(modifier), .. } => {
write!(f, "{{{}:{}}}", operand_idx, modifier)
write!(f, "{{{operand_idx}:{modifier}}}")
}
Self::Placeholder { operand_idx, modifier: None, .. } => {
write!(f, "{{{}}}", operand_idx)
write!(f, "{{{operand_idx}}}")
}
}
}
Expand All @@ -2185,7 +2185,7 @@ impl InlineAsmTemplatePiece {
use fmt::Write;
let mut out = String::new();
for p in s.iter() {
let _ = write!(out, "{}", p);
let _ = write!(out, "{p}");
}
out
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast/src/ast_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ impl HasTokens for Attribute {
match &self.kind {
AttrKind::Normal(normal) => normal.tokens.as_ref(),
kind @ AttrKind::DocComment(..) => {
panic!("Called tokens on doc comment attr {:?}", kind)
panic!("Called tokens on doc comment attr {kind:?}")
}
}
}
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
Some(match &mut self.kind {
AttrKind::Normal(normal) => &mut normal.tokens,
kind @ AttrKind::DocComment(..) => {
panic!("Called tokens_mut on doc comment attr {:?}", kind)
panic!("Called tokens_mut on doc comment attr {kind:?}")
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl Attribute {
AttrKind::Normal(normal) => normal
.tokens
.as_ref()
.unwrap_or_else(|| panic!("attribute is missing tokens: {:?}", self))
.unwrap_or_else(|| panic!("attribute is missing tokens: {self:?}"))
.to_attr_token_stream()
.to_tokenstream(),
&AttrKind::DocComment(comment_kind, data) => TokenStream::new(vec![TokenTree::Token(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast/src/expand/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub enum AllocatorKind {
impl AllocatorKind {
pub fn fn_name(&self, base: Symbol) -> String {
match *self {
AllocatorKind::Global => format!("__rg_{}", base),
AllocatorKind::Default => format!("__rdl_{}", base),
AllocatorKind::Global => format!("__rg_{base}"),
AllocatorKind::Default => format!("__rdl_{base}"),
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,27 @@ impl fmt::Display for Lit {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let Lit { kind, symbol, suffix } = *self;
match kind {
Byte => write!(f, "b'{}'", symbol)?,
Char => write!(f, "'{}'", symbol)?,
Str => write!(f, "\"{}\"", symbol)?,
Byte => write!(f, "b'{symbol}'")?,
Char => write!(f, "'{symbol}'")?,
Str => write!(f, "\"{symbol}\"")?,
StrRaw(n) => write!(
f,
"r{delim}\"{string}\"{delim}",
delim = "#".repeat(n as usize),
string = symbol
)?,
ByteStr => write!(f, "b\"{}\"", symbol)?,
ByteStr => write!(f, "b\"{symbol}\"")?,
ByteStrRaw(n) => write!(
f,
"br{delim}\"{string}\"{delim}",
delim = "#".repeat(n as usize),
string = symbol
)?,
Integer | Float | Bool | Err => write!(f, "{}", symbol)?,
Integer | Float | Bool | Err => write!(f, "{symbol}")?,
}

if let Some(suffix) = suffix {
write!(f, "{}", suffix)?;
write!(f, "{suffix}")?;
}

Ok(())
Expand Down Expand Up @@ -756,7 +756,7 @@ impl Token {
_ => return None,
},
SingleQuote => match joint.kind {
Ident(name, false) => Lifetime(Symbol::intern(&format!("'{}", name))),
Ident(name, false) => Lifetime(Symbol::intern(&format!("'{name}"))),
_ => return None,
},

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ impl AttrTokenStream {

assert!(
found,
"Failed to find trailing delimited group in: {:?}",
target_tokens
"Failed to find trailing delimited group in: {target_tokens:?}"
);
}
let mut flat: SmallVec<[_; 1]> = SmallVec::new();
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_ast/src/util/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub enum LitError {
InvalidIntSuffix,
InvalidFloatSuffix,
NonDecimalFloat(u32),
IntTooLarge,
IntTooLarge(u32),
}

impl LitKind {
Expand Down Expand Up @@ -168,7 +168,7 @@ impl fmt::Display for LitKind {
match *self {
LitKind::Byte(b) => {
let b: String = ascii::escape_default(b).map(Into::<char>::into).collect();
write!(f, "b'{}'", b)?;
write!(f, "b'{b}'")?;
}
LitKind::Char(ch) => write!(f, "'{}'", escape_char_symbol(ch))?,
LitKind::Str(sym, StrStyle::Cooked) => write!(f, "\"{}\"", escape_string_symbol(sym))?,
Expand All @@ -192,15 +192,15 @@ impl fmt::Display for LitKind {
)?;
}
LitKind::Int(n, ty) => {
write!(f, "{}", n)?;
write!(f, "{n}")?;
match ty {
ast::LitIntType::Unsigned(ty) => write!(f, "{}", ty.name())?,
ast::LitIntType::Signed(ty) => write!(f, "{}", ty.name())?,
ast::LitIntType::Unsuffixed => {}
}
}
LitKind::Float(symbol, ty) => {
write!(f, "{}", symbol)?;
write!(f, "{symbol}")?;
match ty {
ast::LitFloatType::Suffixed(ty) => write!(f, "{}", ty.name())?,
ast::LitFloatType::Unsuffixed => {}
Expand Down Expand Up @@ -333,6 +333,6 @@ fn integer_lit(symbol: Symbol, suffix: Option<Symbol>) -> Result<LitKind, LitErr
// but these kinds of errors are already reported by the lexer.
let from_lexer =
base < 10 && s.chars().any(|c| c.to_digit(10).map_or(false, |d| d >= base));
if from_lexer { LitError::LexerError } else { LitError::IntTooLarge }
if from_lexer { LitError::LexerError } else { LitError::IntTooLarge(base) }
})
}
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
Err(supported_abis) => {
let mut abis = format!("`{}`", supported_abis[0]);
for m in &supported_abis[1..] {
let _ = write!(abis, ", `{}`", m);
let _ = write!(abis, ", `{m}`");
}
self.tcx.sess.emit_err(InvalidAbiClobberAbi {
abi_span: *abi_span,
Expand Down Expand Up @@ -262,7 +262,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let sub = if !valid_modifiers.is_empty() {
let mut mods = format!("`{}`", valid_modifiers[0]);
for m in &valid_modifiers[1..] {
let _ = write!(mods, ", `{}`", m);
let _ = write!(mods, ", `{m}`");
}
InvalidAsmTemplateModifierRegClassSub::SupportModifier {
class_name: class.name(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
_ => {
// Replace the ident for bindings that aren't simple.
let name = format!("__arg{}", index);
let name = format!("__arg{index}");
let ident = Ident::from_str(&name);

(ident, false)
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl std::fmt::Display for ImplTraitPosition {
ImplTraitPosition::ImplReturn => "`impl` method return",
};

write!(f, "{}", name)
write!(f, "{name}")
}
}

Expand Down Expand Up @@ -503,7 +503,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {

fn orig_local_def_id(&self, node: NodeId) -> LocalDefId {
self.orig_opt_local_def_id(node)
.unwrap_or_else(|| panic!("no entry for node id: `{:?}`", node))
.unwrap_or_else(|| panic!("no entry for node id: `{node:?}`"))
}

/// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
Expand All @@ -524,7 +524,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}

fn local_def_id(&self, node: NodeId) -> LocalDefId {
self.opt_local_def_id(node).unwrap_or_else(|| panic!("no entry for node id: `{:?}`", node))
self.opt_local_def_id(node).unwrap_or_else(|| panic!("no entry for node id: `{node:?}`"))
}

/// Get the previously recorded `to` local def id given the `from` local def id, obtained using
Expand Down Expand Up @@ -2197,7 +2197,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
fn lower_trait_ref(&mut self, p: &TraitRef, itctx: &ImplTraitContext) -> hir::TraitRef<'hir> {
let path = match self.lower_qpath(p.ref_id, &None, &p.path, ParamMode::Explicit, itctx) {
hir::QPath::Resolved(None, path) => path,
qpath => panic!("lower_trait_ref: unexpected QPath `{:?}`", qpath),
qpath => panic!("lower_trait_ref: unexpected QPath `{qpath:?}`"),
};
hir::TraitRef { path, hir_ref_id: self.lower_node_id(p.ref_id) }
}
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,23 +191,23 @@ fn doc_comment_to_string(
data: Symbol,
) -> String {
match (comment_kind, attr_style) {
(CommentKind::Line, ast::AttrStyle::Outer) => format!("///{}", data),
(CommentKind::Line, ast::AttrStyle::Inner) => format!("//!{}", data),
(CommentKind::Block, ast::AttrStyle::Outer) => format!("/**{}*/", data),
(CommentKind::Block, ast::AttrStyle::Inner) => format!("/*!{}*/", data),
(CommentKind::Line, ast::AttrStyle::Outer) => format!("///{data}"),
(CommentKind::Line, ast::AttrStyle::Inner) => format!("//!{data}"),
(CommentKind::Block, ast::AttrStyle::Outer) => format!("/**{data}*/"),
(CommentKind::Block, ast::AttrStyle::Inner) => format!("/*!{data}*/"),
}
}

pub fn literal_to_string(lit: token::Lit) -> String {
let token::Lit { kind, symbol, suffix } = lit;
let mut out = match kind {
token::Byte => format!("b'{}'", symbol),
token::Char => format!("'{}'", symbol),
token::Str => format!("\"{}\"", symbol),
token::Byte => format!("b'{symbol}'"),
token::Char => format!("'{symbol}'"),
token::Str => format!("\"{symbol}\""),
token::StrRaw(n) => {
format!("r{delim}\"{string}\"{delim}", delim = "#".repeat(n as usize), string = symbol)
}
token::ByteStr => format!("b\"{}\"", symbol),
token::ByteStr => format!("b\"{symbol}\""),
token::ByteStrRaw(n) => {
format!("br{delim}\"{string}\"{delim}", delim = "#".repeat(n as usize), string = symbol)
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_pretty/src/pprust/state/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,9 @@ impl<'a> State<'a> {
ast::VisibilityKind::Restricted { path, shorthand, .. } => {
let path = Self::to_string(|s| s.print_path(path, false, 0));
if *shorthand && (path == "crate" || path == "self" || path == "super") {
self.word_nbsp(format!("pub({})", path))
self.word_nbsp(format!("pub({path})"))
} else {
self.word_nbsp(format!("pub(in {})", path))
self.word_nbsp(format!("pub(in {path})"))
}
}
ast::VisibilityKind::Inherited => {}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ fn try_gate_cfg(name: Symbol, span: Span, sess: &ParseSess, features: Option<&Fe
fn gate_cfg(gated_cfg: &GatedCfg, cfg_span: Span, sess: &ParseSess, features: &Features) {
let (cfg, feature, has_feature) = gated_cfg;
if !has_feature(features) && !cfg_span.allows_unstable(*feature) {
let explain = format!("`cfg({})` is experimental and subject to change", cfg);
let explain = format!("`cfg({cfg})` is experimental and subject to change");
feature_err(sess, *feature, cfg_span, &explain).emit();
}
}
Expand Down Expand Up @@ -975,7 +975,7 @@ pub fn find_repr_attrs(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
}

pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
assert!(attr.has_name(sym::repr), "expected `#[repr(..)]`, found: {:?}", attr);
assert!(attr.has_name(sym::repr), "expected `#[repr(..)]`, found: {attr:?}");
use ReprAttr::*;
let mut acc = Vec::new();
let diagnostic = &sess.parse_sess.span_diagnostic;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub(crate) struct UnknownMetaItem<'a> {
// Manual implementation to be able to format `expected` items correctly.
impl<'a> IntoDiagnostic<'a> for UnknownMetaItem<'_> {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let expected = self.expected.iter().map(|name| format!("`{}`", name)).collect::<Vec<_>>();
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
let mut diag = handler.struct_span_err_with_code(
self.span,
fluent::attr_unknown_meta_item,
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_borrowck/src/borrowck_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,14 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
closure_kind: &str,
borrowed_path: &str,
capture_span: Span,
scope: &str,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = struct_span_err!(
self,
closure_span,
E0373,
"{} may outlive the current function, but it borrows {}, which is owned by the current \
function",
closure_kind,
borrowed_path,
"{closure_kind} may outlive the current {scope}, but it borrows {borrowed_path}, \
which is owned by the current {scope}",
);
err.span_label(capture_span, format!("{} is borrowed here", borrowed_path))
.span_label(closure_span, format!("may outlive borrowed value {}", borrowed_path));
Expand Down
Loading

0 comments on commit d61d359

Please sign in to comment.