Skip to content

Commit 12358a7

Browse files
authored
Rollup merge of rust-lang#126055 - lengrongfu:master, r=pnkfelix
Expand list of trait implementers in E0277 when calling rustc with --verbose Fixes: rust-lang#125984 - Build `rustc` use `./x build`. - Test result <img width="634" alt="image" src="https://github.com/rust-lang/rust/assets/15009201/89377059-2316-492b-a38a-fa33adfc9793"> - vim test.rs ```rust trait Reconcile { fn reconcile(&self); } // Implementing the trait for some types impl Reconcile for bool { fn reconcile(&self) { println!("Reconciling bool"); } } impl Reconcile for i8 { fn reconcile(&self) { println!("Reconciling i8"); } } impl Reconcile for i16 { fn reconcile(&self) { println!("Reconciling i16"); } } impl Reconcile for i32 { fn reconcile(&self) { println!("Reconciling i32"); } } impl Reconcile for i64 { fn reconcile(&self) { println!("Reconciling i64"); } } impl Reconcile for u8 { fn reconcile(&self) { println!("Reconciling u8"); } } impl Reconcile for u16 { fn reconcile(&self) { println!("Reconciling u16"); } } impl Reconcile for u32 { fn reconcile(&self) { println!("Reconciling u32"); } } impl Reconcile for i128 { fn reconcile(&self) { println!("Reconciling u32"); } } impl Reconcile for u128 { fn reconcile(&self) { println!("Reconciling u32"); } } fn process<T: Reconcile>(item: T) { item.reconcile(); } fn main() { let value = String::from("This will cause an error"); process(value); // This line will cause a compilation error } ```
2 parents 260f789 + 69769fc commit 12358a7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -2069,12 +2069,16 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20692069
})
20702070
.collect();
20712071

2072-
let end = if candidates.len() <= 9 { candidates.len() } else { 8 };
2072+
let end = if candidates.len() <= 9 || self.tcx.sess.opts.verbose {
2073+
candidates.len()
2074+
} else {
2075+
8
2076+
};
20732077
err.help(format!(
20742078
"the following {other}types implement trait `{}`:{}{}",
20752079
trait_ref.print_trait_sugared(),
20762080
candidates[..end].join(""),
2077-
if candidates.len() > 9 {
2081+
if candidates.len() > 9 && !self.tcx.sess.opts.verbose {
20782082
format!("\nand {} others", candidates.len() - 8)
20792083
} else {
20802084
String::new()

0 commit comments

Comments
 (0)