1
Fork 0

Auto merge of #119000 - celinval:smir-cstr, r=ouz-a

Add a method to StableMIR to check if a type is a CStr

Also add a check that StableMIR works properly with C string literal.
This commit is contained in:
bors 2023-12-17 08:18:17 +00:00
commit 9f13b9d9ca
4 changed files with 37 additions and 0 deletions

View file

@ -219,6 +219,12 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
def.internal(&mut *tables).repr().simd()
}
fn adt_is_cstr(&self, def: AdtDef) -> bool {
let mut tables = self.0.borrow_mut();
let def_id = def.0.internal(&mut *tables);
tables.tcx.lang_items().c_str() == Some(def_id)
}
fn fn_sig(&self, def: FnDef, args: &GenericArgs) -> PolyFnSig {
let mut tables = self.0.borrow_mut();
let def_id = def.0.internal(&mut *tables);