mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-15 08:23:26 +00:00
allocate string only when error will be emitted
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
This commit is contained in:
parent
f77658b470
commit
48fd66613b
@ -98,7 +98,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
|||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
|
|
||||||
if !is_implemented {
|
if !is_implemented {
|
||||||
to_implement.push(tcx.item_name(trait_item_id).to_string());
|
to_implement.push(trait_item_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,13 +106,18 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
|||||||
// all nonconst trait functions (not marked with #[default_method_body_is_const])
|
// all nonconst trait functions (not marked with #[default_method_body_is_const])
|
||||||
// must be implemented
|
// must be implemented
|
||||||
if !to_implement.is_empty() {
|
if !to_implement.is_empty() {
|
||||||
|
let not_implemented = to_implement
|
||||||
|
.into_iter()
|
||||||
|
.map(|did| tcx.item_name(did).to_string())
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("`, `");
|
||||||
tcx
|
tcx
|
||||||
.sess
|
.sess
|
||||||
.struct_span_err(
|
.struct_span_err(
|
||||||
item.span,
|
item.span,
|
||||||
"const trait implementations may not use non-const default functions",
|
"const trait implementations may not use non-const default functions",
|
||||||
)
|
)
|
||||||
.note(&format!("`{}` not implemented", to_implement.join("`, `")))
|
.note(&format!("`{}` not implemented", not_implemented))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user