Skip to content

Commit 684e9d6

Browse files
committed
Auto merge of #123628 - matthiaskrgr:rollup-6otgb94, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #115984 (extending filesystem support for Hermit) - #120144 (privacy: Stabilize lint `unnameable_types`) - #122807 (Add consistency with phrases "meantime" and "mean time") - #123089 (Add invariant to VecDeque::pop_* that len < cap if pop successful) - #123595 (Documentation fix) - #123625 (Stop exporting `TypeckRootCtxt` and `FnCtxt`.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 02a84aa + a961871 commit 684e9d6

File tree

5 files changed

+5
-45
lines changed

5 files changed

+5
-45
lines changed

clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use rustc_errors::Applicability;
1212
use rustc_hir::def::{DefKind, Res};
1313
use rustc_hir::def_id::DefId;
1414
use rustc_hir::{BorrowKind, Expr, ExprKind, ItemKind, LangItem, Node};
15-
use rustc_hir_typeck::{FnCtxt, TypeckRootCtxt};
1615
use rustc_infer::infer::TyCtxtInferExt;
1716
use rustc_lint::LateContext;
1817
use rustc_middle::mir::Mutability;
@@ -437,9 +436,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
437436
Node::Item(item) => {
438437
if let ItemKind::Fn(_, _, body_id) = &item.kind
439438
&& let output_ty = return_ty(cx, item.owner_id)
440-
&& let root_ctxt = TypeckRootCtxt::new(cx.tcx, item.owner_id.def_id)
441-
&& let fn_ctxt = FnCtxt::new(&root_ctxt, cx.param_env, item.owner_id.def_id)
442-
&& fn_ctxt.can_coerce(ty, output_ty)
439+
&& rustc_hir_typeck::can_coerce(cx.tcx, cx.param_env, item.owner_id.def_id, ty, output_ty)
443440
{
444441
if has_lifetime(output_ty) && has_lifetime(ty) {
445442
return false;

clippy_lints/src/misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ declare_clippy_lint! {
6666
///
6767
/// ### Known problems
6868
/// The lint does not work properly with desugaring and
69-
/// macro, it has been allowed in the mean time.
69+
/// macro, it has been allowed in the meantime.
7070
///
7171
/// ### Example
7272
/// ```no_run

clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::utils::check_cast;
1+
use rustc_hir_typeck::cast::check_cast;
22
use super::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS;
33
use clippy_utils::diagnostics::span_lint_and_sugg;
44
use clippy_utils::sugg::Sugg;
@@ -22,7 +22,7 @@ pub(super) fn check<'tcx>(
2222
) -> bool {
2323
use CastKind::{AddrPtrCast, ArrayPtrCast, FnPtrAddrCast, FnPtrPtrCast, PtrAddrCast, PtrPtrCast};
2424
let mut app = Applicability::MachineApplicable;
25-
let mut sugg = match check_cast(cx, e, from_ty, to_ty) {
25+
let mut sugg = match check_cast(cx.tcx, cx.param_env, e, from_ty, to_ty) {
2626
Some(FnPtrAddrCast | PtrAddrCast) if const_context => return false,
2727
Some(PtrPtrCast | AddrPtrCast | ArrayPtrCast | FnPtrPtrCast | FnPtrAddrCast) => {
2828
Sugg::hir_with_context(cx, arg, e.span.ctxt(), "..", &mut app)

clippy_lints/src/transmute/utils.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
use rustc_hir as hir;
2-
use rustc_hir::Expr;
3-
use rustc_hir_typeck::{cast, FnCtxt, TypeckRootCtxt};
41
use rustc_lint::LateContext;
5-
use rustc_middle::ty::cast::CastKind;
62
use rustc_middle::ty::Ty;
7-
use rustc_span::DUMMY_SP;
83

94
// check if the component types of the transmuted collection and the result have different ABI,
105
// size or alignment
@@ -20,35 +15,3 @@ pub(super) fn is_layout_incompatible<'tcx>(cx: &LateContext<'tcx>, from: Ty<'tcx
2015
false
2116
}
2217
}
23-
24-
/// If a cast from `from_ty` to `to_ty` is valid, returns an Ok containing the kind of
25-
/// the cast. In certain cases, including some invalid casts from array references
26-
/// to pointers, this may cause additional errors to be emitted and/or ICE error
27-
/// messages. This function will panic if that occurs.
28-
pub(super) fn check_cast<'tcx>(
29-
cx: &LateContext<'tcx>,
30-
e: &'tcx Expr<'_>,
31-
from_ty: Ty<'tcx>,
32-
to_ty: Ty<'tcx>,
33-
) -> Option<CastKind> {
34-
let hir_id = e.hir_id;
35-
let local_def_id = hir_id.owner.def_id;
36-
37-
let root_ctxt = TypeckRootCtxt::new(cx.tcx, local_def_id);
38-
let fn_ctxt = FnCtxt::new(&root_ctxt, cx.param_env, local_def_id);
39-
40-
if let Ok(check) = cast::CastCheck::new(
41-
&fn_ctxt,
42-
e,
43-
from_ty,
44-
to_ty,
45-
// We won't show any error to the user, so we don't care what the span is here.
46-
DUMMY_SP,
47-
DUMMY_SP,
48-
hir::Constness::NotConst,
49-
) {
50-
check.do_check(&fn_ctxt).ok()
51-
} else {
52-
None
53-
}
54-
}

tests/ui-internal/custom_ice_message.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
44

55
error: the compiler unexpectedly panicked. this is a bug.
66

7-
note: it seems that this compiler <version> is outdated, a newer nightly should have been released in the mean time
7+
note: it seems that this compiler <version> is outdated, a newer nightly should have been released in the meantime
88
|
99
= note: please consider running `rustup update nightly` to update the nightly channel and check if this problem still persists
1010
= note: if the problem still persists, we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml

0 commit comments

Comments
 (0)