Auto merge of #103683 - fee1-dead-contrib:fix-deferred-cast-checks-constness, r=oli-obk
Retain ParamEnv constness when running deferred cast checks Fixes #103677.
This commit is contained in:
commit
9565dfeb4e
5 changed files with 33 additions and 5 deletions
5
src/test/ui/rfc-2632-const-trait-impl/issue-103677.rs
Normal file
5
src/test/ui/rfc-2632-const-trait-impl/issue-103677.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// check-pass
|
||||
|
||||
const _: fn(&String) = |s| { &*s as &str; };
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -3,6 +3,7 @@ use rustc_hir_typeck::{cast, FnCtxt, Inherited};
|
|||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::{cast::CastKind, Ty};
|
||||
use rustc_span::DUMMY_SP;
|
||||
use rustc_hir as hir;
|
||||
|
||||
// check if the component types of the transmuted collection and the result have different ABI,
|
||||
// size or alignment
|
||||
|
|
@ -56,7 +57,7 @@ fn check_cast<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty<'tcx>
|
|||
if let Ok(check) = cast::CastCheck::new(
|
||||
&fn_ctxt, e, from_ty, to_ty,
|
||||
// We won't show any error to the user, so we don't care what the span is here.
|
||||
DUMMY_SP, DUMMY_SP,
|
||||
DUMMY_SP, DUMMY_SP, hir::Constness::NotConst,
|
||||
) {
|
||||
let res = check.do_check(&fn_ctxt);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue