Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 91496c2

Browse files
committed
Auto merge of rust-lang#7853 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents 535262c + 8e48333 commit 91496c2

File tree

69 files changed

+316
-625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+316
-625
lines changed

CHANGELOG.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,10 +1873,10 @@ Released 2019-01-17
18731873

18741874
[2e26fdc2...b2601be](https://github.com/rust-lang/rust-clippy/compare/2e26fdc2...b2601be)
18751875

1876-
* New lints: [`slow_vector_initialization`], [`mem_discriminant_non_enum`],
1876+
* New lints: [`slow_vector_initialization`], `mem_discriminant_non_enum`,
18771877
[`redundant_clone`], [`wildcard_dependencies`],
18781878
[`into_iter_on_ref`], `into_iter_on_array`, [`deprecated_cfg_attr`],
1879-
[`mem_discriminant_non_enum`], [`cargo_common_metadata`]
1879+
[`cargo_common_metadata`]
18801880
* Add support for `u128` and `i128` to integer related lints
18811881
* Add float support to `mistyped_literal_suffixes`
18821882
* Fix false positives in `use_self`
@@ -2842,7 +2842,6 @@ Released 2018-09-13
28422842
[`match_wild_err_arm`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_wild_err_arm
28432843
[`match_wildcard_for_single_variants`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_wildcard_for_single_variants
28442844
[`maybe_infinite_iter`]: https://rust-lang.github.io/rust-clippy/master/index.html#maybe_infinite_iter
2845-
[`mem_discriminant_non_enum`]: https://rust-lang.github.io/rust-clippy/master/index.html#mem_discriminant_non_enum
28462845
[`mem_forget`]: https://rust-lang.github.io/rust-clippy/master/index.html#mem_forget
28472846
[`mem_replace_option_with_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_option_with_none
28482847
[`mem_replace_with_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.57"
3+
version = "0.1.58"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.57"
3+
version = "0.1.58"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_lints/src/copies.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_data_structures::fx::FxHashSet;
99
use rustc_errors::{Applicability, DiagnosticBuilder};
1010
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
1111
use rustc_hir::{Block, Expr, ExprKind, HirId};
12-
use rustc_lint::{LateContext, LateLintPass};
12+
use rustc_lint::{LateContext, LateLintPass, LintContext};
1313
use rustc_middle::hir::map::Map;
1414
use rustc_session::{declare_lint_pass, declare_tool_lint};
1515
use rustc_span::{source_map::Span, symbol::Symbol, BytePos};
@@ -432,10 +432,11 @@ fn emit_branches_sharing_code_lint(
432432
let mut add_expr_note = false;
433433

434434
// Construct suggestions
435+
let sm = cx.sess().source_map();
435436
if start_stmts > 0 {
436437
let block = blocks[0];
437438
let span_start = first_line_of_span(cx, if_expr.span).shrink_to_lo();
438-
let span_end = block.stmts[start_stmts - 1].span.source_callsite();
439+
let span_end = sm.stmt_span(block.stmts[start_stmts - 1].span, block.span);
439440

440441
let cond_span = first_line_of_span(cx, if_expr.span).until(block.span);
441442
let cond_snippet = reindent_multiline(snippet(cx, cond_span, "_"), false, None);
@@ -454,15 +455,14 @@ fn emit_branches_sharing_code_lint(
454455
let span_end = block.span.shrink_to_hi();
455456

456457
let moved_start = if end_stmts == 0 && block.expr.is_some() {
457-
block.expr.unwrap().span
458+
block.expr.unwrap().span.source_callsite()
458459
} else {
459-
block.stmts[block.stmts.len() - end_stmts].span
460-
}
461-
.source_callsite();
462-
let moved_end = block
463-
.expr
464-
.map_or_else(|| block.stmts[block.stmts.len() - 1].span, |expr| expr.span)
465-
.source_callsite();
460+
sm.stmt_span(block.stmts[block.stmts.len() - end_stmts].span, block.span)
461+
};
462+
let moved_end = block.expr.map_or_else(
463+
|| sm.stmt_span(block.stmts[block.stmts.len() - 1].span, block.span),
464+
|expr| expr.span.source_callsite(),
465+
);
466466

467467
let moved_span = moved_start.to(moved_end);
468468
let moved_snipped = reindent_multiline(snippet(cx, moved_span, "_"), true, None);

clippy_lints/src/format.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessFormat {
8989
}
9090
}
9191

92-
fn span_useless_format(cx: &LateContext<'_>, span: Span, mut sugg: String, mut applicability: Applicability) {
93-
// The callsite span contains the statement semicolon for some reason.
94-
if snippet_with_applicability(cx, span, "..", &mut applicability).ends_with(';') {
95-
sugg.push(';');
96-
}
97-
92+
fn span_useless_format(cx: &LateContext<'_>, span: Span, sugg: String, applicability: Applicability) {
9893
span_lint_and_sugg(
9994
cx,
10095
USELESS_FORMAT,

clippy_lints/src/lib.register_all.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
130130
LintId::of(matches::REDUNDANT_PATTERN_MATCHING),
131131
LintId::of(matches::SINGLE_MATCH),
132132
LintId::of(matches::WILDCARD_IN_OR_PATTERNS),
133-
LintId::of(mem_discriminant::MEM_DISCRIMINANT_NON_ENUM),
134133
LintId::of(mem_replace::MEM_REPLACE_OPTION_WITH_NONE),
135134
LintId::of(mem_replace::MEM_REPLACE_WITH_DEFAULT),
136135
LintId::of(mem_replace::MEM_REPLACE_WITH_UNINIT),

clippy_lints/src/lib.register_correctness.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ store.register_group(true, "clippy::correctness", Some("clippy_correctness"), ve
3737
LintId::of(loops::NEVER_LOOP),
3838
LintId::of(loops::WHILE_IMMUTABLE_CONDITION),
3939
LintId::of(match_str_case_mismatch::MATCH_STR_CASE_MISMATCH),
40-
LintId::of(mem_discriminant::MEM_DISCRIMINANT_NON_ENUM),
4140
LintId::of(mem_replace::MEM_REPLACE_WITH_UNINIT),
4241
LintId::of(methods::CLONE_DOUBLE_REF),
4342
LintId::of(methods::ITERATOR_STEP_BY_ZERO),

clippy_lints/src/lib.register_lints.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ store.register_lints(&[
245245
matches::SINGLE_MATCH_ELSE,
246246
matches::WILDCARD_ENUM_MATCH_ARM,
247247
matches::WILDCARD_IN_OR_PATTERNS,
248-
mem_discriminant::MEM_DISCRIMINANT_NON_ENUM,
249248
mem_forget::MEM_FORGET,
250249
mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
251250
mem_replace::MEM_REPLACE_WITH_DEFAULT,

clippy_lints/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ mod match_on_vec_items;
268268
mod match_result_ok;
269269
mod match_str_case_mismatch;
270270
mod matches;
271-
mod mem_discriminant;
272271
mod mem_forget;
273272
mod mem_replace;
274273
mod methods;
@@ -606,7 +605,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
606605
let doc_valid_idents = conf.doc_valid_idents.iter().cloned().collect::<FxHashSet<_>>();
607606
store.register_late_pass(move || Box::new(doc::DocMarkdown::new(doc_valid_idents.clone())));
608607
store.register_late_pass(|| Box::new(neg_multiply::NegMultiply));
609-
store.register_late_pass(|| Box::new(mem_discriminant::MemDiscriminant));
610608
store.register_late_pass(|| Box::new(mem_forget::MemForget));
611609
store.register_late_pass(|| Box::new(arithmetic::Arithmetic::default()));
612610
store.register_late_pass(|| Box::new(assign_ops::AssignOps));
@@ -861,6 +859,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
861859
ls.register_renamed("clippy::panic_params", "non_fmt_panics");
862860
ls.register_renamed("clippy::unknown_clippy_lints", "unknown_lints");
863861
ls.register_renamed("clippy::invalid_atomic_ordering", "invalid_atomic_ordering");
862+
ls.register_renamed("clippy::mem_discriminant_non_enum", "enum_intrinsics_non_enums");
864863
}
865864

866865
// only exists to let the dogfood integration test works.

clippy_lints/src/manual_unwrap_or.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn lint_manual_unwrap_or<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
9898
reindent_multiline(or_body_snippet.into(), true, Some(indent));
9999

100100
let suggestion = if scrutinee.span.from_expansion() {
101-
// we don't want parenthesis around macro, e.g. `(some_macro!()).unwrap_or(0)`
101+
// we don't want parentheses around macro, e.g. `(some_macro!()).unwrap_or(0)`
102102
sugg::Sugg::hir_with_macro_callsite(cx, scrutinee, "..")
103103
}
104104
else {

0 commit comments

Comments
 (0)