use self::drop_ranges::DropRanges;
use super::FnCtxt;
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
-use rustc_errors::pluralize;
+use rustc_errors::{pluralize, DelayDm};
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, DefKind, Res};
use rustc_hir::def_id::DefId;
rustc_session::lint::builtin::MUST_NOT_SUSPEND,
hir_id,
data.source_span,
- |lint| {
- let msg = format!(
+ DelayDm(|| {
+ format!(
"{}`{}`{} held across a suspend point, but should not be",
data.descr_pre,
tcx.def_path_str(def_id),
data.descr_post,
- );
- let mut err = lint.build(&msg);
-
+ )
+ }),
+ |lint| {
// add span pointing to the offending yield/await
- err.span_label(data.yield_span, "the value is held across this suspend point");
+ lint.span_label(data.yield_span, "the value is held across this suspend point");
// Add optional reason note
if let Some(note) = attr.value_str() {
// FIXME(guswynn): consider formatting this better
- err.span_note(data.source_span, note.as_str());
+ lint.span_note(data.source_span, note.as_str());
}
// Add some quick suggestions on what to do
// FIXME: can `drop` work as a suggestion here as well?
- err.span_help(
+ lint.span_help(
data.source_span,
"consider using a block (`{ ... }`) \
to shrink the value's scope, ending before the suspend point",
);
- err.emit();
+ lint
},
);