Skip to content

Commit 907b87f

Browse files
committed
rustc_resolve: Use #![feature(format_args_capture)]
1 parent b2d115f commit 907b87f

File tree

3 files changed

+13
-38
lines changed

3 files changed

+13
-38
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+11-37
Original file line numberDiff line numberDiff line change
@@ -1021,17 +1021,11 @@ impl<'a> Resolver<'a> {
10211021
("", "")
10221022
};
10231023

1024-
let article = if built_in.is_empty() { res.article() } else { "a" };
1025-
format!(
1026-
"{a}{built_in} {thing}{from}",
1027-
a = article,
1028-
thing = res.descr(),
1029-
built_in = built_in,
1030-
from = from
1031-
)
1024+
let a = if built_in.is_empty() { res.article() } else { "a" };
1025+
format!("{a}{built_in} {thing}{from}", thing = res.descr())
10321026
} else {
10331027
let introduced = if b.is_import() { "imported" } else { "defined" };
1034-
format!("the {thing} {introduced} here", thing = res.descr(), introduced = introduced)
1028+
format!("the {thing} {introduced} here", thing = res.descr())
10351029
}
10361030
}
10371031

@@ -1049,19 +1043,13 @@ impl<'a> Resolver<'a> {
10491043
ident.span,
10501044
E0659,
10511045
"`{ident}` is ambiguous ({why})",
1052-
ident = ident,
10531046
why = kind.descr()
10541047
);
10551048
err.span_label(ident.span, "ambiguous name");
10561049

10571050
let mut could_refer_to = |b: &NameBinding<'_>, misc: AmbiguityErrorMisc, also: &str| {
10581051
let what = self.binding_description(b, ident, misc == AmbiguityErrorMisc::FromPrelude);
1059-
let note_msg = format!(
1060-
"`{ident}` could{also} refer to {what}",
1061-
ident = ident,
1062-
also = also,
1063-
what = what
1064-
);
1052+
let note_msg = format!("`{ident}` could{also} refer to {what}");
10651053

10661054
let thing = b.res().descr();
10671055
let mut help_msgs = Vec::new();
@@ -1071,30 +1059,18 @@ impl<'a> Resolver<'a> {
10711059
|| kind == AmbiguityKind::GlobVsOuter && swapped != also.is_empty())
10721060
{
10731061
help_msgs.push(format!(
1074-
"consider adding an explicit import of \
1075-
`{ident}` to disambiguate",
1076-
ident = ident
1062+
"consider adding an explicit import of `{ident}` to disambiguate"
10771063
))
10781064
}
10791065
if b.is_extern_crate() && ident.span.rust_2018() {
1080-
help_msgs.push(format!(
1081-
"use `::{ident}` to refer to this {thing} unambiguously",
1082-
ident = ident,
1083-
thing = thing,
1084-
))
1066+
help_msgs.push(format!("use `::{ident}` to refer to this {thing} unambiguously"))
10851067
}
10861068
if misc == AmbiguityErrorMisc::SuggestCrate {
1087-
help_msgs.push(format!(
1088-
"use `crate::{ident}` to refer to this {thing} unambiguously",
1089-
ident = ident,
1090-
thing = thing,
1091-
))
1069+
help_msgs
1070+
.push(format!("use `crate::{ident}` to refer to this {thing} unambiguously"))
10921071
} else if misc == AmbiguityErrorMisc::SuggestSelf {
1093-
help_msgs.push(format!(
1094-
"use `self::{ident}` to refer to this {thing} unambiguously",
1095-
ident = ident,
1096-
thing = thing,
1097-
))
1072+
help_msgs
1073+
.push(format!("use `self::{ident}` to refer to this {thing} unambiguously"))
10981074
}
10991075

11001076
err.span_note(b.span, &note_msg);
@@ -1167,12 +1143,10 @@ impl<'a> Resolver<'a> {
11671143
};
11681144

11691145
let first = ptr::eq(binding, first_binding);
1170-
let descr = get_descr(binding);
11711146
let msg = format!(
11721147
"{and_refers_to}the {item} `{name}`{which} is defined here{dots}",
11731148
and_refers_to = if first { "" } else { "...and refers to " },
1174-
item = descr,
1175-
name = name,
1149+
item = get_descr(binding),
11761150
which = if first { "" } else { " which" },
11771151
dots = if next_binding.is_some() { "..." } else { "" },
11781152
);

compiler/rustc_resolve/src/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
865865
err.span_suggestion(
866866
span,
867867
&format!("use struct {} syntax instead", descr),
868-
format!("{} {{{pad}{}{pad}}}", path_str, fields, pad = pad),
868+
format!("{path_str} {{{pad}{fields}{pad}}}"),
869869
applicability,
870870
);
871871
}

compiler/rustc_resolve/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1212
#![feature(bool_to_option)]
1313
#![feature(crate_visibility_modifier)]
14+
#![feature(format_args_capture)]
1415
#![feature(nll)]
1516
#![feature(or_patterns)]
1617
#![recursion_limit = "256"]

0 commit comments

Comments
 (0)