Skip to content

Commit e16087f

Browse files
committed
Auto merge of rust-lang#3147 - rust-lang:rustup-2023-10-28, r=saethlin
Automatic Rustup
2 parents b91759e + 2ee3c83 commit e16087f

File tree

8 files changed

+45
-27
lines changed

8 files changed

+45
-27
lines changed

clippy_lints/src/async_yields_async.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_hir_and_then;
22
use clippy_utils::source::snippet;
33
use clippy_utils::ty::implements_trait;
44
use rustc_errors::Applicability;
5-
use rustc_hir::{AsyncCoroutineKind, Body, BodyId, CoroutineKind, ExprKind, QPath};
5+
use rustc_hir::{CoroutineSource, Body, BodyId, CoroutineKind, ExprKind, QPath};
66
use rustc_lint::{LateContext, LateLintPass};
77
use rustc_session::{declare_lint_pass, declare_tool_lint};
88

@@ -45,7 +45,7 @@ declare_lint_pass!(AsyncYieldsAsync => [ASYNC_YIELDS_ASYNC]);
4545

4646
impl<'tcx> LateLintPass<'tcx> for AsyncYieldsAsync {
4747
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
48-
use AsyncCoroutineKind::{Block, Closure};
48+
use CoroutineSource::{Block, Closure};
4949
// For functions, with explicitly defined types, don't warn.
5050
// XXXkhuey maybe we should?
5151
if let Some(CoroutineKind::Async(Block | Closure)) = body.coroutine_kind {

clippy_lints/src/await_holding_invalid.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::{match_def_path, paths};
33
use rustc_data_structures::fx::FxHashMap;
44
use rustc_hir::def_id::DefId;
5-
use rustc_hir::{AsyncCoroutineKind, Body, CoroutineKind};
5+
use rustc_hir::{CoroutineSource, Body, CoroutineKind};
66
use rustc_lint::{LateContext, LateLintPass};
77
use rustc_middle::mir::CoroutineLayout;
88
use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -195,7 +195,7 @@ impl LateLintPass<'_> for AwaitHolding {
195195
}
196196

197197
fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ Body<'_>) {
198-
use AsyncCoroutineKind::{Block, Closure, Fn};
198+
use CoroutineSource::{Block, Closure, Fn};
199199
if let Some(CoroutineKind::Async(Block | Closure | Fn)) = body.coroutine_kind {
200200
let def_id = cx.tcx.hir().body_owner_def_id(body.id());
201201
if let Some(coroutine_layout) = cx.tcx.mir_coroutine_witnesses(def_id) {

clippy_lints/src/manual_async_fn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use if_chain::if_chain;
44
use rustc_errors::Applicability;
55
use rustc_hir::intravisit::FnKind;
66
use rustc_hir::{
7-
AsyncCoroutineKind, Block, Body, Closure, CoroutineKind, Expr, ExprKind, FnDecl, FnRetTy, GenericArg, GenericBound,
7+
CoroutineSource, Block, Body, Closure, CoroutineKind, Expr, ExprKind, FnDecl, FnRetTy, GenericArg, GenericBound,
88
ImplItem, Item, ItemKind, LifetimeName, Node, Term, TraitRef, Ty, TyKind, TypeBindingKind,
99
};
1010
use rustc_lint::{LateContext, LateLintPass};
@@ -188,7 +188,7 @@ fn desugared_async_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>)
188188
..
189189
} = block_expr;
190190
let closure_body = cx.tcx.hir().body(body);
191-
if closure_body.coroutine_kind == Some(CoroutineKind::Async(AsyncCoroutineKind::Block));
191+
if closure_body.coroutine_kind == Some(CoroutineKind::Async(CoroutineSource::Block));
192192
then {
193193
return Some(closure_body);
194194
}

clippy_lints/src/needless_question_mark.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::source::snippet;
44
use if_chain::if_chain;
55
use rustc_errors::Applicability;
66
use rustc_hir::def::{DefKind, Res};
7-
use rustc_hir::{AsyncCoroutineKind, Block, Body, CoroutineKind, Expr, ExprKind, LangItem, MatchSource, QPath};
7+
use rustc_hir::{CoroutineSource, Block, Body, CoroutineKind, Expr, ExprKind, LangItem, MatchSource, QPath};
88
use rustc_lint::{LateContext, LateLintPass};
99
use rustc_session::{declare_lint_pass, declare_tool_lint};
1010

@@ -87,7 +87,7 @@ impl LateLintPass<'_> for NeedlessQuestionMark {
8787
}
8888

8989
fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ Body<'_>) {
90-
if let Some(CoroutineKind::Async(AsyncCoroutineKind::Fn)) = body.coroutine_kind {
90+
if let Some(CoroutineKind::Async(CoroutineSource::Fn)) = body.coroutine_kind {
9191
if let ExprKind::Block(
9292
Block {
9393
expr:

clippy_lints/src/redundant_async_block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clippy_utils::peel_blocks;
55
use clippy_utils::source::{snippet, walk_span_to_context};
66
use clippy_utils::visitors::for_each_expr;
77
use rustc_errors::Applicability;
8-
use rustc_hir::{AsyncCoroutineKind, Closure, CoroutineKind, Expr, ExprKind, MatchSource};
8+
use rustc_hir::{CoroutineSource, Closure, CoroutineKind, Expr, ExprKind, MatchSource};
99
use rustc_lint::{LateContext, LateLintPass};
1010
use rustc_middle::lint::in_external_macro;
1111
use rustc_middle::ty::UpvarCapture;
@@ -71,7 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantAsyncBlock {
7171
fn desugar_async_block<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<&'tcx Expr<'tcx>> {
7272
if let ExprKind::Closure(Closure { body, def_id, .. }) = expr.kind &&
7373
let body = cx.tcx.hir().body(*body) &&
74-
matches!(body.coroutine_kind, Some(CoroutineKind::Async(AsyncCoroutineKind::Block)))
74+
matches!(body.coroutine_kind, Some(CoroutineKind::Async(CoroutineSource::Block)))
7575
{
7676
cx
7777
.typeck_results()

clippy_utils/src/qualify_min_const_fn.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use crate::msrvs::Msrv;
77
use hir::LangItem;
8+
use rustc_attr::{Since, CURRENT_RUSTC_VERSION};
89
use rustc_const_eval::transform::check_consts::ConstCx;
910
use rustc_hir as hir;
1011
use rustc_hir::def_id::DefId;
@@ -370,19 +371,24 @@ fn is_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: &Msrv) -> bool {
370371
// function could be removed if `rustc` provided a MSRV-aware version of `is_const_fn`.
371372
// as a part of an unimplemented MSRV check https://github.com/rust-lang/rust/issues/65262.
372373

373-
// HACK(nilstrieb): CURRENT_RUSTC_VERSION can return versions like 1.66.0-dev. `rustc-semver`
374-
// doesn't accept the `-dev` version number so we have to strip it off.
375-
let short_version = since
376-
.as_str()
377-
.split('-')
378-
.next()
379-
.expect("rustc_attr::StabilityLevel::Stable::since` is empty");
374+
let const_stab_rust_version = match since {
375+
Since::Version(version) => RustcVersion::new(
376+
u32::from(version.major),
377+
u32::from(version.minor),
378+
u32::from(version.patch),
379+
),
380+
Since::Current => {
381+
// HACK(nilstrieb): CURRENT_RUSTC_VERSION can return versions like 1.66.0-dev.
382+
// `rustc-semver` doesn't accept the `-dev` version number so we have to strip it off.
383+
let short_version = CURRENT_RUSTC_VERSION.split('-').next().unwrap();
384+
RustcVersion::parse(short_version).unwrap_or_else(|err| {
385+
panic!("`rustc_attr::StabilityLevel::Stable::since` is ill-formatted: `{CURRENT_RUSTC_VERSION}`, {err:?}")
386+
})
387+
},
388+
Since::Err => return false,
389+
};
380390

381-
let since = rustc_span::Symbol::intern(short_version);
382-
383-
msrv.meets(RustcVersion::parse(since.as_str()).unwrap_or_else(|err| {
384-
panic!("`rustc_attr::StabilityLevel::Stable::since` is ill-formatted: `{since}`, {err:?}")
385-
}))
391+
msrv.meets(const_stab_rust_version)
386392
} else {
387393
// Unstable const fn with the feature enabled.
388394
msrv.current().is_none()

src/driver.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ pub fn main() {
178178

179179
rustc_driver::init_rustc_env_logger(&handler);
180180

181-
rustc_driver::install_ice_hook(BUG_REPORT_URL, |handler| {
181+
let using_internal_features = rustc_driver::install_ice_hook(BUG_REPORT_URL, |handler| {
182182
// FIXME: this macro calls unwrap internally but is called in a panicking context! It's not
183183
// as simple as moving the call from the hook to main, because `install_ice_hook` doesn't
184184
// accept a generic closure.
@@ -265,9 +265,11 @@ pub fn main() {
265265
let clippy_enabled = !cap_lints_allow && (!no_deps || in_primary_package);
266266
if clippy_enabled {
267267
args.extend(clippy_args);
268-
rustc_driver::RunCompiler::new(&args, &mut ClippyCallbacks { clippy_args_var }).run()
268+
rustc_driver::RunCompiler::new(&args, &mut ClippyCallbacks { clippy_args_var })
269+
.set_using_internal_features(using_internal_features).run()
269270
} else {
270-
rustc_driver::RunCompiler::new(&args, &mut RustcCallbacks { clippy_args_var }).run()
271+
rustc_driver::RunCompiler::new(&args, &mut RustcCallbacks { clippy_args_var })
272+
.set_using_internal_features(using_internal_features).run()
271273
}
272274
}))
273275
}

tests/ui/crashes/ice-6252.stderr

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ help: you might be missing a type parameter
2424
LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
2525
| +++++
2626

27-
error: aborting due to 2 previous errors
27+
error[E0046]: not all trait items implemented, missing: `VAL`
28+
--> $DIR/ice-6252.rs:11:1
29+
|
30+
LL | const VAL: T;
31+
| ------------ `VAL` from trait
32+
...
33+
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
34+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation
35+
36+
error: aborting due to 3 previous errors
2837

29-
For more information about this error, try `rustc --explain E0412`.
38+
Some errors have detailed explanations: E0046, E0412.
39+
For more information about an error, try `rustc --explain E0046`.

0 commit comments

Comments
 (0)