Skip to content

Commit 089a016

Browse files
committed
Auto merge of #90661 - matthiaskrgr:rollup-1umbdlx, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #90487 (Add a chapter on reading Rustdoc output) - #90508 (Apply adjustments for field expression even if inaccessible) - #90627 (Suggest dereference of `Box` when inner type is expected) - #90642 (use matches!() macro in more places) - #90646 (type error go brrrrrrrr) - #90649 (Run reveal_all on MIR when inlining is activated.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0727994 + ec471de commit 089a016

File tree

36 files changed

+304
-93
lines changed

36 files changed

+304
-93
lines changed

compiler/rustc_ast/src/util/parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ impl AssocOp {
212212
/// parentheses while having a high degree of confidence on the correctness of the suggestion.
213213
pub fn can_continue_expr_unambiguously(&self) -> bool {
214214
use AssocOp::*;
215-
match self {
215+
matches!(
216+
self,
216217
BitXor | // `{ 42 } ^ 3`
217218
Assign | // `{ 42 } = { 42 }`
218219
Divide | // `{ 42 } / 42`
@@ -225,9 +226,8 @@ impl AssocOp {
225226
As | // `{ 42 } as usize`
226227
// Equal | // `{ 42 } == { 42 }` Accepting these here would regress incorrect
227228
// NotEqual | // `{ 42 } != { 42 } struct literals parser recovery.
228-
Colon => true, // `{ 42 }: usize`
229-
_ => false,
230-
}
229+
Colon, // `{ 42 }: usize`
230+
)
231231
}
232232
}
233233

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ pub(crate) enum LaterUseKind {
5353

5454
impl BorrowExplanation {
5555
pub(crate) fn is_explained(&self) -> bool {
56-
match self {
57-
BorrowExplanation::Unexplained => false,
58-
_ => true,
59-
}
56+
!matches!(self, BorrowExplanation::Unexplained)
6057
}
6158
pub(crate) fn add_explanation_to_diagnostic<'tcx>(
6259
&self,

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,14 +2110,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
21102110
_ => constraint_sup_scc != target_scc,
21112111
}
21122112
} else {
2113-
match categorized_path[*i].category {
2113+
!matches!(
2114+
categorized_path[*i].category,
21142115
ConstraintCategory::OpaqueType
2115-
| ConstraintCategory::Boring
2116-
| ConstraintCategory::BoringNoLocation
2117-
| ConstraintCategory::Internal
2118-
| ConstraintCategory::Predicate(_) => false,
2119-
_ => true,
2120-
}
2116+
| ConstraintCategory::Boring
2117+
| ConstraintCategory::BoringNoLocation
2118+
| ConstraintCategory::Internal
2119+
| ConstraintCategory::Predicate(_)
2120+
)
21212121
}
21222122
};
21232123

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,11 @@ impl<'tcx> DefiningTy<'tcx> {
138138
}
139139

140140
pub fn is_fn_def(&self) -> bool {
141-
match *self {
142-
DefiningTy::FnDef(..) => true,
143-
_ => false,
144-
}
141+
matches!(*self, DefiningTy::FnDef(..))
145142
}
146143

147144
pub fn is_const(&self) -> bool {
148-
match *self {
149-
DefiningTy::Const(..) => true,
150-
_ => false,
151-
}
145+
matches!(*self, DefiningTy::Const(..))
152146
}
153147

154148
pub fn def_id(&self) -> DefId {

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,7 @@ fn push_debuginfo_type_name<'tcx>(
124124
// info for MSVC debugger. However, wrapping these types' names in a synthetic type
125125
// causes the .natvis engine for WinDbg to fail to display their data, so we opt these
126126
// types out to aid debugging in MSVC.
127-
let is_slice_or_str = match *inner_type.kind() {
128-
ty::Slice(_) | ty::Str => true,
129-
_ => false,
130-
};
127+
let is_slice_or_str = matches!(*inner_type.kind(), ty::Slice(_) | ty::Str);
131128

132129
if !cpp_like_names {
133130
output.push('&');

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ pub enum ConstEvalErrKind {
2525

2626
impl MachineStopType for ConstEvalErrKind {
2727
fn is_hard_err(&self) -> bool {
28-
match self {
29-
Self::Panic { .. } => true,
30-
_ => false,
31-
}
28+
matches!(self, Self::Panic { .. })
3229
}
3330
}
3431

compiler/rustc_const_eval/src/const_eval/fn_queries.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ fn is_const_fn_raw(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
5151
// If the function itself is not annotated with `const`, it may still be a `const fn`
5252
// if it resides in a const trait impl.
5353
is_parent_const_impl_raw(tcx, hir_id)
54-
} else if let hir::Node::Ctor(_) = node {
55-
true
5654
} else {
57-
false
55+
matches!(node, hir::Node::Ctor(_))
5856
}
5957
}
6058

compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,8 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
138138
args: &[GenericArg<'tcx>],
139139
) -> Result<Self::Path, Self::Error> {
140140
self = print_prefix(self)?;
141-
let args = args.iter().cloned().filter(|arg| match arg.unpack() {
142-
GenericArgKind::Lifetime(_) => false,
143-
_ => true,
144-
});
141+
let args =
142+
args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_)));
145143
if args.clone().next().is_some() {
146144
self.generic_delimiters(|cx| cx.comma_sep(args))
147145
} else {

compiler/rustc_const_eval/src/interpret/terminator.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
345345

346346
// Figure out how to pass which arguments.
347347
// The Rust ABI is special: ZST get skipped.
348-
let rust_abi = match caller_abi {
349-
Abi::Rust | Abi::RustCall => true,
350-
_ => false,
351-
};
348+
let rust_abi = matches!(caller_abi, Abi::Rust | Abi::RustCall);
349+
352350
// We have two iterators: Where the arguments come from,
353351
// and where they go to.
354352

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,7 @@ impl Qualifs<'mir, 'tcx> {
131131
.body
132132
.basic_blocks()
133133
.iter_enumerated()
134-
.find(|(_, block)| match block.terminator().kind {
135-
TerminatorKind::Return => true,
136-
_ => false,
137-
})
134+
.find(|(_, block)| matches!(block.terminator().kind, TerminatorKind::Return))
138135
.map(|(bb, _)| bb);
139136

140137
let return_block = match return_block {

0 commit comments

Comments
 (0)