Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
};

// sort the errors by span, for better error message stability.
errors.sort_by_key(|u| match *u {
RegionResolutionError::ConcreteFailure(ref sro, _, _) => sro.span(),
RegionResolutionError::GenericBoundFailure(ref sro, _, _) => sro.span(),
RegionResolutionError::SubSupConflict(_, ref rvo, _, _, _, _, _) => rvo.span(),
RegionResolutionError::UpperBoundUniverseConflict(_, ref rvo, _, _, _) => rvo.span(),
});
errors.sort_by_key(|u| u.span());
errors
}

Expand Down
26 changes: 25 additions & 1 deletion compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub enum RegionResolutionError<'tcx> {
/// `o` requires that `a <= b`, but this does not hold
ConcreteFailure(SubregionOrigin<'tcx>, Region<'tcx>, Region<'tcx>),

/// `GenericBoundFailure(p, s, a)
/// `GenericBoundFailure(p, s, a)`:
///
/// The parameter/associated-type `p` must be known to outlive the lifetime
/// `a` (but none of the known bounds are sufficient).
Expand Down Expand Up @@ -113,6 +113,30 @@ pub enum RegionResolutionError<'tcx> {
),
}

impl<'tcx> RegionResolutionError<'tcx> {
pub fn span(&self) -> Span {
match self {
RegionResolutionError::ConcreteFailure(sro, _, _) => sro.span(),
RegionResolutionError::GenericBoundFailure(sro, _, _) => sro.span(),
RegionResolutionError::SubSupConflict(_, rvo, _, _, _, _, _) => rvo.span(),
RegionResolutionError::UpperBoundUniverseConflict(_, rvo, _, _, _) => rvo.span(),
}
}
}

impl<'tcx> RegionResolutionError<'tcx> {
pub fn as_bound(&self) -> String {
match self {
RegionResolutionError::ConcreteFailure(_, a, b) => format!("{}: {}", b, a),
RegionResolutionError::GenericBoundFailure(_, a, b) => format!("{}: {}", b, a),
RegionResolutionError::SubSupConflict(_, _, _, sub_r, _, sup_r, _) => {
format!("{}: {}", sup_r, sub_r)
}
RegionResolutionError::UpperBoundUniverseConflict(_, _, _, _, _) => unimplemented!(),
}
}
}

struct RegionAndOrigin<'tcx> {
region: Region<'tcx>,
origin: SubregionOrigin<'tcx>,
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,10 @@ impl<'tcx> TyCtxt<'tcx> {
ty::EarlyBinder(self.type_of(def_id))
}

pub fn bound_param_env(self, def_id: DefId) -> ty::EarlyBinder<ty::ParamEnv<'tcx>> {
ty::EarlyBinder(self.param_env(def_id))
}

pub fn bound_fn_sig(self, def_id: DefId) -> ty::EarlyBinder<ty::PolyFnSig<'tcx>> {
ty::EarlyBinder(self.fn_sig(def_id))
}
Expand Down
Loading