Skip to content

Commit d107a87

Browse files
committed
Auto merge of rust-lang#80503 - JohnTitor:rollup-b26vglu, r=JohnTitor
Rollup of 13 pull requests Successful merges: - rust-lang#79812 (Lint on redundant trailing semicolon after item) - rust-lang#80348 (remove redundant clones (clippy::redundant_clone)) - rust-lang#80358 (Edit rustc_span documentation) - rust-lang#80457 (Add missing commas to `rustc_ast_pretty::pp` docs) - rust-lang#80461 (Add llvm-libunwind change to bootstrap CHANGELOG) - rust-lang#80464 (Use Option::map_or instead of open coding it) - rust-lang#80465 (Fix typo in ffi-pure.md) - rust-lang#80467 (More uses of the matches! macro) - rust-lang#80469 (Fix small typo in time comment) - rust-lang#80472 (Use sans-serif font for the "all items" page links) - rust-lang#80477 (Make forget intrinsic safe) - rust-lang#80482 (don't clone copy types) - rust-lang#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

+4-10
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

+5-6
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

+2-4
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

+2-2
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

+1-1
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

+1-1
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

+1-1
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

+3-17
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

+1-4
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

+2-2
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
}

compiler/rustc_middle/src/ty/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
16341634

16351635
let layout = tcx.intern_layout(Layout {
16361636
variants: Variants::Multiple {
1637-
tag: tag,
1637+
tag,
16381638
tag_encoding: TagEncoding::Direct,
16391639
tag_field: tag_index,
16401640
variants,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ struct SplitIntRange {
328328
}
329329

330330
impl SplitIntRange {
331-
fn new(r: IntRange) -> Self {
332-
SplitIntRange { range: r.clone(), borders: Vec::new() }
331+
fn new(range: IntRange) -> Self {
332+
SplitIntRange { range, borders: Vec::new() }
333333
}
334334

335335
/// Internal use

compiler/rustc_span/src/edition.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,25 @@ use std::str::FromStr;
44

55
use rustc_macros::HashStable_Generic;
66

7-
/// The edition of the compiler (RFC 2052)
7+
/// The edition of the compiler. (See [RFC 2052](https://github.com/rust-lang/rfcs/blob/master/text/2052-epochs.md).)
88
#[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Debug, Encodable, Decodable, Eq)]
99
#[derive(HashStable_Generic)]
1010
pub enum Edition {
11-
// editions must be kept in order, oldest to newest
11+
// When adding new editions, be sure to do the following:
12+
//
13+
// - update the `ALL_EDITIONS` const
14+
// - update the `EDITION_NAME_LIST` const
15+
// - add a `rust_####()` function to the session
16+
// - update the enum in Cargo's sources as well
17+
//
18+
// Editions *must* be kept in order, oldest to newest.
1219
/// The 2015 edition
1320
Edition2015,
1421
/// The 2018 edition
1522
Edition2018,
16-
// when adding new editions, be sure to update:
17-
//
18-
// - Update the `ALL_EDITIONS` const
19-
// - Update the EDITION_NAME_LIST const
20-
// - add a `rust_####()` function to the session
21-
// - update the enum in Cargo's sources as well
2223
}
2324

24-
// must be in order from oldest to newest
25+
// Must be in order from oldest to newest.
2526
pub const ALL_EDITIONS: &[Edition] = &[Edition::Edition2015, Edition::Edition2018];
2627

2728
pub const EDITION_NAME_LIST: &str = "2015|2018";

compiler/rustc_span/src/lev_distance.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
//! Levenshtein distances.
2+
//!
3+
//! The [Levenshtein distance] is a metric for measuring the difference between two strings.
4+
//!
5+
//! [Levenshtein distance]: https://en.wikipedia.org/wiki/Levenshtein_distance
6+
17
use crate::symbol::Symbol;
28
use std::cmp;
39

410
#[cfg(test)]
511
mod tests;
612

7-
/// Finds the Levenshtein distance between two strings
13+
/// Finds the Levenshtein distance between two strings.
814
pub fn lev_distance(a: &str, b: &str) -> usize {
915
// cases which don't require further computation
1016
if a.is_empty() {
@@ -35,14 +41,14 @@ pub fn lev_distance(a: &str, b: &str) -> usize {
3541
dcol[t_last + 1]
3642
}
3743

38-
/// Finds the best match for a given word in the given iterator
44+
/// Finds the best match for a given word in the given iterator.
3945
///
4046
/// As a loose rule to avoid the obviously incorrect suggestions, it takes
4147
/// an optional limit for the maximum allowable edit distance, which defaults
4248
/// to one-third of the given word.
4349
///
44-
/// Besides Levenshtein, we use case insensitive comparison to improve accuracy on an edge case with
45-
/// a lower(upper)case letters mismatch.
50+
/// Besides Levenshtein, we use case insensitive comparison to improve accuracy
51+
/// on an edge case with a lower(upper)case letters mismatch.
4652
#[cold]
4753
pub fn find_best_match_for_name(
4854
name_vec: &[Symbol],
@@ -98,7 +104,7 @@ fn find_match_by_sorted_words(iter_names: &[Symbol], lookup: &str) -> Option<Sym
98104

99105
fn sort_by_words(name: &str) -> String {
100106
let mut split_words: Vec<&str> = name.split('_').collect();
101-
// We are sorting primitive &strs and can use unstable sort here
107+
// We are sorting primitive &strs and can use unstable sort here.
102108
split_words.sort_unstable();
103109
split_words.join("_")
104110
}

0 commit comments

Comments
 (0)