Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/next_solver/infer/traits.rs')
-rw-r--r--crates/hir-ty/src/next_solver/infer/traits.rs34
1 files changed, 5 insertions, 29 deletions
diff --git a/crates/hir-ty/src/next_solver/infer/traits.rs b/crates/hir-ty/src/next_solver/infer/traits.rs
index 523c94b36f..12a6652bf7 100644
--- a/crates/hir-ty/src/next_solver/infer/traits.rs
+++ b/crates/hir-ty/src/next_solver/infer/traits.rs
@@ -27,13 +27,6 @@ use crate::{
use super::InferCtxt;
/// The reason why we incurred this obligation; used for error reporting.
-///
-/// Non-misc `ObligationCauseCode`s are stored on the heap. This gives the
-/// best trade-off between keeping the type small (which makes copies cheaper)
-/// while not doing too many heap allocations.
-///
-/// We do not want to intern this as there are a lot of obligation causes which
-/// only live for a short period of time.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct ObligationCause {
span: Span,
@@ -41,23 +34,13 @@ pub struct ObligationCause {
impl ObligationCause {
#[inline]
- pub fn new() -> ObligationCause {
- ObligationCause { span: Span::Dummy }
- }
-
- #[inline]
- pub fn with_span(span: Span) -> ObligationCause {
- ObligationCause { span }
+ pub fn new<S: Into<Span>>(span: S) -> ObligationCause {
+ ObligationCause { span: span.into() }
}
#[inline]
pub fn dummy() -> ObligationCause {
- ObligationCause::new()
- }
-
- #[inline]
- pub fn misc() -> ObligationCause {
- ObligationCause::new()
+ ObligationCause::new(Span::Dummy)
}
#[inline]
@@ -66,13 +49,6 @@ impl ObligationCause {
}
}
-impl Default for ObligationCause {
- #[inline]
- fn default() -> Self {
- Self::new()
- }
-}
-
/// An `Obligation` represents some trait reference (e.g., `i32: Eq`) for
/// which the "impl_source" must be found. The process of finding an "impl_source" is
/// called "resolving" the `Obligation`. This process consists of
@@ -128,11 +104,11 @@ impl<'db> Elaboratable<DbInterner<'db>> for PredicateObligation<'db> {
fn child_with_derived_cause(
&self,
clause: Clause<'db>,
- _span: Span,
+ span: Span,
_parent_trait_pred: PolyTraitPredicate<'db>,
_index: usize,
) -> Self {
- let cause = ObligationCause::new();
+ let cause = ObligationCause::new(span);
Obligation {
cause,
param_env: self.param_env,