}
ty::Str => p!("str"),
ty::Generator(did, substs, movability) => {
- // FIXME(swatinem): async constructs used to be pretty printed
- // as `impl Future` previously due to the `from_generator` wrapping.
- // lets special case this here for now to avoid churn in diagnostics.
- let generator_kind = self.tcx().generator_kind(did);
- if matches!(generator_kind, Some(hir::GeneratorKind::Async(..))) {
- let return_ty = substs.as_generator().return_ty();
- p!(write("impl Future<Output = {}>", return_ty));
-
- return Ok(self);
- }
-
p!(write("["));
- match movability {
- hir::Movability::Movable => {}
- hir::Movability::Static => p!("static "),
+ let generator_kind = self.tcx().generator_kind(did).unwrap();
+ let should_print_movability =
+ self.should_print_verbose() || generator_kind == hir::GeneratorKind::Gen;
+
+ if should_print_movability {
+ match movability {
+ hir::Movability::Movable => {}
+ hir::Movability::Static => p!("static "),
+ }
}
if !self.should_print_verbose() {
- p!("generator");
+ p!(write("{}", generator_kind));
// FIXME(eddyb) should use `def_span`.
if let Some(did) = did.as_local() {
let span = self.tcx().def_span(did);
let bound_predicate = predicate.kind();
match bound_predicate.skip_binder() {
- ty::PredicateKind::Trait(pred) => {
+ ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
let trait_ref = bound_predicate.rebind(pred.trait_ref);
// Don't print + Sized, but rather + ?Sized if absent.
self.insert_trait_and_projection(trait_ref, None, &mut traits, &mut fn_traits);
}
- ty::PredicateKind::Projection(pred) => {
+ ty::PredicateKind::Clause(ty::Clause::Projection(pred)) => {
let proj_ref = bound_predicate.rebind(pred);
let trait_ref = proj_ref.required_poly_trait_ref(tcx);
&mut fn_traits,
);
}
- ty::PredicateKind::TypeOutlives(outlives) => {
+ ty::PredicateKind::Clause(ty::Clause::TypeOutlives(outlives)) => {
lifetimes.push(outlives.1);
}
_ => {}
let mut resugared = false;
// Special-case `Fn(...) -> ...` and re-sugar it.
- let fn_trait_kind = cx.tcx().fn_trait_kind_from_lang_item(principal.def_id);
+ let fn_trait_kind = cx.tcx().fn_trait_kind_from_def_id(principal.def_id);
if !cx.should_print_verbose() && fn_trait_kind.is_some() {
if let ty::Tuple(tys) = principal.substs.type_at(0).kind() {
let mut projections = predicates.projection_bounds();
self.pretty_print_bound_var(debruijn, bound_var)?
}
ty::ConstKind::Placeholder(placeholder) => p!(write("Placeholder({:?})", placeholder)),
+ // FIXME(generic_const_exprs):
+ // write out some legible representation of an abstract const?
+ ty::ConstKind::Expr(_) => p!("[Const Expr]"),
ty::ConstKind::Error(_) => p!("[const error]"),
};
Ok(self)
}
// Aggregates, printed as array/tuple/struct/variant construction syntax.
(ty::ValTree::Branch(_), ty::Array(..) | ty::Tuple(..) | ty::Adt(..)) => {
- let contents =
- self.tcx().destructure_const(ty::Const::from_value(self.tcx(), valtree, ty));
+ let contents = self.tcx().destructure_const(self.tcx().mk_const(valtree, ty));
let fields = contents.fields.iter().copied();
match *ty.kind() {
ty::Array(..) => {
let identify_regions = self.tcx.sess.opts.unstable_opts.identify_regions;
match *region {
- ty::ReEarlyBound(ref data) => {
- data.name != kw::Empty && data.name != kw::UnderscoreLifetime
- }
+ ty::ReEarlyBound(ref data) => data.has_name(),
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. })
| ty::ReFree(ty::FreeRegion { bound_region: br, .. })
| ty::RePlaceholder(ty::Placeholder { name: br, .. }) => {
- if let ty::BrNamed(_, name) = br {
- if name != kw::Empty && name != kw::UnderscoreLifetime {
- return true;
- }
+ if br.is_named() {
+ return true;
}
if let Some((region, _)) = highlight.highlight_bound_region {
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. })
| ty::ReFree(ty::FreeRegion { bound_region: br, .. })
| ty::RePlaceholder(ty::Placeholder { name: br, .. }) => {
- if let ty::BrNamed(_, name) = br {
- if name != kw::Empty && name != kw::UnderscoreLifetime {
- p!(write("{}", name));
- return Ok(self);
- }
+ if let ty::BrNamed(_, name) = br && br.is_named() {
+ p!(write("{}", name));
+ return Ok(self);
}
if let Some((region, counter)) = highlight.highlight_bound_region {
(name, ty::BrNamed(CRATE_DEF_ID.to_def_id(), name))
}
- ty::BrNamed(def_id, kw::UnderscoreLifetime) => {
+ ty::BrNamed(def_id, kw::UnderscoreLifetime | kw::Empty) => {
let name = next_name(&self);
if let Some(lt_idx) = lifetime_idx {
ty::PredicateKind<'tcx> {
match *self {
- ty::PredicateKind::Trait(ref data) => {
+ ty::PredicateKind::Clause(ty::Clause::Trait(ref data)) => {
p!(print(data))
}
ty::PredicateKind::Subtype(predicate) => p!(print(predicate)),
ty::PredicateKind::Coerce(predicate) => p!(print(predicate)),
- ty::PredicateKind::RegionOutlives(predicate) => p!(print(predicate)),
- ty::PredicateKind::TypeOutlives(predicate) => p!(print(predicate)),
- ty::PredicateKind::Projection(predicate) => p!(print(predicate)),
+ ty::PredicateKind::Clause(ty::Clause::RegionOutlives(predicate)) => p!(print(predicate)),
+ ty::PredicateKind::Clause(ty::Clause::TypeOutlives(predicate)) => p!(print(predicate)),
+ ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) => p!(print(predicate)),
ty::PredicateKind::WellFormed(arg) => p!(print(arg), " well-formed"),
ty::PredicateKind::ObjectSafe(trait_def_id) => {
p!("the trait `", print_def_path(trait_def_id, &[]), "` is object-safe")