Expand list of trait implementers in E0277 when calling rustc with --verbose

Signed-off-by: rongfu.leng <lenronfu@gmail.com>
This commit is contained in:
rongfu.leng 2024-06-06 09:38:09 +08:00
parent db8aca4812
commit 69769fc797

View file

@ -2082,12 +2082,16 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
})
.collect();
let end = if candidates.len() <= 9 { candidates.len() } else { 8 };
let end = if candidates.len() <= 9 || self.tcx.sess.opts.verbose {
candidates.len()
} else {
8
};
err.help(format!(
"the following {other}types implement trait `{}`:{}{}",
trait_ref.print_trait_sugared(),
candidates[..end].join(""),
if candidates.len() > 9 {
if candidates.len() > 9 && !self.tcx.sess.opts.verbose {
format!("\nand {} others", candidates.len() - 8)
} else {
String::new()