Skip to content

Commit d107a87

Browse files
committed
Auto merge of #80503 - JohnTitor:rollup-b26vglu, r=JohnTitor
Rollup of 13 pull requests Successful merges: - #79812 (Lint on redundant trailing semicolon after item) - #80348 (remove redundant clones (clippy::redundant_clone)) - #80358 (Edit rustc_span documentation) - #80457 (Add missing commas to `rustc_ast_pretty::pp` docs) - #80461 (Add llvm-libunwind change to bootstrap CHANGELOG) - #80464 (Use Option::map_or instead of open coding it) - #80465 (Fix typo in ffi-pure.md) - #80467 (More uses of the matches! macro) - #80469 (Fix small typo in time comment) - #80472 (Use sans-serif font for the "all items" page links) - #80477 (Make forget intrinsic safe) - #80482 (don't clone copy types) - #80487 (don't redundantly repeat field names) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents b9c403b + 3812909 commit d107a87

File tree

39 files changed

+164
-142
lines changed

39 files changed

+164
-142
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,15 +1092,9 @@ impl Expr {
10921092
if let ExprKind::Block(ref block, _) = self.kind {
10931093
match block.stmts.last().map(|last_stmt| &last_stmt.kind) {
10941094
// Implicit return
1095-
Some(&StmtKind::Expr(_)) => true,
1096-
Some(&StmtKind::Semi(ref expr)) => {
1097-
if let ExprKind::Ret(_) = expr.kind {
1098-
// Last statement is explicit return.
1099-
true
1100-
} else {
1101-
false
1102-
}
1103-
}
1095+
Some(StmtKind::Expr(_)) => true,
1096+
// Last statement is an explicit return?
1097+
Some(StmtKind::Semi(expr)) => matches!(expr.kind, ExprKind::Ret(_)),
11041098
// This is a block that doesn't end in either an implicit or explicit return.
11051099
_ => false,
11061100
}
@@ -1950,7 +1944,7 @@ impl TyKind {
19501944
}
19511945

19521946
pub fn is_unit(&self) -> bool {
1953-
if let TyKind::Tup(ref tys) = *self { tys.is_empty() } else { false }
1947+
matches!(self, TyKind::Tup(tys) if tys.is_empty())
19541948
}
19551949
}
19561950

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,12 +1857,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18571857
output,
18581858
c_variadic,
18591859
implicit_self: decl.inputs.get(0).map_or(hir::ImplicitSelfKind::None, |arg| {
1860-
let is_mutable_pat = match arg.pat.kind {
1861-
PatKind::Ident(BindingMode::ByValue(mt) | BindingMode::ByRef(mt), _, _) => {
1862-
mt == Mutability::Mut
1863-
}
1864-
_ => false,
1865-
};
1860+
use BindingMode::{ByRef, ByValue};
1861+
let is_mutable_pat = matches!(
1862+
arg.pat.kind,
1863+
PatKind::Ident(ByValue(Mutability::Mut) | ByRef(Mutability::Mut), ..)
1864+
);
18661865

18671866
match arg.ty.kind {
18681867
TyKind::ImplicitSelf if is_mutable_pat => hir::ImplicitSelfKind::Mut,

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
397397
match i.kind {
398398
ast::ForeignItemKind::Fn(..) | ast::ForeignItemKind::Static(..) => {
399399
let link_name = self.sess.first_attr_value_str_by_name(&i.attrs, sym::link_name);
400-
let links_to_llvm = match link_name {
401-
Some(val) => val.as_str().starts_with("llvm."),
402-
_ => false,
403-
};
400+
let links_to_llvm =
401+
link_name.map_or(false, |val| val.as_str().starts_with("llvm."));
404402
if links_to_llvm {
405403
gate_feature_post!(
406404
&self,

compiler/rustc_ast_pretty/src/pp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@
7575
//! breaking inconsistently to become
7676
//!
7777
//! ```
78-
//! foo(hello, there
78+
//! foo(hello, there,
7979
//! good, friends);
8080
//! ```
8181
//!
8282
//! whereas a consistent breaking would yield:
8383
//!
8484
//! ```
8585
//! foo(hello,
86-
//! there
86+
//! there,
8787
//! good,
8888
//! friends);
8989
//! ```

compiler/rustc_codegen_ssa/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub struct NativeLib {
116116

117117
impl From<&cstore::NativeLib> for NativeLib {
118118
fn from(lib: &cstore::NativeLib) -> Self {
119-
NativeLib { kind: lib.kind.clone(), name: lib.name.clone(), cfg: lib.cfg.clone() }
119+
NativeLib { kind: lib.kind, name: lib.name, cfg: lib.cfg.clone() }
120120
}
121121
}
122122

compiler/rustc_data_structures/src/graph/scc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ where
523523
successors_len: 0,
524524
min_depth: depth,
525525
min_cycle_root: successor_node,
526-
successor_node: successor_node,
526+
successor_node,
527527
});
528528
continue 'recurse;
529529
}

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
13171317
T: TypeFoldable<'tcx>,
13181318
{
13191319
if !value.needs_infer() {
1320-
return value.clone(); // Avoid duplicated subst-folding.
1320+
return value; // Avoid duplicated subst-folding.
13211321
}
13221322
let mut r = resolve::OpportunisticVarResolver::new(self);
13231323
value.fold_with(&mut r)

compiler/rustc_lint/src/redundant_semicolon.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,26 @@ declare_lint_pass!(RedundantSemicolons => [REDUNDANT_SEMICOLONS]);
2828

2929
impl EarlyLintPass for RedundantSemicolons {
3030
fn check_block(&mut self, cx: &EarlyContext<'_>, block: &Block) {
31-
let mut after_item_stmt = false;
3231
let mut seq = None;
3332
for stmt in block.stmts.iter() {
3433
match (&stmt.kind, &mut seq) {
3534
(StmtKind::Empty, None) => seq = Some((stmt.span, false)),
3635
(StmtKind::Empty, Some(seq)) => *seq = (seq.0.to(stmt.span), true),
37-
(_, seq) => {
38-
maybe_lint_redundant_semis(cx, seq, after_item_stmt);
39-
after_item_stmt = matches!(stmt.kind, StmtKind::Item(_));
40-
}
36+
(_, seq) => maybe_lint_redundant_semis(cx, seq),
4137
}
4238
}
43-
maybe_lint_redundant_semis(cx, &mut seq, after_item_stmt);
39+
maybe_lint_redundant_semis(cx, &mut seq);
4440
}
4541
}
4642

47-
fn maybe_lint_redundant_semis(
48-
cx: &EarlyContext<'_>,
49-
seq: &mut Option<(Span, bool)>,
50-
after_item_stmt: bool,
51-
) {
43+
fn maybe_lint_redundant_semis(cx: &EarlyContext<'_>, seq: &mut Option<(Span, bool)>) {
5244
if let Some((span, multiple)) = seq.take() {
5345
// FIXME: Find a better way of ignoring the trailing
5446
// semicolon from macro expansion
5547
if span == rustc_span::DUMMY_SP {
5648
return;
5749
}
5850

59-
// FIXME: Lint on semicolons after item statements
60-
// once doing so doesn't break bootstrapping
61-
if after_item_stmt {
62-
return;
63-
}
64-
6551
cx.struct_span_lint(REDUNDANT_SEMICOLONS, span, |lint| {
6652
let (msg, rem) = if multiple {
6753
("unnecessary trailing semicolons", "remove these semicolons")

compiler/rustc_middle/src/hir/place.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ impl<'tcx> PlaceWithHirId<'tcx> {
110110
base: PlaceBase,
111111
projections: Vec<Projection<'tcx>>,
112112
) -> PlaceWithHirId<'tcx> {
113-
PlaceWithHirId {
114-
hir_id: hir_id,
115-
place: Place { base_ty: base_ty, base: base, projections: projections },
116-
}
113+
PlaceWithHirId { hir_id, place: Place { base_ty, base, projections } }
117114
}
118115
}
119116

compiler/rustc_middle/src/mir/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,13 @@ macro_rules! make_mir_visitor {
306306

307307
let mut index = 0;
308308
for statement in statements {
309-
let location = Location { block: block, statement_index: index };
309+
let location = Location { block, statement_index: index };
310310
self.visit_statement(statement, location);
311311
index += 1;
312312
}
313313

314314
if let Some(terminator) = terminator {
315-
let location = Location { block: block, statement_index: index };
315+
let location = Location { block, statement_index: index };
316316
self.visit_terminator(terminator, location);
317317
}
318318
}

0 commit comments

Comments
 (0)