Do not trim paths in MIR validator
This commit is contained in:
parent
ecb170afc8
commit
c00343a5b4
2 changed files with 44 additions and 1 deletions
|
@ -12,6 +12,7 @@ use rustc_middle::mir::coverage::CoverageKind;
|
|||
use rustc_middle::mir::visit::{NonUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::adjustment::PointerCoercion;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::{
|
||||
self, CoroutineArgsExt, InstanceKind, ScalarInt, Ty, TyCtxt, TypeVisitableExt, Upcast, Variance,
|
||||
};
|
||||
|
@ -543,7 +544,13 @@ pub(super) fn validate_types<'tcx>(
|
|||
caller_body: &Body<'tcx>,
|
||||
) -> Vec<(Location, String)> {
|
||||
let mut type_checker = TypeChecker { body, caller_body, tcx, typing_env, failures: Vec::new() };
|
||||
type_checker.visit_body(body);
|
||||
// The type checker formats a bunch of strings with type names in it, but these strings
|
||||
// are not always going to be encountered on the error path since the inliner also uses
|
||||
// the validator, and there are certain kinds of inlining (even for valid code) that
|
||||
// can cause validation errors (mostly around where clauses and rigid projections).
|
||||
with_no_trimmed_paths!({
|
||||
type_checker.visit_body(body);
|
||||
});
|
||||
type_checker.failures
|
||||
}
|
||||
|
||||
|
|
36
tests/ui/mir/inline-causes-trimmed-paths.rs
Normal file
36
tests/ui/mir/inline-causes-trimmed-paths.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
//@ build-pass
|
||||
//@ compile-flags: -Zinline-mir
|
||||
|
||||
trait Storage {
|
||||
type Buffer: ?Sized;
|
||||
}
|
||||
|
||||
struct Array<const N: usize>;
|
||||
impl<const N: usize> Storage for Array<N> {
|
||||
type Buffer = [(); N];
|
||||
}
|
||||
|
||||
struct Slice;
|
||||
impl Storage for Slice {
|
||||
type Buffer = [()];
|
||||
}
|
||||
|
||||
struct Wrap<S: Storage> {
|
||||
_b: S::Buffer,
|
||||
}
|
||||
|
||||
fn coerce<const N: usize>(this: &Wrap<Array<N>>) -> &Wrap<Slice>
|
||||
where
|
||||
Array<N>: Storage,
|
||||
{
|
||||
coerce_again(this)
|
||||
}
|
||||
|
||||
fn coerce_again<const N: usize>(this: &Wrap<Array<N>>) -> &Wrap<Slice> {
|
||||
this
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let inner: Wrap<Array<1>> = Wrap { _b: [(); 1] };
|
||||
let _: &Wrap<Slice> = coerce(&inner);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue