1
Fork 0

Have the spans of TAIT type conflict errors point to the actual site instead of the owning function

This commit is contained in:
Oli Scherer 2022-02-09 16:44:17 +00:00
parent 4b249b062b
commit d5b6510bfb
37 changed files with 180 additions and 187 deletions

View file

@ -8,7 +8,9 @@ use rustc_hir as hir;
use rustc_middle::traits::ObligationCause;
use rustc_middle::ty::fold::BottomUpFolder;
use rustc_middle::ty::subst::{GenericArgKind, Subst};
use rustc_middle::ty::{self, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable, TypeVisitor};
use rustc_middle::ty::{
self, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable, TypeVisitor,
};
use rustc_span::Span;
use std::ops::ControlFlow;
@ -35,38 +37,6 @@ pub struct OpaqueTypeDecl<'tcx> {
pub origin: hir::OpaqueTyOrigin,
}
#[derive(Copy, Clone, Debug, TypeFoldable)]
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>,
}
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn handle_opaque_type(
&self,

View file

@ -1,11 +1,11 @@
use rustc_data_structures::undo_log::UndoLogs;
use rustc_hir::OpaqueTyOrigin;
use rustc_middle::ty::{self, OpaqueTypeKey, Ty};
use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty};
use rustc_span::DUMMY_SP;
use crate::infer::{InferCtxtUndoLogs, UndoLog};
use super::{OpaqueHiddenType, OpaqueTypeDecl, OpaqueTypeMap};
use super::{OpaqueTypeDecl, OpaqueTypeMap};
#[derive(Default, Debug, Clone)]
pub struct OpaqueTypeStorage<'tcx> {

View file

@ -4,15 +4,13 @@ use rustc_data_structures::snapshot_vec as sv;
use rustc_data_structures::undo_log::{Rollback, UndoLogs};
use rustc_data_structures::unify as ut;
use rustc_middle::infer::unify_key::RegionVidKey;
use rustc_middle::ty::{self, OpaqueTypeKey};
use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey};
use crate::{
infer::{region_constraints, type_variable, InferCtxtInner},
traits,
};
use super::opaque_types::OpaqueHiddenType;
pub struct Snapshot<'tcx> {
pub(crate) undo_len: usize,
_marker: PhantomData<&'tcx ()>,