mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Auto merge of #14837 - Veykril:rustc-lexer, r=Veykril
Support c string literals
This commit is contained in:
commit
9ce95674e8
24 changed files with 374 additions and 155 deletions
|
@ -13,7 +13,7 @@ use hir_def::{
|
|||
hir::{
|
||||
ArithOp, Array, BinaryOp, ClosureKind, Expr, ExprId, LabelId, Literal, Statement, UnaryOp,
|
||||
},
|
||||
lang_item::LangItem,
|
||||
lang_item::{LangItem, LangItemTarget},
|
||||
path::{GenericArg, GenericArgs},
|
||||
BlockId, ConstParamId, FieldId, ItemContainerId, Lookup,
|
||||
};
|
||||
|
@ -832,6 +832,20 @@ impl<'a> InferenceContext<'a> {
|
|||
let array_type = TyKind::Array(byte_type, len).intern(Interner);
|
||||
TyKind::Ref(Mutability::Not, static_lifetime(), array_type).intern(Interner)
|
||||
}
|
||||
Literal::CString(..) => TyKind::Ref(
|
||||
Mutability::Not,
|
||||
static_lifetime(),
|
||||
self.resolve_lang_item(LangItem::CStr)
|
||||
.and_then(LangItemTarget::as_struct)
|
||||
.map_or_else(
|
||||
|| self.err_ty(),
|
||||
|strukt| {
|
||||
TyKind::Adt(AdtId(strukt.into()), Substitution::empty(Interner))
|
||||
.intern(Interner)
|
||||
},
|
||||
),
|
||||
)
|
||||
.intern(Interner),
|
||||
Literal::Char(..) => TyKind::Scalar(Scalar::Char).intern(Interner),
|
||||
Literal::Int(_v, ty) => match ty {
|
||||
Some(int_ty) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue