//! instance of `AstConv`.
use crate::collect::PlaceholderHirTyCollector;
-use crate::hir::def::{CtorOf, DefKind, Res};
-use crate::hir::def_id::DefId;
-use crate::hir::intravisit::Visitor;
-use crate::hir::print;
-use crate::hir::{self, ExprKind, GenericArg, GenericArgs};
use crate::lint;
use crate::middle::lang_items::SizedTraitLangItem;
use crate::middle::resolve_lifetime as rl;
use crate::namespace::Namespace;
use crate::require_c_abi_if_c_variadic;
use crate::util::common::ErrorReported;
-use errors::{Applicability, DiagnosticId};
+use errors::{struct_span_err, Applicability, DiagnosticId};
use rustc::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS;
use rustc::traits;
+use rustc::traits::astconv_object_safety_violations;
+use rustc::traits::error_reporting::report_object_safety_error;
+use rustc::traits::wf::object_region_bounds;
use rustc::ty::subst::{self, InternalSubsts, Subst, SubstsRef};
-use rustc::ty::wf::object_region_bounds;
use rustc::ty::{self, Const, DefIdTree, ToPredicate, Ty, TyCtxt, TypeFoldable};
use rustc::ty::{GenericParamDef, GenericParamDefKind};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_hir as hir;
+use rustc_hir::def::{CtorOf, DefKind, Res};
+use rustc_hir::def_id::DefId;
+use rustc_hir::intravisit::Visitor;
+use rustc_hir::print;
+use rustc_hir::{ExprKind, GenericArg, GenericArgs};
use rustc_span::symbol::sym;
use rustc_span::{MultiSpan, Span, DUMMY_SP};
use rustc_target::spec::abi;
if unbound.is_none() {
unbound = Some(&ptr.trait_ref);
} else {
- span_err!(
+ struct_span_err!(
tcx.sess,
span,
E0203,
"type parameter has more than one relaxed default \
bound, only one is supported"
- );
+ )
+ .emit();
}
}
}
}
if regular_traits.is_empty() && auto_traits.is_empty() {
- span_err!(tcx.sess, span, E0224, "at least one trait is required for an object type");
+ struct_span_err!(
+ tcx.sess,
+ span,
+ E0224,
+ "at least one trait is required for an object type"
+ )
+ .emit();
return tcx.types.err;
}
// to avoid ICEs.
for item in ®ular_traits {
let object_safety_violations =
- tcx.astconv_object_safety_violations(item.trait_ref().def_id());
+ astconv_object_safety_violations(tcx, item.trait_ref().def_id());
if !object_safety_violations.is_empty() {
- tcx.report_object_safety_error(
+ report_object_safety_error(
+ tcx,
span,
item.trait_ref().def_id(),
object_safety_violations,
self.ast_region_to_region(lifetime, None)
} else {
self.re_infer(None, span).unwrap_or_else(|| {
- span_err!(
+ struct_span_err!(
tcx.sess,
span,
E0228,
"the lifetime bound for this object type cannot be deduced \
from context; please supply an explicit bound"
- );
+ )
+ .emit();
tcx.lifetimes.re_static
})
}
assert_eq!(opt_self_ty, None);
self.prohibit_generics(path.segments);
match prim_ty {
- hir::Bool => tcx.types.bool,
- hir::Char => tcx.types.char,
- hir::Int(it) => tcx.mk_mach_int(it),
- hir::Uint(uit) => tcx.mk_mach_uint(uit),
- hir::Float(ft) => tcx.mk_mach_float(ft),
- hir::Str => tcx.mk_str(),
+ hir::PrimTy::Bool => tcx.types.bool,
+ hir::PrimTy::Char => tcx.types.char,
+ hir::PrimTy::Int(it) => tcx.mk_mach_int(it),
+ hir::PrimTy::Uint(uit) => tcx.mk_mach_uint(uit),
+ hir::PrimTy::Float(ft) => tcx.mk_mach_float(ft),
+ hir::PrimTy::Str => tcx.mk_str(),
}
}
Res::Err => {
}
let input_tys = decl.inputs.iter().map(|a| self.ty_of_arg(a, None));
let output_ty = match decl.output {
- hir::Return(ref output) => {
+ hir::FunctionRetTy::Return(ref output) => {
visitor.visit_ty(output);
self.ast_ty_to_ty(output)
}
- hir::DefaultReturn(..) => tcx.mk_unit(),
+ hir::FunctionRetTy::DefaultReturn(..) => tcx.mk_unit(),
};
debug!("ty_of_fn: output_ty={:?}", output_ty);
// error.
let r = derived_region_bounds[0];
if derived_region_bounds[1..].iter().any(|r1| r != *r1) {
- span_err!(
+ struct_span_err!(
tcx.sess,
span,
E0227,
"ambiguous lifetime bound, explicit lifetime bound required"
- );
+ )
+ .emit();
}
return Some(r);
}