-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cadaba9
commit 2b6065f
Showing
9 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::clauses::ClauseBuilder; | ||
use crate::rust_ir::WellKnownTrait; | ||
use crate::{Interner, RustIrDatabase, TraitRef}; | ||
use chalk_ir::{Floundered, Substitution, Ty, TyKind}; | ||
|
||
/// Add implicit impl for the `Tuple` trait for all tuples | ||
pub fn add_tuple_program_clauses<I: Interner>( | ||
db: &dyn RustIrDatabase<I>, | ||
builder: &mut ClauseBuilder<'_, I>, | ||
self_ty: Ty<I>, | ||
) -> Result<(), Floundered> { | ||
let interner = db.interner(); | ||
|
||
match self_ty.kind(interner) { | ||
TyKind::Tuple(..) => { | ||
let trait_id = db.well_known_trait_id(WellKnownTrait::Tuple).unwrap(); | ||
|
||
builder.push_fact(TraitRef { | ||
trait_id, | ||
substitution: Substitution::from1(interner, self_ty), | ||
}); | ||
|
||
Ok(()) | ||
} | ||
|
||
// Tuple trait is non-enumerable | ||
TyKind::InferenceVar(..) | TyKind::BoundVar(_) | TyKind::Alias(..) => Err(Floundered), | ||
_ => Ok(()), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters