mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-28 03:07:24 +03:00
Remember whether a struct literal had syntax errors.
This adds a variant `NoneWithError` to AST and HIR representations of the “rest” or “tail”, which is currently always treated identically to the `None` variant.
This commit is contained in:
@@ -242,7 +242,7 @@ fn has_no_effect(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
||||
!expr_ty_has_significant_drop(cx, expr)
|
||||
&& fields.iter().all(|field| has_no_effect(cx, field.expr))
|
||||
&& match &base {
|
||||
StructTailExpr::None | StructTailExpr::DefaultFields(_) => true,
|
||||
StructTailExpr::None | StructTailExpr::NoneWithError(_) | StructTailExpr::DefaultFields(_) => true,
|
||||
StructTailExpr::Base(base) => has_no_effect(cx, base),
|
||||
}
|
||||
},
|
||||
@@ -353,7 +353,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option<Vec
|
||||
} else {
|
||||
let base = match base {
|
||||
StructTailExpr::Base(base) => Some(base),
|
||||
StructTailExpr::None | StructTailExpr::DefaultFields(_) => None,
|
||||
StructTailExpr::None | StructTailExpr::NoneWithError(_) | StructTailExpr::DefaultFields(_) => None,
|
||||
};
|
||||
Some(fields.iter().map(|f| &f.expr).chain(base).map(Deref::deref).collect())
|
||||
}
|
||||
|
||||
@@ -673,7 +673,7 @@ macro_rules! kind {
|
||||
bind!(self, qpath, fields);
|
||||
let base = OptionPat::new(match base {
|
||||
StructTailExpr::Base(base) => Some(self.bind("base", base)),
|
||||
StructTailExpr::None | StructTailExpr::DefaultFields(_) => None,
|
||||
StructTailExpr::None | StructTailExpr::NoneWithError(_) | StructTailExpr::DefaultFields(_) => None,
|
||||
});
|
||||
kind!("Struct({qpath}, {fields}, {base})");
|
||||
self.qpath(qpath, &expr.name, expr.value.hir_id);
|
||||
|
||||
Reference in New Issue
Block a user