rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.51k stars 12.73k forks source link

Detect spurious `;` before assoc fn body #105226

Closed estebank closed 1 year ago

estebank commented 1 year ago

When copying bounds from a trait assoc item, you can accidentally copy the semicolon. If you forget to remove it, multiple errors are emitted, while the second is:

error: associated function in `impl` without body
    --> compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs:2349:5
     |
2349 | /     fn note_obligation_cause_code<T>(
2350 | |         &self,
2351 | |         err: &mut Diagnostic,
2352 | |         predicate: &T,
...    |
2357 | |     ) where
2358 | |         T: fmt::Display + ToPredicate<'tcx, T>;
     | |                                               ^ help: provide a definition for the function: `{ <body> }`
     | |_______________________________________________|

This should be explicitly handled to avoid knock down errors.

chenyukang commented 1 year ago

@rustbot claim