-
Notifications
You must be signed in to change notification settings - Fork 183
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 f9f89c5
Showing
9 changed files
with
94 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,31 @@ | ||
use crate::clauses::ClauseBuilder; | ||
use crate::rust_ir::WellKnownTrait; | ||
use crate::{Interner, RustIrDatabase, TraitRef}; | ||
use chalk_ir::{Floundered, Substitution, Ty, TyKind}; | ||
|
||
/// Add implicit impls of the generator trait, i.e., add a clause that all generators implement | ||
/// `Generator` and clauses for `Generator`'s associated types. | ||
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(()) | ||
} | ||
|
||
// Generator 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