Auto merge of #118982 - matthiaskrgr:rollup-xoraxf4, r=matthiaskrgr

Rollup of 3 pull requests

Successful merges:

 - #118962 (Annotate some bugs)
 - #118969 (coverage: Use `Waker::noop` in async tests)
 - #118974 (Annotate panic! reasons during enum layout)

Failed merges:

 - #111658 (Refactor pre-getopts command line argument handling)
 - #117449 (Avoid silencing relevant follow-up errors)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2023-12-15 15:01:55 +00:00
commit e6707df0de
51 changed files with 467 additions and 582 deletions

View File

@ -382,7 +382,7 @@ pub trait LayoutCalculator {
*offset += this_offset;
}
}
_ => {
FieldsShape::Primitive | FieldsShape::Array { .. } | FieldsShape::Union(..) => {
panic!("Layout of fields should be Arbitrary for variants")
}
}
@ -600,7 +600,9 @@ pub trait LayoutCalculator {
variant.size = new_ity_size;
}
}
_ => panic!(),
FieldsShape::Primitive | FieldsShape::Array { .. } | FieldsShape::Union(..) => {
panic!("encountered a non-arbitrary layout during enum layout")
}
}
}
}
@ -628,7 +630,7 @@ pub trait LayoutCalculator {
let mut common_prim_initialized_in_all_variants = true;
for (field_layouts, layout_variant) in iter::zip(variants, &layout_variants) {
let FieldsShape::Arbitrary { ref offsets, .. } = layout_variant.fields else {
panic!();
panic!("encountered a non-arbitrary layout during enum layout");
};
// We skip *all* ZST here and later check if we are good in terms of alignment.
// This lets us handle some cases involving aligned ZST.
@ -681,7 +683,7 @@ pub trait LayoutCalculator {
assert_eq!(memory_index.raw, [0, 1]);
offsets
}
_ => panic!(),
_ => panic!("encountered a non-arbitrary layout during enum layout"),
};
if pair_offsets[FieldIdx::new(0)] == Size::ZERO
&& pair_offsets[FieldIdx::new(1)] == *offset
@ -758,7 +760,9 @@ pub trait LayoutCalculator {
Variants::Multiple { tag, tag_encoding, tag_field, .. } => {
Variants::Multiple { tag, tag_encoding, tag_field, variants: best_layout.variants }
}
_ => panic!(),
Variants::Single { .. } => {
panic!("encountered a single-variant enum during multi-variant layout")
}
};
Some(best_layout.layout)
}
@ -1154,7 +1158,11 @@ fn univariant<
assert_eq!(memory_index.raw, [0, 1]);
offsets
}
_ => panic!(),
FieldsShape::Primitive
| FieldsShape::Array { .. }
| FieldsShape::Union(..) => {
panic!("encountered a non-arbitrary layout during enum layout")
}
};
if offsets[i] == pair_offsets[FieldIdx::new(0)]
&& offsets[j] == pair_offsets[FieldIdx::new(1)]

View File

@ -336,7 +336,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
hir::InlineAsmOperand::Const { .. }
| hir::InlineAsmOperand::SymFn { .. }
| hir::InlineAsmOperand::SymStatic { .. } => {
unreachable!()
unreachable!("{op:?} is not a register operand");
}
};
@ -380,7 +380,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
{
reg_sym.as_str()
} else {
unreachable!();
unreachable!("{op:?} is not a register operand");
}
};

View File

@ -421,8 +421,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
ItemKind::MacroDef(MacroDef { body, macro_rules }) => {
let body = P(self.lower_delim_args(body));
let DefKind::Macro(macro_kind) = self.tcx.def_kind(self.local_def_id(id)) else {
unreachable!()
let def_id = self.local_def_id(id);
let def_kind = self.tcx.def_kind(def_id);
let DefKind::Macro(macro_kind) = def_kind else {
unreachable!(
"expected DefKind::Macro for macro item, found {}",
def_kind.descr(def_id.to_def_id())
);
};
let macro_def = self.arena.alloc(ast::MacroDef { body, macro_rules: *macro_rules });
hir::ItemKind::Macro(macro_def, macro_kind)

View File

@ -2815,7 +2815,7 @@ impl TraitRef<'_> {
match self.path.res {
Res::Def(DefKind::Trait | DefKind::TraitAlias, did) => Some(did),
Res::Err => None,
_ => unreachable!(),
res => panic!("{res:?} did not resolve to a trait or trait alias"),
}
}
}

View File

@ -477,7 +477,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
ty::Const::new_misc_error(tcx, ty).into()
}
}
_ => unreachable!(),
(kind, arg) => span_bug!(
self.span,
"mismatched path argument for kind {kind:?}: found arg {arg:?}"
),
}
}
@ -1946,7 +1949,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
"s",
),
[only] => (only.to_string(), ""),
[] => unreachable!(),
[] => unreachable!("expected at least one generic to prohibit"),
};
let last_span = *arg_spans.last().unwrap();
let span: MultiSpan = arg_spans.into();
@ -2555,8 +2558,19 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
if let Some(i) = (param.index as usize).checked_sub(generics.count() - lifetimes.len())
{
// Resolve our own lifetime parameters.
let GenericParamDefKind::Lifetime { .. } = param.kind else { bug!() };
let hir::GenericArg::Lifetime(lifetime) = &lifetimes[i] else { bug!() };
let GenericParamDefKind::Lifetime { .. } = param.kind else {
span_bug!(
tcx.def_span(param.def_id),
"only expected lifetime for opaque's own generics, got {:?}",
param.kind
);
};
let hir::GenericArg::Lifetime(lifetime) = &lifetimes[i] else {
bug!(
"expected lifetime argument for param {param:?}, found {:?}",
&lifetimes[i]
)
};
self.ast_region_to_region(lifetime, None).into()
} else {
tcx.mk_param_from_def(param)

View File

@ -73,7 +73,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
| ty::ClauseKind::ConstArgHasType(..)
| ty::ClauseKind::WellFormed(_)
| ty::ClauseKind::ConstEvaluatable(_) => {
bug!()
span_bug!(span, "did not expect {pred} clause in object bounds");
}
}
}

View File

@ -1086,8 +1086,14 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
_ => return Ok(region),
}
let e = if let Some(region) = self.map.get(&region) {
if let ty::ReEarlyParam(e) = region.kind() { e } else { bug!() }
let e = if let Some(id_region) = self.map.get(&region) {
if let ty::ReEarlyParam(e) = id_region.kind() {
e
} else {
bug!(
"expected to map region {region} to early-bound identity region, but got {id_region}"
);
}
} else {
let guar = match region.kind() {
ty::ReEarlyParam(ty::EarlyParamRegion { def_id, .. })
@ -1710,92 +1716,87 @@ fn compare_synthetic_generics<'tcx>(
trait_m.name
);
err.span_label(trait_span, "declaration in trait here");
match (impl_synthetic, trait_synthetic) {
if impl_synthetic {
// The case where the impl method uses `impl Trait` but the trait method uses
// explicit generics
(true, false) => {
err.span_label(impl_span, "expected generic parameter, found `impl Trait`");
let _: Option<_> = try {
// try taking the name from the trait impl
// FIXME: this is obviously suboptimal since the name can already be used
// as another generic argument
let new_name = tcx.opt_item_name(trait_def_id)?;
let trait_m = trait_m.def_id.as_local()?;
let trait_m = tcx.hir().expect_trait_item(trait_m);
err.span_label(impl_span, "expected generic parameter, found `impl Trait`");
let _: Option<_> = try {
// try taking the name from the trait impl
// FIXME: this is obviously suboptimal since the name can already be used
// as another generic argument
let new_name = tcx.opt_item_name(trait_def_id)?;
let trait_m = trait_m.def_id.as_local()?;
let trait_m = tcx.hir().expect_trait_item(trait_m);
let impl_m = impl_m.def_id.as_local()?;
let impl_m = tcx.hir().expect_impl_item(impl_m);
let impl_m = impl_m.def_id.as_local()?;
let impl_m = tcx.hir().expect_impl_item(impl_m);
// in case there are no generics, take the spot between the function name
// and the opening paren of the argument list
let new_generics_span = tcx.def_ident_span(impl_def_id)?.shrink_to_hi();
// in case there are generics, just replace them
let generics_span =
impl_m.generics.span.substitute_dummy(new_generics_span);
// replace with the generics from the trait
let new_generics =
tcx.sess.source_map().span_to_snippet(trait_m.generics.span).ok()?;
// in case there are no generics, take the spot between the function name
// and the opening paren of the argument list
let new_generics_span = tcx.def_ident_span(impl_def_id)?.shrink_to_hi();
// in case there are generics, just replace them
let generics_span = impl_m.generics.span.substitute_dummy(new_generics_span);
// replace with the generics from the trait
let new_generics =
tcx.sess.source_map().span_to_snippet(trait_m.generics.span).ok()?;
err.multipart_suggestion(
"try changing the `impl Trait` argument to a generic parameter",
vec![
// replace `impl Trait` with `T`
(impl_span, new_name.to_string()),
// replace impl method generics with trait method generics
// This isn't quite right, as users might have changed the names
// of the generics, but it works for the common case
(generics_span, new_generics),
],
Applicability::MaybeIncorrect,
);
};
}
err.multipart_suggestion(
"try changing the `impl Trait` argument to a generic parameter",
vec![
// replace `impl Trait` with `T`
(impl_span, new_name.to_string()),
// replace impl method generics with trait method generics
// This isn't quite right, as users might have changed the names
// of the generics, but it works for the common case
(generics_span, new_generics),
],
Applicability::MaybeIncorrect,
);
};
} else {
// The case where the trait method uses `impl Trait`, but the impl method uses
// explicit generics.
(false, true) => {
err.span_label(impl_span, "expected `impl Trait`, found generic parameter");
let _: Option<_> = try {
let impl_m = impl_m.def_id.as_local()?;
let impl_m = tcx.hir().expect_impl_item(impl_m);
let (sig, _) = impl_m.expect_fn();
let input_tys = sig.decl.inputs;
err.span_label(impl_span, "expected `impl Trait`, found generic parameter");
let _: Option<_> = try {
let impl_m = impl_m.def_id.as_local()?;
let impl_m = tcx.hir().expect_impl_item(impl_m);
let (sig, _) = impl_m.expect_fn();
let input_tys = sig.decl.inputs;
struct Visitor(Option<Span>, hir::def_id::LocalDefId);
impl<'v> intravisit::Visitor<'v> for Visitor {
fn visit_ty(&mut self, ty: &'v hir::Ty<'v>) {
intravisit::walk_ty(self, ty);
if let hir::TyKind::Path(hir::QPath::Resolved(None, path)) = ty.kind
&& let Res::Def(DefKind::TyParam, def_id) = path.res
&& def_id == self.1.to_def_id()
{
self.0 = Some(ty.span);
}
struct Visitor(Option<Span>, hir::def_id::LocalDefId);
impl<'v> intravisit::Visitor<'v> for Visitor {
fn visit_ty(&mut self, ty: &'v hir::Ty<'v>) {
intravisit::walk_ty(self, ty);
if let hir::TyKind::Path(hir::QPath::Resolved(None, path)) = ty.kind
&& let Res::Def(DefKind::TyParam, def_id) = path.res
&& def_id == self.1.to_def_id()
{
self.0 = Some(ty.span);
}
}
}
let mut visitor = Visitor(None, impl_def_id);
for ty in input_tys {
intravisit::Visitor::visit_ty(&mut visitor, ty);
}
let span = visitor.0?;
let mut visitor = Visitor(None, impl_def_id);
for ty in input_tys {
intravisit::Visitor::visit_ty(&mut visitor, ty);
}
let span = visitor.0?;
let bounds = impl_m.generics.bounds_for_param(impl_def_id).next()?.bounds;
let bounds = bounds.first()?.span().to(bounds.last()?.span());
let bounds = tcx.sess.source_map().span_to_snippet(bounds).ok()?;
let bounds = impl_m.generics.bounds_for_param(impl_def_id).next()?.bounds;
let bounds = bounds.first()?.span().to(bounds.last()?.span());
let bounds = tcx.sess.source_map().span_to_snippet(bounds).ok()?;
err.multipart_suggestion(
"try removing the generic parameter and using `impl Trait` instead",
vec![
// delete generic parameters
(impl_m.generics.span, String::new()),
// replace param usage with `impl Trait`
(span, format!("impl {bounds}")),
],
Applicability::MaybeIncorrect,
);
};
}
_ => unreachable!(),
err.multipart_suggestion(
"try removing the generic parameter and using `impl Trait` instead",
vec![
// delete generic parameters
(impl_m.generics.span, String::new()),
// replace param usage with `impl Trait`
(span, format!("impl {bounds}")),
],
Applicability::MaybeIncorrect,
);
};
}
error_found = Some(err.emit_unless(delay));
}
@ -1859,7 +1860,9 @@ fn compare_generic_param_kinds<'tcx>(
// this is exhaustive so that anyone adding new generic param kinds knows
// to make sure this error is reported for them.
(Const { .. }, Const { .. }) | (Type { .. }, Type { .. }) => false,
(Lifetime { .. }, _) | (_, Lifetime { .. }) => unreachable!(),
(Lifetime { .. }, _) | (_, Lifetime { .. }) => {
bug!("lifetime params are expected to be filtered by `ty_const_params_of`")
}
} {
let param_impl_span = tcx.def_span(param_impl.def_id);
let param_trait_span = tcx.def_span(param_trait.def_id);
@ -1883,7 +1886,10 @@ fn compare_generic_param_kinds<'tcx>(
)
}
Type { .. } => format!("{prefix} type parameter"),
Lifetime { .. } => unreachable!(),
Lifetime { .. } => span_bug!(
tcx.def_span(param.def_id),
"lifetime params are expected to be filtered by `ty_const_params_of`"
),
};
let trait_header_span = tcx.def_ident_span(tcx.parent(trait_item.def_id)).unwrap();
@ -2187,7 +2193,10 @@ pub(super) fn check_type_bounds<'tcx>(
..
}) => ty.span,
hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Type(ty), .. }) => ty.span,
_ => bug!(),
item => span_bug!(
tcx.def_span(impl_ty_def_id),
"cannot call `check_type_bounds` on item: {item:?}",
),
}
};
let assumed_wf_types = ocx.assumed_wf_types_and_report_errors(param_env, impl_ty_def_id)?;

View File

@ -262,7 +262,10 @@ fn report_mismatched_rpitit_signature<'tcx>(
if tcx.asyncness(impl_m_def_id).is_async() && tcx.asyncness(trait_m_def_id).is_async() {
let ty::Alias(ty::Projection, future_ty) = return_ty.kind() else {
bug!();
span_bug!(
tcx.def_span(trait_m_def_id),
"expected return type of async fn in trait to be a AFIT projection"
);
};
let Some(future_output_ty) = tcx
.explicit_item_bounds(future_ty.def_id)
@ -272,7 +275,7 @@ fn report_mismatched_rpitit_signature<'tcx>(
_ => None,
})
else {
bug!()
span_bug!(tcx.def_span(trait_m_def_id), "expected `Future` projection bound in AFIT");
};
return_ty = future_output_ty;
}

View File

@ -49,7 +49,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
16 => InlineAsmType::I16,
32 => InlineAsmType::I32,
64 => InlineAsmType::I64,
_ => unreachable!(),
width => bug!("unsupported pointer width: {width}"),
};
match *ty.kind() {
@ -101,7 +101,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
16 => InlineAsmType::VecI16(size),
32 => InlineAsmType::VecI32(size),
64 => InlineAsmType::VecI64(size),
_ => unreachable!(),
width => bug!("unsupported pointer width: {width}"),
})
}
ty::Float(FloatTy::F32) => Some(InlineAsmType::VecF32(size)),
@ -109,7 +109,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
_ => None,
}
}
ty::Infer(_) => unreachable!(),
ty::Infer(_) => bug!("unexpected infer ty in asm operand"),
_ => None,
}
}
@ -136,8 +136,15 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
ty::Adt(adt, args) if Some(adt.did()) == self.tcx.lang_items().maybe_uninit() => {
let fields = &adt.non_enum_variant().fields;
let ty = fields[FieldIdx::from_u32(1)].ty(self.tcx, args);
let ty::Adt(ty, args) = ty.kind() else { unreachable!() };
assert!(ty.is_manually_drop());
// FIXME: Are we just trying to map to the `T` in `MaybeUninit<T>`?
// If so, just get it from the args.
let ty::Adt(ty, args) = ty.kind() else {
unreachable!("expected first field of `MaybeUninit` to be an ADT")
};
assert!(
ty.is_manually_drop(),
"expected first field of `MaybeUnit` to be `ManuallyDrop`"
);
let fields = &ty.non_enum_variant().fields;
let ty = fields[FieldIdx::from_u32(0)].ty(self.tcx, args);
self.get_asm_ty(ty)

View File

@ -204,11 +204,14 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
res = Err(err.emit());
}
// We match on both `ty::ImplPolarity` and `ast::ImplPolarity` just to get the `!` span.
match (tcx.impl_polarity(def_id), impl_.polarity) {
(ty::ImplPolarity::Positive, _) => {
match tcx.impl_polarity(def_id) {
ty::ImplPolarity::Positive => {
res = res.and(check_impl(tcx, item, impl_.self_ty, &impl_.of_trait));
}
(ty::ImplPolarity::Negative, ast::ImplPolarity::Negative(span)) => {
ty::ImplPolarity::Negative => {
let ast::ImplPolarity::Negative(span) = impl_.polarity else {
bug!("impl_polarity query disagrees with impl's polarity in AST");
};
// FIXME(#27579): what amount of WF checking do we need for neg impls?
if let hir::Defaultness::Default { .. } = impl_.defaultness {
let mut spans = vec![span];
@ -222,10 +225,9 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
.emit());
}
}
(ty::ImplPolarity::Reservation, _) => {
ty::ImplPolarity::Reservation => {
// FIXME: what amount of WF checking do we need for reservation impls?
}
_ => unreachable!(),
}
res
}
@ -992,15 +994,6 @@ fn check_associated_item(
})
}
fn item_adt_kind(kind: &ItemKind<'_>) -> Option<AdtKind> {
match kind {
ItemKind::Struct(..) => Some(AdtKind::Struct),
ItemKind::Union(..) => Some(AdtKind::Union),
ItemKind::Enum(..) => Some(AdtKind::Enum),
_ => None,
}
}
/// In a type definition, we check that to ensure that the types of the fields are well-formed.
fn check_type_defn<'tcx>(
tcx: TyCtxt<'tcx>,
@ -1068,9 +1061,14 @@ fn check_type_defn<'tcx>(
hir_ty.span,
wfcx.body_def_id,
traits::FieldSized {
adt_kind: match item_adt_kind(&item.kind) {
Some(i) => i,
None => bug!(),
adt_kind: match &item.kind {
ItemKind::Struct(..) => AdtKind::Struct,
ItemKind::Union(..) => AdtKind::Union,
ItemKind::Enum(..) => AdtKind::Enum,
kind => span_bug!(
item.span,
"should be wfchecking an ADT, got {kind:?}"
),
},
span: hir_ty.span,
last,
@ -1302,7 +1300,9 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
| GenericParamDefKind::Const { has_default, .. } => {
has_default && def.index >= generics.parent_count as u32
}
GenericParamDefKind::Lifetime => unreachable!(),
GenericParamDefKind::Lifetime => {
span_bug!(tcx.def_span(def.def_id), "lifetime params can have no default")
}
};
// Check that concrete defaults are well-formed. See test `type-check-defaults.rs`.
@ -1750,15 +1750,15 @@ fn check_variances_for_type_defn<'tcx>(
}
}
ItemKind::TyAlias(..) => {
if tcx.type_alias_is_lazy(item.owner_id) {
if tcx.type_of(item.owner_id).skip_binder().references_error() {
return;
}
} else {
bug!();
assert!(
tcx.type_alias_is_lazy(item.owner_id),
"should not be computing variance of non-weak type alias"
);
if tcx.type_of(item.owner_id).skip_binder().references_error() {
return;
}
}
_ => bug!(),
kind => span_bug!(item.span, "cannot compute the variances of {kind:?}"),
}
let ty_predicates = tcx.predicates_of(item.owner_id);

View File

@ -836,7 +836,7 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
use rustc_hir::*;
let Node::Item(item) = tcx.hir_node_by_def_id(def_id) else {
bug!();
bug!("expected ADT to be an item");
};
let repr = tcx.repr_options_of_def(def_id.to_def_id());
@ -887,7 +887,7 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
(adt_kind, variants)
}
_ => bug!(),
_ => bug!("{:?} is not an ADT", item.owner_id.def_id),
};
tcx.mk_adt_def(def_id.to_def_id(), kind, variants, repr)
}

View File

@ -97,8 +97,10 @@ pub(super) fn explicit_item_bounds(
item.span,
));
}
// These should have been fed!
Some(ty::ImplTraitInTraitData::Impl { .. }) => unreachable!(),
Some(ty::ImplTraitInTraitData::Impl { .. }) => span_bug!(
tcx.def_span(def_id),
"item bounds for RPITIT in impl to be fed on def-id creation"
),
None => {}
}
@ -128,7 +130,7 @@ pub(super) fn explicit_item_bounds(
let (hir::OpaqueTyOrigin::FnReturn(fn_def_id)
| hir::OpaqueTyOrigin::AsyncFn(fn_def_id)) = *origin
else {
bug!()
span_bug!(*span, "RPITIT cannot be a TAIT, but got origin {origin:?}");
};
let args = GenericArgs::identity_for_item(tcx, def_id);
let item_ty = Ty::new_opaque(tcx, def_id.to_def_id(), args);

View File

@ -296,7 +296,12 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
hir::GenericBound::Outlives(lt) => {
(icx.astconv().ast_region_to_region(lt, None), lt.ident.span)
}
_ => bug!(),
bound => {
span_bug!(
bound.span(),
"lifetime param bounds must be outlives, but found {bound:?}"
)
}
};
let pred = ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
.to_predicate(tcx);

View File

@ -1300,7 +1300,11 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
what,
})
}
_ => unreachable!(),
kind => span_bug!(
use_span,
"did not expect to resolve lifetime to {}",
kind.descr(param_def_id)
),
};
def = ResolvedArg::Error(guar);
} else if let Some(body_id) = outermost_body {
@ -1441,7 +1445,11 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
what,
})
}
_ => unreachable!(),
kind => span_bug!(
use_span,
"did not expect to resolve non-lifetime param to {}",
kind.descr(param_def_id.to_def_id())
),
};
self.map.defs.insert(hir_id, ResolvedArg::Error(guar));
} else {
@ -2123,7 +2131,7 @@ pub fn deny_non_region_late_bound(
for (var, arg) in bound_vars {
let Node::GenericParam(param) = tcx.hir_node_by_def_id(*var) else {
bug!();
span_bug!(tcx.def_span(*var), "expected bound-var def-id to resolve to param");
};
let what = match param.kind {

View File

@ -20,7 +20,13 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
use rustc_middle::ty::Ty;
let hir_id = tcx.local_def_id_to_hir_id(def_id);
let Node::AnonConst(_) = tcx.hir_node(hir_id) else { panic!() };
let node = tcx.hir_node(hir_id);
let Node::AnonConst(_) = node else {
span_bug!(
tcx.def_span(def_id),
"expected anon const in `anon_const_type_of`, got {node:?}"
);
};
let parent_node_id = tcx.hir().parent_id(hir_id);
let parent_node = tcx.hir_node(parent_node_id);

View File

@ -2003,18 +2003,14 @@ impl<'a> State<'a> {
});
self.word("|");
if let hir::FnRetTy::DefaultReturn(..) = decl.output {
return;
}
self.space_if_not_bol();
self.word_space("->");
match decl.output {
hir::FnRetTy::Return(ty) => {
self.space_if_not_bol();
self.word_space("->");
self.print_type(ty);
self.maybe_print_comment(ty.span.lo());
}
hir::FnRetTy::DefaultReturn(..) => unreachable!(),
hir::FnRetTy::DefaultReturn(..) => {}
}
}
@ -2179,7 +2175,7 @@ impl<'a> State<'a> {
GenericBound::Outlives(lt) => {
self.print_lifetime(lt);
}
_ => panic!(),
_ => panic!("unexpected bound on lifetime param: {bound:?}"),
}
if i != 0 {
@ -2216,16 +2212,14 @@ impl<'a> State<'a> {
}
fn print_fn_output(&mut self, decl: &hir::FnDecl<'_>) {
if let hir::FnRetTy::DefaultReturn(..) = decl.output {
return;
}
self.space_if_not_bol();
self.ibox(INDENT_UNIT);
self.word_space("->");
match decl.output {
hir::FnRetTy::DefaultReturn(..) => unreachable!(),
hir::FnRetTy::Return(ty) => self.print_type(ty),
hir::FnRetTy::Return(ty) => {
self.space_if_not_bol();
self.ibox(INDENT_UNIT);
self.word_space("->");
self.print_type(ty);
}
hir::FnRetTy::DefaultReturn(..) => return,
}
self.end();

View File

@ -149,7 +149,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub enum CastError {
ErrorGuaranteed(ErrorGuaranteed),
@ -271,7 +271,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
match e {
CastError::NeedViaPtr => "a raw pointer",
CastError::NeedViaThinPtr => "a thin pointer",
_ => bug!(),
e => unreachable!("control flow means we should never encounter a {e:?}"),
}
));
}
@ -288,13 +288,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
self.cast_ty,
fcx,
)
.help(format!(
"cast through {} first",
match e {
CastError::NeedViaInt => "an integer",
_ => bug!(),
}
))
.help("cast through an integer first")
.emit();
}
CastError::IllegalCast => {
@ -534,7 +528,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
let unknown_cast_to = match e {
CastError::UnknownCastPtrKind => true,
CastError::UnknownExprPtrKind => false,
_ => bug!(),
e => unreachable!("control flow means we should never encounter a {e:?}"),
};
let (span, sub) = if unknown_cast_to {
(self.cast_span, errors::CastUnknownPointerSub::To(self.cast_span))

View File

@ -1182,14 +1182,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Adjust::Pointer(PointerCoercion::ClosureFnPointer(a_sig.unsafety()))
}
ty::FnDef(..) => Adjust::Pointer(PointerCoercion::ReifyFnPointer),
_ => unreachable!(),
_ => span_bug!(cause.span, "should not try to coerce a {prev_ty} to a fn pointer"),
};
let next_adjustment = match new_ty.kind() {
ty::Closure(..) => {
Adjust::Pointer(PointerCoercion::ClosureFnPointer(b_sig.unsafety()))
}
ty::FnDef(..) => Adjust::Pointer(PointerCoercion::ReifyFnPointer),
_ => unreachable!(),
_ => span_bug!(new.span, "should not try to coerce a {new_ty} to a fn pointer"),
};
for expr in exprs.iter().map(|e| e.as_coercion_site()) {
self.apply_adjustments(
@ -1918,7 +1918,7 @@ where
impl AsCoercionSite for ! {
fn as_coercion_site(&self) -> &hir::Expr<'_> {
unreachable!()
*self
}
}

View File

@ -331,13 +331,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty_op: |ty| {
if let ty::Infer(infer) = ty.kind() {
match infer {
ty::InferTy::TyVar(_) => self.next_ty_var(TypeVariableOrigin {
ty::TyVar(_) => self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: DUMMY_SP,
}),
ty::InferTy::IntVar(_) => self.next_int_var(),
ty::InferTy::FloatVar(_) => self.next_float_var(),
_ => bug!(),
ty::IntVar(_) => self.next_int_var(),
ty::FloatVar(_) => self.next_float_var(),
ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) => {
bug!("unexpected fresh ty outside of the trait solver")
}
}
} else {
ty

View File

@ -2087,7 +2087,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let names = names.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
format!("{} and `{last}` ", names.join(", "))
}
[] => unreachable!(),
[] => bug!("expected at least one private field to report"),
};
err.note(format!(
"{}private field{s} {names}that {were} not provided",

View File

@ -993,7 +993,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}) {
match e {
Error::Missing(expected_idx) => missing_idxs.push(expected_idx),
_ => unreachable!(),
_ => unreachable!(
"control flow ensures that we should always get an `Error::Missing`"
),
}
}

View File

@ -2072,8 +2072,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Some(CtorKind::Fn) => ("(".to_owned(), ")"),
None => (format!(" {{ {field_name}: "), " }"),
// unit variants don't have fields
Some(CtorKind::Const) => unreachable!(),
Some(CtorKind::Const) => unreachable!("unit variants don't have fields"),
};
// Suggest constructor as deep into the block tree as possible.

View File

@ -415,7 +415,9 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
)
.into()
}
_ => unreachable!(),
(kind, arg) => {
bug!("mismatched method arg kind {kind:?} in turbofish: {arg:?}")
}
}
}

View File

@ -1820,7 +1820,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn joined_uncovered_patterns(witnesses: &[&Ident]) -> String {
const LIMIT: usize = 3;
match witnesses {
[] => bug!(),
[] => {
unreachable!(
"expected an uncovered pattern, otherwise why are we emitting an error?"
)
}
[witness] => format!("`{witness}`"),
[head @ .., tail] if head.len() < LIMIT => {
let head: Vec<_> = head.iter().map(<_>::to_string).collect();

View File

@ -103,15 +103,19 @@ impl<'tcx> InferCtxt<'tcx> {
}
// We don't expect `TyVar` or `Fresh*` vars at this point with lazy norm.
(
ty::Alias(..),
ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)),
)
| (
ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)),
ty::Alias(..),
) if self.next_trait_solver() => {
bug!()
(ty::Alias(..), ty::Infer(ty::TyVar(_))) | (ty::Infer(ty::TyVar(_)), ty::Alias(..))
if self.next_trait_solver() =>
{
bug!(
"We do not expect to encounter `TyVar` this late in combine \
-- they should have been handled earlier"
)
}
(_, ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)))
| (ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)), _)
if self.next_trait_solver() =>
{
bug!("We do not expect to encounter `Fresh` variables in the new solver")
}
(_, ty::Alias(..)) | (ty::Alias(..), _) if self.next_trait_solver() => {

View File

@ -232,7 +232,9 @@ fn ty_to_string<'tcx>(
/// something users are familiar with. Directly printing the `fn_sig` of closures also
/// doesn't work as they actually use the "rust-call" API.
fn closure_as_fn_str<'tcx>(infcx: &InferCtxt<'tcx>, ty: Ty<'tcx>) -> String {
let ty::Closure(_, args) = ty.kind() else { unreachable!() };
let ty::Closure(_, args) = ty.kind() else {
bug!("cannot convert non-closure to fn str in `closure_as_fn_str`")
};
let fn_sig = args.as_closure().sig();
let args = fn_sig
.inputs()

View File

@ -375,7 +375,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
err.span_note(span, "the lifetime requirement is introduced here");
err
} else {
unreachable!()
unreachable!(
"control flow ensures we have a `BindingObligation` or `ExprBindingObligation` here..."
)
}
}
infer::Subtype(box trace) => {

View File

@ -247,7 +247,9 @@ where
let (a, b) = match (a.kind(), b.kind()) {
(&ty::Alias(ty::Opaque, ..), _) => (a, generalize(b, false)?),
(_, &ty::Alias(ty::Opaque, ..)) => (generalize(a, true)?, b),
_ => unreachable!(),
_ => unreachable!(
"expected at least one opaque type in `relate_opaques`, got {a} and {b}."
),
};
let cause = ObligationCause::dummy_with_span(self.delegate.span());
let obligations = self
@ -707,7 +709,9 @@ where
),
// FIXME(deferred_projection_equality): Implement this when we trigger it.
// Probably just need to do nothing here.
ty::Variance::Bivariant => unreachable!(),
ty::Variance::Bivariant => {
unreachable!("cannot defer an alias-relate goal with Bivariant variance (yet?)")
}
})]);
}
}

View File

@ -203,7 +203,9 @@ pub(super) fn compute_alias_components_recursive<'tcx>(
out: &mut SmallVec<[Component<'tcx>; 4]>,
visited: &mut SsoHashSet<GenericArg<'tcx>>,
) {
let ty::Alias(kind, alias_ty) = alias_ty.kind() else { bug!() };
let ty::Alias(kind, alias_ty) = alias_ty.kind() else {
unreachable!("can only call `compute_alias_components_recursive` on an alias type")
};
let opt_variances = if *kind == ty::Opaque { tcx.variances_of(alias_ty.def_id) } else { &[] };
for (index, child) in alias_ty.args.iter().enumerate() {
if opt_variances.get(index) == Some(&ty::Bivariant) {

View File

@ -71,7 +71,7 @@ impl std::fmt::Debug for ConstInt {
(4, _) => write!(fmt, "_i32")?,
(8, _) => write!(fmt, "_i64")?,
(16, _) => write!(fmt, "_i128")?,
_ => bug!(),
(sz, _) => bug!("unexpected int size i{sz}"),
}
}
Ok(())
@ -105,7 +105,7 @@ impl std::fmt::Debug for ConstInt {
(4, _) => write!(fmt, "_u32")?,
(8, _) => write!(fmt, "_u64")?,
(16, _) => write!(fmt, "_u128")?,
_ => bug!(),
(sz, _) => bug!("unexpected unsigned int size u{sz}"),
}
}
Ok(())

View File

@ -421,13 +421,10 @@ impl<'tcx> TyCtxt<'tcx> {
let impl_args = match *self.type_of(impl_def_id).instantiate_identity().kind() {
ty::Adt(def_, args) if def_ == def => args,
_ => bug!(),
_ => span_bug!(self.def_span(impl_def_id), "expected ADT for self type of `Drop` impl"),
};
let item_args = match *self.type_of(def.did()).instantiate_identity().kind() {
ty::Adt(def_, args) if def_ == def => args,
_ => bug!(),
};
let item_args = ty::GenericArgs::identity_for_item(self, def.did());
let result = iter::zip(item_args, impl_args)
.filter(|&(_, k)| {

View File

@ -640,7 +640,9 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
}
DefKind::Closure if coroutine_kind.is_some() => {
let coroutine_ty = tcx.type_of(def_id).instantiate_identity();
let ty::Coroutine(_, args, _) = coroutine_ty.kind() else { bug!() };
let ty::Coroutine(_, args, _) = coroutine_ty.kind() else {
bug!("expected type of coroutine-like closure to be a coroutine")
};
let args = args.as_coroutine();
let yield_ty = args.yield_ty();
let return_ty = args.return_ty();
@ -648,7 +650,9 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
}
DefKind::Closure => {
let closure_ty = tcx.type_of(def_id).instantiate_identity();
let ty::Closure(_, args) = closure_ty.kind() else { bug!() };
let ty::Closure(_, args) = closure_ty.kind() else {
bug!("expected type of closure to be a closure")
};
let args = args.as_closure();
let sig = tcx.liberate_late_bound_regions(def_id.to_def_id(), args.sig());
let self_ty = match args.kind() {

View File

@ -782,7 +782,7 @@ impl<'tcx> Cx<'tcx> {
hir::ExprKind::Tup(fields) => ExprKind::Tuple { fields: self.mirror_exprs(fields) },
hir::ExprKind::Yield(v, _) => ExprKind::Yield { value: self.mirror_expr(v) },
hir::ExprKind::Err(_) => unreachable!(),
hir::ExprKind::Err(_) => unreachable!("cannot lower a `hir::ExprKind::Err` to THIR"),
};
Expr { temp_lifetime, ty: expr_ty, span: expr.span, kind }

View File

@ -492,8 +492,9 @@ impl<'tcx> ConstToPat<'tcx> {
PatKind::Constant { value: mir::Const::Ty(ty::Const::new_value(tcx, cv, ty)) }
}
ty::FnPtr(..) => {
// Valtree construction would never succeed for these, so this is unreachable.
unreachable!()
unreachable!(
"Valtree construction would never succeed for FnPtr, so this is unreachable."
)
}
_ => {
let err = InvalidPattern { span, non_sm_ty: ty };

View File

@ -203,7 +203,11 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
)
.into(),
ty::AssocKind::Type => Ty::new_error(tcx, guar).into(),
ty::AssocKind::Fn => unreachable!(),
// This makes no sense...
ty::AssocKind::Fn => span_bug!(
tcx.def_span(assoc_def.item.def_id),
"cannot project to an associated function"
),
};
ecx.eq(goal.param_env, goal.predicate.term, error_term)
.expect("expected goal term to be fully unconstrained");

View File

@ -256,7 +256,10 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
Err(NoSolution)
}
}
ty::ImplPolarity::Reservation => bug!(),
// FIXME: Goal polarity should be split from impl polarity
ty::ImplPolarity::Reservation => {
bug!("we never expect a `Reservation` polarity in a trait goal")
}
}
}

View File

@ -487,7 +487,7 @@ fn plug_infer_with_placeholders<'tcx>(
),
)
else {
bug!()
bug!("we always expect to be able to plug an infer var with placeholder")
};
assert_eq!(obligations, &[]);
ControlFlow::Continue(())
@ -510,7 +510,7 @@ fn plug_infer_with_placeholders<'tcx>(
),
)
else {
bug!()
bug!("we always expect to be able to plug an infer var with placeholder")
};
assert_eq!(obligations, &[]);
ControlFlow::Continue(())
@ -544,7 +544,7 @@ fn plug_infer_with_placeholders<'tcx>(
),
)
else {
bug!()
bug!("we always expect to be able to plug an infer var with placeholder")
};
assert_eq!(obligations, &[]);
}

View File

@ -250,7 +250,12 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
err.emit();
self.tcx.sess.abort_if_errors();
bug!();
// FIXME: this should be something like `build_overflow_error_fatal`, which returns
// `DiagnosticBuilder<', !>`. Then we don't even need anything after that `emit()`.
unreachable!(
"did not expect compilation to continue after `abort_if_errors`, \
since an error was definitely emitted!"
);
}
fn build_overflow_error<T>(

View File

@ -191,7 +191,9 @@ impl<'tcx> ProjectionCandidateSet<'tcx> {
match (current, candidate) {
(ParamEnv(..), ParamEnv(..)) => convert_to_ambiguous = (),
(ParamEnv(..), _) => return false,
(_, ParamEnv(..)) => unreachable!(),
(_, ParamEnv(..)) => bug!(
"should never prefer non-param-env candidates over param-env candidates"
),
(_, _) => convert_to_ambiguous = (),
}
}
@ -2080,10 +2082,11 @@ fn confirm_coroutine_candidate<'cx, 'tcx>(
obligation: &ProjectionTyObligation<'tcx>,
nested: Vec<PredicateObligation<'tcx>>,
) -> Progress<'tcx> {
let ty::Coroutine(_, args, _) =
selcx.infcx.shallow_resolve(obligation.predicate.self_ty()).kind()
else {
unreachable!()
let self_ty = selcx.infcx.shallow_resolve(obligation.predicate.self_ty());
let ty::Coroutine(_, args, _) = self_ty.kind() else {
unreachable!(
"expected coroutine self type for built-in coroutine candidate, found {self_ty}"
)
};
let coroutine_sig = args.as_coroutine().sig();
let Normalized { value: coroutine_sig, obligations } = normalize_with_depth(
@ -2113,7 +2116,10 @@ fn confirm_coroutine_candidate<'cx, 'tcx>(
} else if name == sym::Yield {
yield_ty
} else {
bug!()
span_bug!(
tcx.def_span(obligation.predicate.def_id),
"unexpected associated type: `Coroutine::{name}`"
);
};
let predicate = ty::ProjectionPredicate {
@ -2131,10 +2137,11 @@ fn confirm_future_candidate<'cx, 'tcx>(
obligation: &ProjectionTyObligation<'tcx>,
nested: Vec<PredicateObligation<'tcx>>,
) -> Progress<'tcx> {
let ty::Coroutine(_, args, _) =
selcx.infcx.shallow_resolve(obligation.predicate.self_ty()).kind()
else {
unreachable!()
let self_ty = selcx.infcx.shallow_resolve(obligation.predicate.self_ty());
let ty::Coroutine(_, args, _) = self_ty.kind() else {
unreachable!(
"expected coroutine self type for built-in async future candidate, found {self_ty}"
)
};
let coroutine_sig = args.as_coroutine().sig();
let Normalized { value: coroutine_sig, obligations } = normalize_with_depth(
@ -2174,10 +2181,9 @@ fn confirm_iterator_candidate<'cx, 'tcx>(
obligation: &ProjectionTyObligation<'tcx>,
nested: Vec<PredicateObligation<'tcx>>,
) -> Progress<'tcx> {
let ty::Coroutine(_, args, _) =
selcx.infcx.shallow_resolve(obligation.predicate.self_ty()).kind()
else {
unreachable!()
let self_ty = selcx.infcx.shallow_resolve(obligation.predicate.self_ty());
let ty::Coroutine(_, args, _) = self_ty.kind() else {
unreachable!("expected coroutine self type for built-in gen candidate, found {self_ty}")
};
let gen_sig = args.as_coroutine().sig();
let Normalized { value: gen_sig, obligations } = normalize_with_depth(
@ -2341,9 +2347,9 @@ fn confirm_closure_candidate<'cx, 'tcx>(
obligation: &ProjectionTyObligation<'tcx>,
nested: Vec<PredicateObligation<'tcx>>,
) -> Progress<'tcx> {
let ty::Closure(_, args) = selcx.infcx.shallow_resolve(obligation.predicate.self_ty()).kind()
else {
unreachable!()
let self_ty = selcx.infcx.shallow_resolve(obligation.predicate.self_ty());
let ty::Closure(_, args) = self_ty.kind() else {
unreachable!("expected closure self type for closure candidate, found {self_ty}")
};
let closure_sig = args.as_closure().sig();
let Normalized { value: closure_sig, obligations } = normalize_with_depth(

View File

@ -285,7 +285,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
ty::Projection => tcx.normalize_projection_ty(c_data),
ty::Weak => tcx.normalize_weak_ty(c_data),
ty::Inherent => tcx.normalize_inherent_projection_ty(c_data),
_ => unreachable!(),
kind => unreachable!("did not expect {kind:?} due to match arm above"),
}?;
// We don't expect ambiguity.
if !result.value.is_proven() {

View File

@ -184,7 +184,9 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>(
push_outlives_components(tcx, ty_a, &mut components);
implied_bounds.extend(implied_bounds_from_components(r_b, components))
}
ty::GenericArgKind::Const(_) => unreachable!(),
ty::GenericArgKind::Const(_) => {
unreachable!("consts do not participate in outlives bounds")
}
}
}

View File

@ -942,8 +942,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let a_ty = self.infcx.shallow_resolve(predicate.self_ty());
let b_ty = self.infcx.shallow_resolve(predicate.trait_ref.args.type_at(1));
let ty::Dynamic(a_data, a_region, ty::Dyn) = *a_ty.kind() else { bug!() };
let ty::Dynamic(b_data, b_region, ty::Dyn) = *b_ty.kind() else { bug!() };
let ty::Dynamic(a_data, a_region, ty::Dyn) = *a_ty.kind() else {
bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`")
};
let ty::Dynamic(b_data, b_region, ty::Dyn) = *b_ty.kind() else {
bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`")
};
let source_principal = a_data.principal().unwrap().with_self_ty(tcx, a_ty);
let unnormalized_upcast_principal =

View File

@ -1,20 +1,20 @@
Function name: async::c
Raw bytes (9): 0x[01, 01, 00, 01, 01, 05, 01, 00, 19]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 07, 01, 00, 19]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 5, 1) to (start + 0, 25)
- Code(Counter(0)) at (prev + 7, 1) to (start + 0, 25)
Function name: async::c::{closure#0}
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 05, 19, 01, 0e, 05, 02, 09, 00, 0a, 02, 02, 09, 00, 0a, 07, 02, 01, 00, 02]
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 07, 19, 01, 0e, 05, 02, 09, 00, 0a, 02, 02, 09, 00, 0a, 07, 02, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 2
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 5, 25) to (start + 1, 14)
- Code(Counter(0)) at (prev + 7, 25) to (start + 1, 14)
- Code(Counter(1)) at (prev + 2, 9) to (start + 0, 10)
- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 10)
= (c0 - c1)
@ -22,136 +22,84 @@ Number of file 0 mappings: 4
= (c1 + (c0 - c1))
Function name: async::d
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0d, 01, 00, 14]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0f, 01, 00, 14]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 13, 1) to (start + 0, 20)
- Code(Counter(0)) at (prev + 15, 1) to (start + 0, 20)
Function name: async::d::{closure#0}
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0d, 14, 00, 19]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0f, 14, 00, 19]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 13, 20) to (start + 0, 25)
- Code(Counter(0)) at (prev + 15, 20) to (start + 0, 25)
Function name: async::e (unused)
Raw bytes (9): 0x[01, 01, 00, 01, 00, 0f, 01, 00, 14]
Raw bytes (9): 0x[01, 01, 00, 01, 00, 11, 01, 00, 14]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Zero) at (prev + 15, 1) to (start + 0, 20)
- Code(Zero) at (prev + 17, 1) to (start + 0, 20)
Function name: async::e::{closure#0} (unused)
Raw bytes (9): 0x[01, 01, 00, 01, 00, 0f, 14, 00, 19]
Raw bytes (9): 0x[01, 01, 00, 01, 00, 11, 14, 00, 19]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Zero) at (prev + 15, 20) to (start + 0, 25)
Function name: async::executor::block_on::<core::pin::Pin<&mut async::i::{closure#0}>>
Raw bytes (40): 0x[01, 01, 03, 0b, 05, 01, 05, 01, 05, 06, 01, 6e, 05, 0a, 36, 02, 0d, 20, 00, 23, 0b, 00, 27, 00, 49, 02, 01, 17, 00, 1a, 05, 01, 0e, 00, 0f, 02, 02, 05, 00, 06]
Number of files: 1
- file 0 => global file 1
Number of expressions: 3
- expression 0 operands: lhs = Expression(2, Add), rhs = Counter(1)
- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
- expression 2 operands: lhs = Counter(0), rhs = Counter(1)
Number of file 0 mappings: 6
- Code(Counter(0)) at (prev + 110, 5) to (start + 10, 54)
- Code(Expression(0, Sub)) at (prev + 13, 32) to (start + 0, 35)
= ((c0 + c1) - c1)
- Code(Expression(2, Add)) at (prev + 0, 39) to (start + 0, 73)
= (c0 + c1)
- Code(Expression(0, Sub)) at (prev + 1, 23) to (start + 0, 26)
= ((c0 + c1) - c1)
- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 15)
- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 6)
= ((c0 + c1) - c1)
Function name: async::executor::block_on::VTABLE::{closure#0}
Raw bytes (9): 0x[01, 01, 00, 01, 01, 72, 11, 00, 31]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 114, 17) to (start + 0, 49)
Function name: async::executor::block_on::VTABLE::{closure#1}
Raw bytes (9): 0x[01, 01, 00, 01, 01, 73, 11, 00, 31]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 115, 17) to (start + 0, 49)
Function name: async::executor::block_on::VTABLE::{closure#2}
Raw bytes (9): 0x[01, 01, 00, 01, 01, 74, 11, 00, 31]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 116, 17) to (start + 0, 49)
Function name: async::executor::block_on::VTABLE::{closure#3}
Raw bytes (9): 0x[01, 01, 00, 01, 01, 75, 11, 00, 13]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 117, 17) to (start + 0, 19)
- Code(Zero) at (prev + 17, 20) to (start + 0, 25)
Function name: async::f
Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 01, 00, 14]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 01, 00, 14]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 17, 1) to (start + 0, 20)
- Code(Counter(0)) at (prev + 19, 1) to (start + 0, 20)
Function name: async::f::{closure#0}
Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 14, 00, 19]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 14, 00, 19]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 17, 20) to (start + 0, 25)
- Code(Counter(0)) at (prev + 19, 20) to (start + 0, 25)
Function name: async::foo (unused)
Raw bytes (9): 0x[01, 01, 00, 01, 00, 13, 01, 00, 1e]
Raw bytes (9): 0x[01, 01, 00, 01, 00, 15, 01, 00, 1e]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Zero) at (prev + 19, 1) to (start + 0, 30)
- Code(Zero) at (prev + 21, 1) to (start + 0, 30)
Function name: async::foo::{closure#0} (unused)
Raw bytes (9): 0x[01, 01, 00, 01, 00, 13, 1e, 00, 2d]
Raw bytes (9): 0x[01, 01, 00, 01, 00, 15, 1e, 00, 2d]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Zero) at (prev + 19, 30) to (start + 0, 45)
- Code(Zero) at (prev + 21, 30) to (start + 0, 45)
Function name: async::g
Raw bytes (9): 0x[01, 01, 00, 01, 01, 15, 01, 00, 17]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 00, 17]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 21, 1) to (start + 0, 23)
- Code(Counter(0)) at (prev + 23, 1) to (start + 0, 23)
Function name: async::g::{closure#0} (unused)
Raw bytes (69): 0x[01, 01, 00, 0d, 00, 15, 17, 01, 0c, 00, 02, 09, 00, 0a, 00, 00, 0e, 00, 11, 00, 00, 12, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 11, 00, 00, 12, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02]
Raw bytes (69): 0x[01, 01, 00, 0d, 00, 17, 17, 01, 0c, 00, 02, 09, 00, 0a, 00, 00, 0e, 00, 11, 00, 00, 12, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 11, 00, 00, 12, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 13
- Code(Zero) at (prev + 21, 23) to (start + 1, 12)
- Code(Zero) at (prev + 23, 23) to (start + 1, 12)
- Code(Zero) at (prev + 2, 9) to (start + 0, 10)
- Code(Zero) at (prev + 0, 14) to (start + 0, 17)
- Code(Zero) at (prev + 0, 18) to (start + 0, 23)
@ -166,20 +114,20 @@ Number of file 0 mappings: 13
- Code(Zero) at (prev + 2, 1) to (start + 0, 2)
Function name: async::h
Raw bytes (9): 0x[01, 01, 00, 01, 01, 1d, 01, 00, 16]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 1f, 01, 00, 16]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 29, 1) to (start + 0, 22)
- Code(Counter(0)) at (prev + 31, 1) to (start + 0, 22)
Function name: async::h::{closure#0} (unused)
Raw bytes (44): 0x[01, 01, 00, 08, 00, 1d, 16, 03, 0c, 00, 04, 09, 00, 0a, 00, 00, 0e, 00, 13, 00, 00, 14, 00, 19, 00, 00, 1a, 00, 1b, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02]
Raw bytes (44): 0x[01, 01, 00, 08, 00, 1f, 16, 03, 0c, 00, 04, 09, 00, 0a, 00, 00, 0e, 00, 13, 00, 00, 14, 00, 19, 00, 00, 1a, 00, 1b, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 8
- Code(Zero) at (prev + 29, 22) to (start + 3, 12)
- Code(Zero) at (prev + 31, 22) to (start + 3, 12)
- Code(Zero) at (prev + 4, 9) to (start + 0, 10)
- Code(Zero) at (prev + 0, 14) to (start + 0, 19)
- Code(Zero) at (prev + 0, 20) to (start + 0, 25)
@ -189,22 +137,22 @@ Number of file 0 mappings: 8
- Code(Zero) at (prev + 2, 1) to (start + 0, 2)
Function name: async::i
Raw bytes (9): 0x[01, 01, 00, 01, 01, 26, 01, 00, 13]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 28, 01, 00, 13]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 38, 1) to (start + 0, 19)
- Code(Counter(0)) at (prev + 40, 1) to (start + 0, 19)
Function name: async::i::{closure#0}
Raw bytes (78): 0x[01, 01, 02, 07, 21, 19, 1d, 0e, 01, 26, 13, 04, 0c, 0d, 05, 09, 00, 0a, 01, 00, 0e, 00, 12, 05, 00, 13, 00, 18, 09, 00, 1c, 00, 21, 0d, 00, 27, 00, 2a, 15, 00, 2b, 00, 30, 1d, 01, 09, 00, 0a, 11, 00, 0e, 00, 11, 25, 00, 12, 00, 17, 29, 00, 1b, 00, 20, 1d, 00, 24, 00, 26, 21, 01, 0e, 00, 10, 03, 02, 01, 00, 02]
Raw bytes (78): 0x[01, 01, 02, 07, 21, 19, 1d, 0e, 01, 28, 13, 04, 0c, 0d, 05, 09, 00, 0a, 01, 00, 0e, 00, 12, 05, 00, 13, 00, 18, 09, 00, 1c, 00, 21, 0d, 00, 27, 00, 2a, 15, 00, 2b, 00, 30, 1d, 01, 09, 00, 0a, 11, 00, 0e, 00, 11, 25, 00, 12, 00, 17, 29, 00, 1b, 00, 20, 1d, 00, 24, 00, 26, 21, 01, 0e, 00, 10, 03, 02, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 2
- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(8)
- expression 1 operands: lhs = Counter(6), rhs = Counter(7)
Number of file 0 mappings: 14
- Code(Counter(0)) at (prev + 38, 19) to (start + 4, 12)
- Code(Counter(0)) at (prev + 40, 19) to (start + 4, 12)
- Code(Counter(3)) at (prev + 5, 9) to (start + 0, 10)
- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 18)
- Code(Counter(1)) at (prev + 0, 19) to (start + 0, 24)
@ -221,14 +169,14 @@ Number of file 0 mappings: 14
= ((c6 + c7) + c8)
Function name: async::j
Raw bytes (53): 0x[01, 01, 02, 07, 0d, 05, 09, 09, 01, 31, 01, 13, 0c, 05, 14, 09, 00, 0a, 01, 00, 0e, 00, 1b, 05, 00, 1f, 00, 27, 09, 01, 09, 00, 0a, 11, 00, 0e, 00, 1a, 09, 00, 1e, 00, 20, 0d, 01, 0e, 00, 10, 03, 02, 01, 00, 02]
Raw bytes (53): 0x[01, 01, 02, 07, 0d, 05, 09, 09, 01, 33, 01, 13, 0c, 05, 14, 09, 00, 0a, 01, 00, 0e, 00, 1b, 05, 00, 1f, 00, 27, 09, 01, 09, 00, 0a, 11, 00, 0e, 00, 1a, 09, 00, 1e, 00, 20, 0d, 01, 0e, 00, 10, 03, 02, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 2
- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(3)
- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
Number of file 0 mappings: 9
- Code(Counter(0)) at (prev + 49, 1) to (start + 19, 12)
- Code(Counter(0)) at (prev + 51, 1) to (start + 19, 12)
- Code(Counter(1)) at (prev + 20, 9) to (start + 0, 10)
- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 27)
- Code(Counter(1)) at (prev + 0, 31) to (start + 0, 39)
@ -240,14 +188,14 @@ Number of file 0 mappings: 9
= ((c1 + c2) + c3)
Function name: async::j::c
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 33, 05, 01, 12, 05, 02, 0d, 00, 0e, 02, 0a, 0d, 00, 0e, 07, 02, 05, 00, 06]
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 35, 05, 01, 12, 05, 02, 0d, 00, 0e, 02, 0a, 0d, 00, 0e, 07, 02, 05, 00, 06]
Number of files: 1
- file 0 => global file 1
Number of expressions: 2
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 51, 5) to (start + 1, 18)
- Code(Counter(0)) at (prev + 53, 5) to (start + 1, 18)
- Code(Counter(1)) at (prev + 2, 13) to (start + 0, 14)
- Code(Expression(0, Sub)) at (prev + 10, 13) to (start + 0, 14)
= (c0 - c1)
@ -255,35 +203,35 @@ Number of file 0 mappings: 4
= (c1 + (c0 - c1))
Function name: async::j::d
Raw bytes (9): 0x[01, 01, 00, 01, 01, 42, 05, 00, 17]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 44, 05, 00, 17]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 66, 5) to (start + 0, 23)
- Code(Counter(0)) at (prev + 68, 5) to (start + 0, 23)
Function name: async::j::f
Raw bytes (9): 0x[01, 01, 00, 01, 01, 43, 05, 00, 17]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 45, 05, 00, 17]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 67, 5) to (start + 0, 23)
- Code(Counter(0)) at (prev + 69, 5) to (start + 0, 23)
Function name: async::k (unused)
Raw bytes (29): 0x[01, 01, 00, 05, 00, 4b, 01, 01, 0c, 00, 02, 0e, 00, 10, 00, 01, 0e, 00, 10, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02]
Raw bytes (29): 0x[01, 01, 00, 05, 00, 4d, 01, 01, 0c, 00, 02, 0e, 00, 10, 00, 01, 0e, 00, 10, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 5
- Code(Zero) at (prev + 75, 1) to (start + 1, 12)
- Code(Zero) at (prev + 77, 1) to (start + 1, 12)
- Code(Zero) at (prev + 2, 14) to (start + 0, 16)
- Code(Zero) at (prev + 1, 14) to (start + 0, 16)
- Code(Zero) at (prev + 1, 14) to (start + 0, 16)
- Code(Zero) at (prev + 2, 1) to (start + 0, 2)
Function name: async::l
Raw bytes (37): 0x[01, 01, 04, 01, 07, 05, 09, 0f, 02, 09, 05, 05, 01, 53, 01, 01, 0c, 02, 02, 0e, 00, 10, 05, 01, 0e, 00, 10, 09, 01, 0e, 00, 10, 0b, 02, 01, 00, 02]
Raw bytes (37): 0x[01, 01, 04, 01, 07, 05, 09, 0f, 02, 09, 05, 05, 01, 55, 01, 01, 0c, 02, 02, 0e, 00, 10, 05, 01, 0e, 00, 10, 09, 01, 0e, 00, 10, 0b, 02, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 4
@ -292,7 +240,7 @@ Number of expressions: 4
- expression 2 operands: lhs = Expression(3, Add), rhs = Expression(0, Sub)
- expression 3 operands: lhs = Counter(2), rhs = Counter(1)
Number of file 0 mappings: 5
- Code(Counter(0)) at (prev + 83, 1) to (start + 1, 12)
- Code(Counter(0)) at (prev + 85, 1) to (start + 1, 12)
- Code(Expression(0, Sub)) at (prev + 2, 14) to (start + 0, 16)
= (c0 - (c1 + c2))
- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 16)
@ -301,26 +249,26 @@ Number of file 0 mappings: 5
= ((c2 + c1) + (c0 - (c1 + c2)))
Function name: async::m
Raw bytes (9): 0x[01, 01, 00, 01, 01, 5b, 01, 00, 19]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 5d, 01, 00, 19]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 91, 1) to (start + 0, 25)
- Code(Counter(0)) at (prev + 93, 1) to (start + 0, 25)
Function name: async::m::{closure#0} (unused)
Raw bytes (9): 0x[01, 01, 00, 01, 00, 5b, 19, 00, 22]
Raw bytes (9): 0x[01, 01, 00, 01, 00, 5d, 19, 00, 22]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Zero) at (prev + 91, 25) to (start + 0, 34)
- Code(Zero) at (prev + 93, 25) to (start + 0, 34)
Function name: async::main
Raw bytes (9): 0x[01, 01, 00, 01, 01, 5d, 01, 08, 02]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 5f, 01, 08, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 93, 1) to (start + 8, 2)
- Code(Counter(0)) at (prev + 95, 1) to (start + 8, 2)

View File

@ -1,6 +1,8 @@
LL| |#![feature(coverage_attribute)]
LL| |#![feature(noop_waker)]
LL| |#![allow(unused_assignments, dead_code)]
LL| |
LL| |// compile-flags: --edition=2018 -C opt-level=1
LL| |// edition: 2018
LL| |// compile-flags: -Copt-level=1
LL| |
LL| 1|async fn c(x: u8) -> u8 {
LL| 1| if x == 8 {
@ -108,32 +110,21 @@
LL| 1|}
LL| |
LL| |mod executor {
LL| | use core::{
LL| | future::Future,
LL| | pin::Pin,
LL| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
LL| | };
LL| | use core::future::Future;
LL| | use core::pin::pin;
LL| | use core::task::{Context, Poll, Waker};
LL| |
LL| 1| pub fn block_on<F: Future>(mut future: F) -> F::Output {
LL| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) };
LL| 1| use std::hint::unreachable_unchecked;
LL| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new(
LL| 1| |_| unsafe { unreachable_unchecked() }, // clone
^0
LL| 1| |_| unsafe { unreachable_unchecked() }, // wake
^0
LL| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref
^0
LL| 1| |_| (),
LL| 1| );
LL| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
LL| 1| let mut context = Context::from_waker(&waker);
LL| | #[coverage(off)]
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
LL| | let mut future = pin!(future);
LL| | let waker = Waker::noop();
LL| | let mut context = Context::from_waker(&waker);
LL| |
LL| | loop {
LL| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
LL| 1| break val;
LL| 0| }
LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
LL| | break val;
LL| | }
LL| | }
LL| 1| }
LL| | }
LL| |}

View File

@ -1,6 +1,8 @@
#![feature(coverage_attribute)]
#![feature(noop_waker)]
#![allow(unused_assignments, dead_code)]
// compile-flags: --edition=2018 -C opt-level=1
// edition: 2018
// compile-flags: -Copt-level=1
async fn c(x: u8) -> u8 {
if x == 8 {
@ -101,22 +103,14 @@ fn main() {
}
mod executor {
use core::{
future::Future,
pin::Pin,
task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
};
use core::future::Future;
use core::pin::pin;
use core::task::{Context, Poll, Waker};
#[coverage(off)]
pub fn block_on<F: Future>(mut future: F) -> F::Output {
let mut future = unsafe { Pin::new_unchecked(&mut future) };
use std::hint::unreachable_unchecked;
static VTABLE: RawWakerVTable = RawWakerVTable::new(
|_| unsafe { unreachable_unchecked() }, // clone
|_| unsafe { unreachable_unchecked() }, // wake
|_| unsafe { unreachable_unchecked() }, // wake_by_ref
|_| (),
);
let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
let mut future = pin!(future);
let waker = Waker::noop();
let mut context = Context::from_waker(&waker);
loop {

View File

@ -1,20 +1,20 @@
Function name: async2::async_func
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 01, 00, 17]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0d, 01, 00, 17]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 11, 1) to (start + 0, 23)
- Code(Counter(0)) at (prev + 13, 1) to (start + 0, 23)
Function name: async2::async_func::{closure#0}
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 0b, 17, 03, 09, 05, 03, 0a, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02]
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 0d, 17, 03, 09, 05, 03, 0a, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 2
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 11, 23) to (start + 3, 9)
- Code(Counter(0)) at (prev + 13, 23) to (start + 3, 9)
- Code(Counter(1)) at (prev + 3, 10) to (start + 2, 6)
- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
= (c0 - c1)
@ -22,109 +22,37 @@ Number of file 0 mappings: 4
= (c1 + (c0 - c1))
Function name: async2::async_func_just_println
Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 01, 00, 24]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 15, 01, 00, 24]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 19, 1) to (start + 0, 36)
- Code(Counter(0)) at (prev + 21, 1) to (start + 0, 36)
Function name: async2::async_func_just_println::{closure#0}
Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 24, 02, 02]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 15, 24, 02, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 19, 36) to (start + 2, 2)
Function name: async2::executor::block_on::<async2::async_func::{closure#0}>
Raw bytes (40): 0x[01, 01, 03, 0b, 05, 01, 05, 01, 05, 06, 01, 27, 05, 0a, 36, 02, 0d, 20, 00, 23, 0b, 00, 27, 00, 49, 02, 01, 17, 00, 1a, 05, 01, 0e, 00, 0f, 02, 02, 05, 00, 06]
Number of files: 1
- file 0 => global file 1
Number of expressions: 3
- expression 0 operands: lhs = Expression(2, Add), rhs = Counter(1)
- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
- expression 2 operands: lhs = Counter(0), rhs = Counter(1)
Number of file 0 mappings: 6
- Code(Counter(0)) at (prev + 39, 5) to (start + 10, 54)
- Code(Expression(0, Sub)) at (prev + 13, 32) to (start + 0, 35)
= ((c0 + c1) - c1)
- Code(Expression(2, Add)) at (prev + 0, 39) to (start + 0, 73)
= (c0 + c1)
- Code(Expression(0, Sub)) at (prev + 1, 23) to (start + 0, 26)
= ((c0 + c1) - c1)
- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 15)
- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 6)
= ((c0 + c1) - c1)
Function name: async2::executor::block_on::<async2::async_func_just_println::{closure#0}>
Raw bytes (40): 0x[01, 01, 03, 0b, 05, 01, 05, 01, 05, 06, 01, 27, 05, 0a, 36, 02, 0d, 20, 00, 23, 0b, 00, 27, 00, 49, 02, 01, 17, 00, 1a, 05, 01, 0e, 00, 0f, 02, 02, 05, 00, 06]
Number of files: 1
- file 0 => global file 1
Number of expressions: 3
- expression 0 operands: lhs = Expression(2, Add), rhs = Counter(1)
- expression 1 operands: lhs = Counter(0), rhs = Counter(1)
- expression 2 operands: lhs = Counter(0), rhs = Counter(1)
Number of file 0 mappings: 6
- Code(Counter(0)) at (prev + 39, 5) to (start + 10, 54)
- Code(Expression(0, Sub)) at (prev + 13, 32) to (start + 0, 35)
= ((c0 + c1) - c1)
- Code(Expression(2, Add)) at (prev + 0, 39) to (start + 0, 73)
= (c0 + c1)
- Code(Expression(0, Sub)) at (prev + 1, 23) to (start + 0, 26)
= ((c0 + c1) - c1)
- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 15)
- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 6)
= ((c0 + c1) - c1)
Function name: async2::executor::block_on::VTABLE::{closure#0}
Raw bytes (9): 0x[01, 01, 00, 01, 01, 2b, 11, 00, 31]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 43, 17) to (start + 0, 49)
Function name: async2::executor::block_on::VTABLE::{closure#1}
Raw bytes (9): 0x[01, 01, 00, 01, 01, 2c, 11, 00, 31]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 44, 17) to (start + 0, 49)
Function name: async2::executor::block_on::VTABLE::{closure#2}
Raw bytes (9): 0x[01, 01, 00, 01, 01, 2d, 11, 00, 31]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 45, 17) to (start + 0, 49)
Function name: async2::executor::block_on::VTABLE::{closure#3}
Raw bytes (9): 0x[01, 01, 00, 01, 01, 2e, 11, 00, 13]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 46, 17) to (start + 0, 19)
- Code(Counter(0)) at (prev + 21, 36) to (start + 2, 2)
Function name: async2::main
Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 07, 02]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 19, 01, 07, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 23, 1) to (start + 7, 2)
- Code(Counter(0)) at (prev + 25, 1) to (start + 7, 2)
Function name: async2::non_async_func
Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 03, 01, 03, 09, 05, 03, 0a, 02, 06, 00, 02, 06, 00, 07, 03, 01, 01, 00, 02]
Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 05, 01, 03, 09, 05, 03, 0a, 02, 06, 00, 02, 06, 00, 07, 03, 01, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 1
- expression 0 operands: lhs = Counter(1), rhs = Zero
Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 3, 1) to (start + 3, 9)
- Code(Counter(0)) at (prev + 5, 1) to (start + 3, 9)
- Code(Counter(1)) at (prev + 3, 10) to (start + 2, 6)
- Code(Zero) at (prev + 2, 6) to (start + 0, 7)
- Code(Expression(0, Add)) at (prev + 1, 1) to (start + 0, 2)

View File

@ -1,4 +1,6 @@
LL| |// compile-flags: --edition=2018
LL| |#![feature(coverage_attribute)]
LL| |#![feature(noop_waker)]
LL| |// edition: 2018
LL| |
LL| 1|fn non_async_func() {
LL| 1| println!("non_async_func was covered");
@ -32,73 +34,21 @@
LL| 1|}
LL| |
LL| |mod executor {
LL| | use core::{
LL| | future::Future,
LL| | pin::Pin,
LL| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
LL| | };
LL| | use core::future::Future;
LL| | use core::pin::pin;
LL| | use core::task::{Context, Poll, Waker};
LL| |
LL| 2| pub fn block_on<F: Future>(mut future: F) -> F::Output {
LL| 2| let mut future = unsafe { Pin::new_unchecked(&mut future) };
LL| 2| use std::hint::unreachable_unchecked;
LL| 2| static VTABLE: RawWakerVTable = RawWakerVTable::new(
LL| 2| |_| unsafe { unreachable_unchecked() }, // clone
^0
LL| 2| |_| unsafe { unreachable_unchecked() }, // wake
^0
LL| 2| |_| unsafe { unreachable_unchecked() }, // wake_by_ref
^0
LL| 2| |_| (),
LL| 2| );
LL| 2| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
LL| 2| let mut context = Context::from_waker(&waker);
LL| | #[coverage(off)]
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
LL| | let mut future = pin!(future);
LL| | let waker = Waker::noop();
LL| | let mut context = Context::from_waker(&waker);
LL| |
LL| | loop {
LL| 2| if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
LL| 2| break val;
LL| 0| }
LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
LL| | break val;
LL| | }
LL| | }
LL| 2| }
------------------
| async2::executor::block_on::<async2::async_func::{closure#0}>:
| LL| 1| pub fn block_on<F: Future>(mut future: F) -> F::Output {
| LL| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) };
| LL| 1| use std::hint::unreachable_unchecked;
| LL| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new(
| LL| 1| |_| unsafe { unreachable_unchecked() }, // clone
| LL| 1| |_| unsafe { unreachable_unchecked() }, // wake
| LL| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref
| LL| 1| |_| (),
| LL| 1| );
| LL| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
| LL| 1| let mut context = Context::from_waker(&waker);
| LL| |
| LL| | loop {
| LL| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
| LL| 1| break val;
| LL| 0| }
| LL| | }
| LL| 1| }
------------------
| async2::executor::block_on::<async2::async_func_just_println::{closure#0}>:
| LL| 1| pub fn block_on<F: Future>(mut future: F) -> F::Output {
| LL| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) };
| LL| 1| use std::hint::unreachable_unchecked;
| LL| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new(
| LL| 1| |_| unsafe { unreachable_unchecked() }, // clone
| LL| 1| |_| unsafe { unreachable_unchecked() }, // wake
| LL| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref
| LL| 1| |_| (),
| LL| 1| );
| LL| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
| LL| 1| let mut context = Context::from_waker(&waker);
| LL| |
| LL| | loop {
| LL| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
| LL| 1| break val;
| LL| 0| }
| LL| | }
| LL| 1| }
------------------
LL| | }
LL| |}

View File

@ -1,4 +1,6 @@
// compile-flags: --edition=2018
#![feature(coverage_attribute)]
#![feature(noop_waker)]
// edition: 2018
fn non_async_func() {
println!("non_async_func was covered");
@ -30,22 +32,14 @@ fn main() {
}
mod executor {
use core::{
future::Future,
pin::Pin,
task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
};
use core::future::Future;
use core::pin::pin;
use core::task::{Context, Poll, Waker};
#[coverage(off)]
pub fn block_on<F: Future>(mut future: F) -> F::Output {
let mut future = unsafe { Pin::new_unchecked(&mut future) };
use std::hint::unreachable_unchecked;
static VTABLE: RawWakerVTable = RawWakerVTable::new(
|_| unsafe { unreachable_unchecked() }, // clone
|_| unsafe { unreachable_unchecked() }, // wake
|_| unsafe { unreachable_unchecked() }, // wake_by_ref
|_| (),
);
let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
let mut future = pin!(future);
let waker = Waker::noop();
let mut context = Context::from_waker(&waker);
loop {

View File

@ -1,28 +1,28 @@
Function name: closure_macro_async::load_configuration_files
Raw bytes (9): 0x[01, 01, 00, 01, 01, 1d, 01, 02, 02]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 1e, 01, 02, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 29, 1) to (start + 2, 2)
- Code(Counter(0)) at (prev + 30, 1) to (start + 2, 2)
Function name: closure_macro_async::test
Raw bytes (9): 0x[01, 01, 00, 01, 01, 21, 01, 00, 2b]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 22, 01, 00, 2b]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 33, 1) to (start + 0, 43)
- Code(Counter(0)) at (prev + 34, 1) to (start + 0, 43)
Function name: closure_macro_async::test::{closure#0}
Raw bytes (43): 0x[01, 01, 02, 01, 05, 05, 02, 07, 01, 21, 2b, 01, 21, 02, 02, 09, 00, 0f, 05, 00, 12, 00, 13, 02, 00, 12, 00, 13, 05, 00, 54, 00, 55, 02, 02, 09, 02, 0b, 07, 03, 01, 00, 02]
Raw bytes (43): 0x[01, 01, 02, 01, 05, 05, 02, 07, 01, 22, 2b, 01, 21, 02, 02, 09, 00, 0f, 05, 00, 12, 00, 13, 02, 00, 12, 00, 13, 05, 00, 54, 00, 55, 02, 02, 09, 02, 0b, 07, 03, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 2
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
Number of file 0 mappings: 7
- Code(Counter(0)) at (prev + 33, 43) to (start + 1, 33)
- Code(Counter(0)) at (prev + 34, 43) to (start + 1, 33)
- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 15)
= (c0 - c1)
- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19)
@ -35,10 +35,10 @@ Number of file 0 mappings: 7
= (c1 + (c0 - c1))
Function name: closure_macro_async::test::{closure#0}::{closure#0}
Raw bytes (9): 0x[01, 01, 00, 01, 01, 23, 12, 00, 54]
Raw bytes (9): 0x[01, 01, 00, 01, 01, 24, 12, 00, 54]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 35, 18) to (start + 0, 84)
- Code(Counter(0)) at (prev + 36, 18) to (start + 0, 84)

View File

@ -1,5 +1,6 @@
LL| |// compile-flags: --edition=2018
LL| |#![feature(coverage_attribute)]
LL| |#![feature(noop_waker)]
LL| |// edition: 2018
LL| |
LL| |macro_rules! bail {
LL| | ($msg:literal $(,)?) => {
@ -46,27 +47,14 @@
LL| |}
LL| |
LL| |mod executor {
LL| | use core::{
LL| | future::Future,
LL| | pin::Pin,
LL| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
LL| | };
LL| | use core::future::Future;
LL| | use core::pin::pin;
LL| | use core::task::{Context, Poll, Waker};
LL| |
LL| | #[coverage(off)]
LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
LL| | let mut future = unsafe { Pin::new_unchecked(&mut future) };
LL| | use std::hint::unreachable_unchecked;
LL| | static VTABLE: RawWakerVTable = RawWakerVTable::new(
LL| | #[coverage(off)]
LL| | |_| unsafe { unreachable_unchecked() }, // clone
LL| | #[coverage(off)]
LL| | |_| unsafe { unreachable_unchecked() }, // wake
LL| | #[coverage(off)]
LL| | |_| unsafe { unreachable_unchecked() }, // wake_by_ref
LL| | #[coverage(off)]
LL| | |_| (),
LL| | );
LL| | let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
LL| | let mut future = pin!(future);
LL| | let waker = Waker::noop();
LL| | let mut context = Context::from_waker(&waker);
LL| |
LL| | loop {

View File

@ -1,5 +1,6 @@
// compile-flags: --edition=2018
#![feature(coverage_attribute)]
#![feature(noop_waker)]
// edition: 2018
macro_rules! bail {
($msg:literal $(,)?) => {
@ -45,27 +46,14 @@ fn main() {
}
mod executor {
use core::{
future::Future,
pin::Pin,
task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
};
use core::future::Future;
use core::pin::pin;
use core::task::{Context, Poll, Waker};
#[coverage(off)]
pub fn block_on<F: Future>(mut future: F) -> F::Output {
let mut future = unsafe { Pin::new_unchecked(&mut future) };
use std::hint::unreachable_unchecked;
static VTABLE: RawWakerVTable = RawWakerVTable::new(
#[coverage(off)]
|_| unsafe { unreachable_unchecked() }, // clone
#[coverage(off)]
|_| unsafe { unreachable_unchecked() }, // wake
#[coverage(off)]
|_| unsafe { unreachable_unchecked() }, // wake_by_ref
#[coverage(off)]
|_| (),
);
let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
let mut future = pin!(future);
let waker = Waker::noop();
let mut context = Context::from_waker(&waker);
loop {