Skip to content

Commit 54a20a0

Browse files
committed
Auto merge of #7468 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents 09f5f15 + 43b0121 commit 54a20a0

File tree

14 files changed

+40
-50
lines changed

14 files changed

+40
-50
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ Released 2021-02-11
592592

593593
* Previously deprecated [`str_to_string`] and [`string_to_string`] have been un-deprecated
594594
as `restriction` lints [#6333](https://github.com/rust-lang/rust-clippy/pull/6333)
595-
* Deprecate `panic_params` lint. This is now available in rustc as `non_fmt_panic`
595+
* Deprecate `panic_params` lint. This is now available in rustc as `non_fmt_panics`
596596
[#6351](https://github.com/rust-lang/rust-clippy/pull/6351)
597597
* Move [`map_err_ignore`] to `restriction`
598598
[#6416](https://github.com/rust-lang/rust-clippy/pull/6416)

clippy_lints/src/doc.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use rustc_span::source_map::{BytePos, FilePathMapping, MultiSpan, SourceMap, Spa
2626
use rustc_span::{sym, FileName, Pos};
2727
use std::io;
2828
use std::ops::Range;
29+
use std::thread;
2930
use url::Url;
3031

3132
declare_clippy_lint! {
@@ -584,17 +585,17 @@ fn get_current_span(spans: &[(usize, Span)], idx: usize) -> (usize, Span) {
584585
}
585586

586587
fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
587-
fn has_needless_main(code: &str, edition: Edition) -> bool {
588+
fn has_needless_main(code: String, edition: Edition) -> bool {
588589
rustc_driver::catch_fatal_errors(|| {
589-
rustc_span::with_session_globals(edition, || {
590-
let filename = FileName::anon_source_code(code);
590+
rustc_span::create_session_globals_then(edition, || {
591+
let filename = FileName::anon_source_code(&code);
591592

592593
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
593594
let emitter = EmitterWriter::new(box io::sink(), None, false, false, false, None, false);
594595
let handler = Handler::with_emitter(false, None, box emitter);
595596
let sess = ParseSess::with_span_handler(handler, sm);
596597

597-
let mut parser = match maybe_new_parser_from_source_str(&sess, filename, code.into()) {
598+
let mut parser = match maybe_new_parser_from_source_str(&sess, filename, code) {
598599
Ok(p) => p,
599600
Err(errs) => {
600601
for mut err in errs {
@@ -649,7 +650,13 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
649650
.unwrap_or_default()
650651
}
651652

652-
if has_needless_main(text, edition) {
653+
// Because of the global session, we need to create a new session in a different thread with
654+
// the edition we need.
655+
let text = text.to_owned();
656+
if thread::spawn(move || has_needless_main(text, edition))
657+
.join()
658+
.expect("thread::spawn failed")
659+
{
653660
span_lint(cx, NEEDLESS_DOCTEST_MAIN, span, "needless `fn main` in doctest");
654661
}
655662
}

clippy_lints/src/implicit_hasher.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(rustc::default_hash_types)]
2-
31
use std::borrow::Cow;
42
use std::collections::BTreeMap;
53

clippy_lints/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2177,7 +2177,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
21772177
ls.register_renamed("clippy::unused_label", "unused_labels");
21782178
ls.register_renamed("clippy::drop_bounds", "drop_bounds");
21792179
ls.register_renamed("clippy::temporary_cstring_as_ptr", "temporary_cstring_as_ptr");
2180-
ls.register_renamed("clippy::panic_params", "non_fmt_panic");
2180+
ls.register_renamed("clippy::panic_params", "non_fmt_panics");
21812181
ls.register_renamed("clippy::unknown_clippy_lints", "unknown_lints");
21822182
}
21832183

clippy_lints/src/misc.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -662,14 +662,7 @@ fn in_attributes_expansion(expr: &Expr<'_>) -> bool {
662662
use rustc_span::hygiene::MacroKind;
663663
if expr.span.from_expansion() {
664664
let data = expr.span.ctxt().outer_expn_data();
665-
matches!(
666-
data.kind,
667-
ExpnKind::Macro {
668-
kind: MacroKind::Attr,
669-
name: _,
670-
proc_macro: _
671-
}
672-
)
665+
matches!(data.kind, ExpnKind::Macro(MacroKind::Attr, _))
673666
} else {
674667
false
675668
}

clippy_lints/src/mut_key.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ fn is_mutable_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Span) -> bo
120120
},
121121
Tuple(..) => ty.tuple_fields().any(|ty| is_mutable_type(cx, ty, span)),
122122
Adt(..) => {
123-
cx.tcx.layout_of(cx.param_env.and(ty)).is_ok()
124-
&& !ty.has_escaping_bound_vars()
123+
!ty.has_escaping_bound_vars()
124+
&& cx.tcx.layout_of(cx.param_env.and(ty)).is_ok()
125125
&& !ty.is_freeze(cx.tcx.at(span), cx.param_env)
126126
},
127127
_ => false,

clippy_lints/src/unit_types/unit_cmp.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ use super::UNIT_CMP;
88
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
99
if expr.span.from_expansion() {
1010
if let Some(callee) = expr.span.source_callee() {
11-
if let ExpnKind::Macro {
12-
kind: MacroKind::Bang,
13-
name: symbol,
14-
proc_macro: _,
15-
} = callee.kind
16-
{
11+
if let ExpnKind::Macro(MacroKind::Bang, symbol) = callee.kind {
1712
if let ExprKind::Binary(ref cmp, left, _) = expr.kind {
1813
let op = cmp.node;
1914
if op.is_comparison() && cx.typeck_results().expr_ty(left).is_unit() {

clippy_lints/src/utils/internal_lints/metadata_collector.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,9 @@ fn get_lint_group_and_level_or_lint(
520520
lint_name: &str,
521521
item: &'hir Item<'_>,
522522
) -> Option<(String, &'static str)> {
523-
let result = cx.lint_store.check_lint_name(lint_name, Some(sym::clippy));
523+
let result = cx
524+
.lint_store
525+
.check_lint_name(cx.sess(), lint_name, Some(sym::clippy), &[]);
524526
if let CheckLintNameResult::Tool(Ok(lint_lst)) = result {
525527
if let Some(group) = get_lint_group(cx, lint_lst[0]) {
526528
if EXCLUDED_LINT_GROUPS.contains(&group.as_str()) {

clippy_utils/src/higher.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl FormatExpn<'tcx> {
285285
if let Some(init) = local.init;
286286
if let ExprKind::Call(_, [format_args]) = init.kind;
287287
let expn_data = expr.span.ctxt().outer_expn_data();
288-
if let ExpnKind::Macro { name: sym::format, .. } = expn_data.kind;
288+
if let ExpnKind::Macro(_, sym::format) = expn_data.kind;
289289
if let Some(format_args) = FormatArgsExpn::parse(format_args);
290290
then {
291291
Some(FormatExpn {
@@ -320,7 +320,7 @@ impl FormatArgsExpn<'tcx> {
320320
/// Parses an expanded `format_args!` or `format_args_nl!` invocation
321321
pub fn parse(expr: &'tcx Expr<'tcx>) -> Option<Self> {
322322
if_chain! {
323-
if let ExpnKind::Macro { name, .. } = expr.span.ctxt().outer_expn_data().kind;
323+
if let ExpnKind::Macro(_, name) = expr.span.ctxt().outer_expn_data().kind;
324324
let name = name.as_str();
325325
if name.ends_with("format_args") || name.ends_with("format_args_nl");
326326
if let ExprKind::Call(_, args) = expr.kind;

clippy_utils/src/lib.rs

+3-13
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Res {
483483
_ => return Res::Err,
484484
};
485485
let tcx = cx.tcx;
486-
let crates = tcx.crates();
486+
let crates = tcx.crates(());
487487
let krate = try_res!(crates.iter().find(|&&num| tcx.crate_name(num).as_str() == krate));
488488
let first = try_res!(item_child_by_name(tcx, krate.as_def_id(), first));
489489
let last = path
@@ -953,12 +953,7 @@ pub fn is_expn_of(mut span: Span, name: &str) -> Option<Span> {
953953
let data = span.ctxt().outer_expn_data();
954954
let new_span = data.call_site;
955955

956-
if let ExpnKind::Macro {
957-
kind: MacroKind::Bang,
958-
name: mac_name,
959-
proc_macro: _,
960-
} = data.kind
961-
{
956+
if let ExpnKind::Macro(MacroKind::Bang, mac_name) = data.kind {
962957
if mac_name.as_str() == name {
963958
return Some(new_span);
964959
}
@@ -986,12 +981,7 @@ pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
986981
let data = span.ctxt().outer_expn_data();
987982
let new_span = data.call_site;
988983

989-
if let ExpnKind::Macro {
990-
kind: MacroKind::Bang,
991-
name: mac_name,
992-
proc_macro: _,
993-
} = data.kind
994-
{
984+
if let ExpnKind::Macro(MacroKind::Bang, mac_name) = data.kind {
995985
if mac_name.as_str() == name {
996986
return Some(new_span);
997987
}

clippy_utils/src/ty.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use rustc_middle::ty::{self, AdtDef, IntTy, Ty, TypeFoldable, UintTy};
1414
use rustc_span::sym;
1515
use rustc_span::symbol::{Ident, Symbol};
1616
use rustc_span::DUMMY_SP;
17+
use rustc_trait_selection::infer::InferCtxtExt;
1718
use rustc_trait_selection::traits::query::normalize::AtExt;
1819

1920
use crate::{match_def_path, must_use_attr};
@@ -112,23 +113,27 @@ pub fn has_iter_method(cx: &LateContext<'_>, probably_ref_ty: Ty<'_>) -> Option<
112113
}
113114

114115
/// Checks whether a type implements a trait.
116+
/// The function returns false in case the type contains an inference variable.
115117
/// See also `get_trait_def_id`.
116118
pub fn implements_trait<'tcx>(
117119
cx: &LateContext<'tcx>,
118120
ty: Ty<'tcx>,
119121
trait_id: DefId,
120122
ty_params: &[GenericArg<'tcx>],
121123
) -> bool {
122-
// Do not check on infer_types to avoid panic in evaluate_obligation.
123-
if ty.has_infer_types() {
124-
return false;
125-
}
124+
// Clippy shouldn't have infer types
125+
assert!(!ty.needs_infer());
126+
126127
let ty = cx.tcx.erase_regions(ty);
127128
if ty.has_escaping_bound_vars() {
128129
return false;
129130
}
130131
let ty_params = cx.tcx.mk_substs(ty_params.iter());
131-
cx.tcx.type_implements_trait((trait_id, ty, ty_params, cx.param_env))
132+
cx.tcx.infer_ctxt().enter(|infcx| {
133+
infcx
134+
.type_implements_trait(trait_id, ty, ty_params, cx.param_env)
135+
.must_apply_modulo_regions()
136+
})
132137
}
133138

134139
/// Checks whether this type implements `Drop`.

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2021-07-01"
2+
channel = "nightly-2021-07-15"
33
components = ["llvm-tools-preview", "rustc-dev", "rust-src"]

tests/ui/assertions_on_constants.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(non_fmt_panic)]
1+
#![allow(non_fmt_panics)]
22

33
macro_rules! assert_const {
44
($len:expr) => {

tests/ui/deprecated.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cs
6060
LL | #[warn(clippy::temporary_cstring_as_ptr)]
6161
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr`
6262

63-
error: lint `clippy::panic_params` has been renamed to `non_fmt_panic`
63+
error: lint `clippy::panic_params` has been renamed to `non_fmt_panics`
6464
--> $DIR/deprecated.rs:11:8
6565
|
6666
LL | #[warn(clippy::panic_params)]
67-
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panic`
67+
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics`
6868

6969
error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints`
7070
--> $DIR/deprecated.rs:12:8

0 commit comments

Comments
 (0)