Skip to content

Commit 6e09cff

Browse files
committed
Auto merge of #116222 - matthiaskrgr:rollup-dnag90q, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #112959 (Change the wording in `std::fmt::Write::write_str`) - #115535 (format doc-comment code examples in std::process) - #115888 (fix a comment about assert_receiver_is_total_eq) - #116211 (more clippy complextity fixes ) - #116213 (Document -Zlink-native-libraries) - #116215 (Tweak wording of missing angle backets in qualified path) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 46da927 + 86d5939 commit 6e09cff

File tree

25 files changed

+263
-132
lines changed

25 files changed

+263
-132
lines changed

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
245245
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else { return; };
246246
diag.span_note(
247247
*trait_span,
248-
format!("due to current limitations in the borrow checker, this implies a `'static` lifetime")
248+
"due to current limitations in the borrow checker, this implies a `'static` lifetime"
249249
);
250250
let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local()) else { return; };
251251
let Def(_, trait_res_defid) = trait_ref.path.res else { return; };
@@ -277,7 +277,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
277277
if suggestions.len() > 0 {
278278
suggestions.dedup();
279279
diag.multipart_suggestion_verbose(
280-
format!("consider restricting the type parameter to the `'static` lifetime"),
280+
"consider restricting the type parameter to the `'static` lifetime",
281281
suggestions,
282282
Applicability::MaybeIncorrect,
283283
);

compiler/rustc_codegen_ssa/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
181181
old_info
182182
}
183183
}
184-
(_, &ty::Dynamic(ref data, _, _)) => meth::get_vtable(cx, source, data.principal()),
184+
(_, ty::Dynamic(data, _, _)) => meth::get_vtable(cx, source, data.principal()),
185185
_ => bug!("unsized_info: invalid unsizing {:?} -> {:?}", source, target),
186186
}
187187
}

compiler/rustc_hir_analysis/src/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ fn impl_trait_ref(
13741374
// make astconv happy.
13751375
let mut path_segments = ast_trait_ref.path.segments.to_vec();
13761376
let last_segment = path_segments.len() - 1;
1377-
let mut args = path_segments[last_segment].args().clone();
1377+
let mut args = *path_segments[last_segment].args();
13781378
let last_arg = args.args.len() - 1;
13791379
assert!(matches!(args.args[last_arg], hir::GenericArg::Const(anon_const) if tcx.has_attr(anon_const.value.def_id, sym::rustc_host)));
13801380
args.args = &args.args[..args.args.len() - 1];

compiler/rustc_hir_typeck/src/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
644644
if self.can_eq(self.param_env, ty, expected) {
645645
err.span_label(
646646
ex.span,
647-
format!("expected because of this `break`"),
647+
"expected because of this `break`",
648648
);
649649
exit = true;
650650
}

compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ fn foo(&self) -> Self::T { String::new() }
621621
{
622622
diag.span_label(
623623
item.span,
624-
format!("associated type is `default` and may be overridden"),
624+
"associated type is `default` and may be overridden",
625625
);
626626
return true;
627627
}

compiler/rustc_middle/src/mir/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1146,10 +1146,10 @@ fn post_fmt_projection(projection: &[PlaceElem<'_>], fmt: &mut Formatter<'_>) ->
11461146
ProjectionElem::ConstantIndex { offset, min_length, from_end: true } => {
11471147
write!(fmt, "[-{offset:?} of {min_length:?}]")?;
11481148
}
1149-
ProjectionElem::Subslice { from, to, from_end: true } if to == 0 => {
1149+
ProjectionElem::Subslice { from, to: 0, from_end: true } => {
11501150
write!(fmt, "[{from:?}:]")?;
11511151
}
1152-
ProjectionElem::Subslice { from, to, from_end: true } if from == 0 => {
1152+
ProjectionElem::Subslice { from: 0, to, from_end: true } => {
11531153
write!(fmt, "[:-{to:?}]")?;
11541154
}
11551155
ProjectionElem::Subslice { from, to, from_end: true } => {

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,7 @@ fn non_exhaustive_match<'p, 'tcx>(
740740
));
741741
}
742742
} else if ty == cx.tcx.types.str_ {
743-
err.note(format!(
744-
"`&str` cannot be matched exhaustively, so a wildcard `_` is necessary",
745-
));
743+
err.note("`&str` cannot be matched exhaustively, so a wildcard `_` is necessary");
746744
} else if cx.is_foreign_non_exhaustive_enum(ty) {
747745
err.note(format!("`{ty}` is marked as non-exhaustive, so a wildcard `_` is necessary to match exhaustively"));
748746
}

compiler/rustc_mir_transform/src/coverage/spans.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ pub(super) fn filtered_statement_span(statement: &Statement<'_>) -> Option<Span>
763763
// and `_1` is the `Place` for `somenum`.
764764
//
765765
// If and when the Issue is resolved, remove this special case match pattern:
766-
StatementKind::FakeRead(box (cause, _)) if cause == FakeReadCause::ForGuardBinding => None,
766+
StatementKind::FakeRead(box (FakeReadCause::ForGuardBinding, _)) => None,
767767

768768
// Retain spans from all other statements
769769
StatementKind::FakeRead(box (_, _)) // Not including `ForGuardBinding`

compiler/rustc_mir_transform/src/large_enums.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,8 @@ impl EnumSizeOpt {
5454
let layout = tcx.layout_of(param_env.and(ty)).ok()?;
5555
let variants = match &layout.variants {
5656
Variants::Single { .. } => return None,
57-
Variants::Multiple { tag_encoding, .. }
58-
if matches!(tag_encoding, TagEncoding::Niche { .. }) =>
59-
{
60-
return None;
61-
}
57+
Variants::Multiple { tag_encoding: TagEncoding::Niche { .. }, .. } => return None,
58+
6259
Variants::Multiple { variants, .. } if variants.len() <= 1 => return None,
6360
Variants::Multiple { variants, .. } => variants,
6461
};

compiler/rustc_parse/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ parse_maybe_fn_typo_with_impl = you might have meant to write `impl` instead of
509509
510510
parse_maybe_recover_from_bad_qpath_stage_2 =
511511
missing angle brackets in associated item path
512-
.suggestion = try: `{$ty}`
512+
.suggestion = types that don't start with an identifier need to be surrounded with angle brackets in qualified paths
513513
514514
parse_maybe_recover_from_bad_type_plus =
515515
expected a path on the left-hand side of `+`, not `{$ty}`

compiler/rustc_parse/src/errors.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,18 @@ pub(crate) enum BadTypePlusSub {
5959
#[diag(parse_maybe_recover_from_bad_qpath_stage_2)]
6060
pub(crate) struct BadQPathStage2 {
6161
#[primary_span]
62-
#[suggestion(code = "", applicability = "maybe-incorrect")]
6362
pub span: Span,
64-
pub ty: String,
63+
#[subdiagnostic]
64+
pub wrap: WrapType,
65+
}
66+
67+
#[derive(Subdiagnostic)]
68+
#[multipart_suggestion(parse_suggestion, applicability = "machine-applicable")]
69+
pub(crate) struct WrapType {
70+
#[suggestion_part(code = "<")]
71+
pub lo: Span,
72+
#[suggestion_part(code = ">")]
73+
pub hi: Span,
6574
}
6675

6776
#[derive(Diagnostic)]

compiler/rustc_parse/src/parser/diagnostics.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::errors::{
1616
StructLiteralBodyWithoutPath, StructLiteralBodyWithoutPathSugg, StructLiteralNeedingParens,
1717
StructLiteralNeedingParensSugg, SuggAddMissingLetStmt, SuggEscapeIdentifier, SuggRemoveComma,
1818
TernaryOperator, UnexpectedConstInGenericParam, UnexpectedConstParamDeclaration,
19-
UnexpectedConstParamDeclarationSugg, UnmatchedAngleBrackets, UseEqInstead,
19+
UnexpectedConstParamDeclarationSugg, UnmatchedAngleBrackets, UseEqInstead, WrapType,
2020
};
2121

2222
use crate::fluent_generated as fluent;
@@ -1589,10 +1589,9 @@ impl<'a> Parser<'a> {
15891589
self.parse_path_segments(&mut path.segments, T::PATH_STYLE, None)?;
15901590
path.span = ty_span.to(self.prev_token.span);
15911591

1592-
let ty_str = self.span_to_snippet(ty_span).unwrap_or_else(|_| pprust::ty_to_string(&ty));
15931592
self.sess.emit_err(BadQPathStage2 {
1594-
span: path.span,
1595-
ty: format!("<{}>::{}", ty_str, pprust::path_to_string(&path)),
1593+
span: ty_span,
1594+
wrap: WrapType { lo: ty_span.shrink_to_lo(), hi: ty_span.shrink_to_hi() },
15961595
});
15971596

15981597
let path_span = ty_span.shrink_to_hi(); // Use an empty path since `position == 0`.

compiler/rustc_resolve/src/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
186186
fallback_label: format!("not a {expected}"),
187187
span,
188188
span_label: match res {
189-
Res::Def(kind, def_id) if kind == DefKind::TyParam => {
189+
Res::Def(DefKind::TyParam, def_id) => {
190190
Some((self.r.def_span(def_id), "found this type parameter"))
191191
}
192192
_ => None,

compiler/rustc_span/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,7 @@ impl SourceFile {
17531753
// is recorded.
17541754
let diff = match self.normalized_pos.binary_search_by(|np| np.pos.cmp(&pos)) {
17551755
Ok(i) => self.normalized_pos[i].diff,
1756-
Err(i) if i == 0 => 0,
1756+
Err(0) => 0,
17571757
Err(i) => self.normalized_pos[i - 1].diff,
17581758
};
17591759

@@ -1775,7 +1775,7 @@ impl SourceFile {
17751775
.binary_search_by(|np| (np.pos.0 + np.diff).cmp(&(self.start_pos.0 + offset)))
17761776
{
17771777
Ok(i) => self.normalized_pos[i].diff,
1778-
Err(i) if i == 0 => 0,
1778+
Err(0) => 0,
17791779
Err(i) => self.normalized_pos[i - 1].diff,
17801780
};
17811781

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3211,7 +3211,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
32113211
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
32123212
let name = match self.tcx.opaque_type_origin(def_id.expect_local()) {
32133213
hir::OpaqueTyOrigin::FnReturn(_) | hir::OpaqueTyOrigin::AsyncFn(_) => {
3214-
format!("opaque type")
3214+
"opaque type".to_string()
32153215
}
32163216
hir::OpaqueTyOrigin::TyAlias { .. } => {
32173217
format!("`{}`", self.tcx.def_path_debug_str(def_id))

compiler/stable_mir/src/fold.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl Foldable for UnevaluatedConst {
8181

8282
impl Foldable for ConstDef {
8383
fn super_fold<V: Folder>(&self, _folder: &mut V) -> ControlFlow<V::Break, Self> {
84-
ControlFlow::Continue(self.clone())
84+
ControlFlow::Continue(*self)
8585
}
8686
}
8787

@@ -96,7 +96,7 @@ impl<T: Foldable> Foldable for Option<T> {
9696

9797
impl Foldable for Promoted {
9898
fn super_fold<V: Folder>(&self, _folder: &mut V) -> ControlFlow<V::Break, Self> {
99-
ControlFlow::Continue(self.clone())
99+
ControlFlow::Continue(*self)
100100
}
101101
}
102102

library/core/src/cmp.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ pub macro PartialEq($item:item) {
291291
#[stable(feature = "rust1", since = "1.0.0")]
292292
#[rustc_diagnostic_item = "Eq"]
293293
pub trait Eq: PartialEq<Self> {
294-
// this method is used solely by #[deriving] to assert
295-
// that every component of a type implements #[deriving]
296-
// itself, the current deriving infrastructure means doing this
294+
// this method is used solely by #[derive(Eq)] to assert
295+
// that every component of a type implements `Eq`
296+
// itself. The current deriving infrastructure means doing this
297297
// assertion without using a method on this trait is nearly
298298
// impossible.
299299
//

library/core/src/fmt/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ pub trait Write {
112112
///
113113
/// # Errors
114114
///
115-
/// This function will return an instance of [`Error`] on error.
115+
/// This function will return an instance of [`std::fmt::Error`][Error] on error.
116116
///
117-
/// The purpose of std::fmt::Error is to abort the formatting operation when the underlying
117+
/// The purpose of that error is to abort the formatting operation when the underlying
118118
/// destination encounters some error preventing it from accepting more text; it should
119119
/// generally be propagated rather than handled, at least when implementing formatting traits.
120120
///

0 commit comments

Comments
 (0)