use rustc::bug;
use rustc_data_structures::thin_vec::ThinVec;
use rustc_error_codes::*;
+use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
use syntax::ast::*;
use syntax::attr;
use syntax::ptr::P as AstP;
-use syntax::{span_err, struct_span_err};
impl<'hir> LoweringContext<'_, 'hir> {
fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] {
ExprKind::Mac(_) => panic!("Shouldn't exist here"),
};
- hir::Expr { hir_id: self.lower_node_id(e.id), kind, span: e.span, attrs: e.attrs.clone() }
+ hir::Expr {
+ hir_id: self.lower_node_id(e.id),
+ kind,
+ span: e.span,
+ attrs: e.attrs.iter().map(|a| self.lower_attr(a)).collect::<Vec<_>>().into(),
+ }
}
fn lower_unop(&mut self, u: UnOp) -> hir::UnOp {
match generator_kind {
Some(hir::GeneratorKind::Gen) => {
if !decl.inputs.is_empty() {
- span_err!(
+ struct_span_err!(
self.sess,
fn_decl_span,
E0628,
"generators cannot have explicit parameters"
- );
+ )
+ .emit();
}
Some(movability)
}
}
None => {
if movability == Movability::Static {
- span_err!(self.sess, fn_decl_span, E0697, "closures cannot be static");
+ struct_span_err!(self.sess, fn_decl_span, E0697, "closures cannot be static")
+ .emit();
}
None
}
fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind<'hir> {
let inner = hir::InlineAsmInner {
- inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
+ inputs: asm.inputs.iter().map(|&(c, _)| c).collect(),
outputs: asm
.outputs
.iter()
.map(|out| hir::InlineAsmOutput {
- constraint: out.constraint.clone(),
+ constraint: out.constraint,
is_rw: out.is_rw,
is_indirect: out.is_indirect,
span: out.expr.span,
})
.collect(),
- asm: asm.asm.clone(),
+ asm: asm.asm,
asm_str_style: asm.asm_str_style,
clobbers: asm.clobbers.clone().into(),
volatile: asm.volatile,
match self.generator_kind {
Some(hir::GeneratorKind::Gen) => {}
Some(hir::GeneratorKind::Async(_)) => {
- span_err!(self.sess, span, E0727, "`async` generators are not yet supported",);
+ struct_span_err!(
+ self.sess,
+ span,
+ E0727,
+ "`async` generators are not yet supported"
+ )
+ .emit();
return hir::ExprKind::Err;
}
None => self.generator_kind = Some(hir::GeneratorKind::Gen),