Have the spans of TAIT type conflict errors point to the actual site instead of the owning function
This commit is contained in:
parent
4b249b062b
commit
d5b6510bfb
37 changed files with 180 additions and 187 deletions
|
@ -1,7 +1,7 @@
|
|||
//! Values computed by queries that use MIR.
|
||||
|
||||
use crate::mir::{Body, Promoted};
|
||||
use crate::ty::{self, Ty, TyCtxt};
|
||||
use crate::ty::{self, OpaqueHiddenType, Ty, TyCtxt};
|
||||
use rustc_data_structures::stable_map::FxHashMap;
|
||||
use rustc_data_structures::vec_map::VecMap;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
|
@ -242,7 +242,7 @@ pub struct BorrowCheckResult<'tcx> {
|
|||
/// All the opaque types that are restricted to concrete types
|
||||
/// by this function. Unlike the value in `TypeckResults`, this has
|
||||
/// unerased regions.
|
||||
pub concrete_opaque_types: VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>>,
|
||||
pub concrete_opaque_types: VecMap<OpaqueTypeKey<'tcx>, OpaqueHiddenType<'tcx>>,
|
||||
pub closure_requirements: Option<ClosureRegionRequirements<'tcx>>,
|
||||
pub used_mut_upvars: SmallVec<[Field; 8]>,
|
||||
pub tainted_by_errors: Option<ErrorGuaranteed>,
|
||||
|
|
|
@ -1081,6 +1081,38 @@ pub struct OpaqueTypeKey<'tcx> {
|
|||
pub substs: SubstsRef<'tcx>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, TypeFoldable, HashStable, TyEncodable, TyDecodable)]
|
||||
pub struct OpaqueHiddenType<'tcx> {
|
||||
/// The span of this particular definition of the opaque type. So
|
||||
/// for example:
|
||||
///
|
||||
/// ```ignore (incomplete snippet)
|
||||
/// type Foo = impl Baz;
|
||||
/// fn bar() -> Foo {
|
||||
/// // ^^^ This is the span we are looking for!
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// In cases where the fn returns `(impl Trait, impl Trait)` or
|
||||
/// other such combinations, the result is currently
|
||||
/// over-approximated, but better than nothing.
|
||||
pub span: Span,
|
||||
|
||||
/// The type variable that represents the value of the opaque type
|
||||
/// that we require. In other words, after we compile this function,
|
||||
/// we will be created a constraint like:
|
||||
///
|
||||
/// Foo<'a, T> = ?C
|
||||
///
|
||||
/// where `?C` is the value of this type variable. =) It may
|
||||
/// naturally refer to the type and lifetime parameters in scope
|
||||
/// in this function, though ultimately it should only reference
|
||||
/// those that are arguments to `Foo` in the constraint above. (In
|
||||
/// other words, `?C` should not include `'b`, even though it's a
|
||||
/// lifetime parameter on `foo`.)
|
||||
pub ty: Ty<'tcx>,
|
||||
}
|
||||
|
||||
rustc_index::newtype_index! {
|
||||
/// "Universes" are used during type- and trait-checking in the
|
||||
/// presence of `for<..>` binders to control what sets of names are
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue