1
Fork 0

Rollup merge of #104895 - chenyukang:yukang/fix-104884-serde, r=TaKO8Ki

Avoid Invalid code suggested when encountering unsatisfied trait bounds in derive macro code

Fixes #104884
This commit is contained in:
Matthias Krüger 2022-11-30 19:53:18 +01:00 committed by GitHub
commit eabc0720a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 97 additions and 0 deletions

View file

@ -355,6 +355,12 @@ pub fn suggest_constraining_type_params<'a>(
));
}
// FIXME: remove the suggestions that are from derive, as the span is not correct
suggestions = suggestions
.into_iter()
.filter(|(span, _, _)| !span.in_derive_expansion())
.collect::<Vec<_>>();
if suggestions.len() == 1 {
let (span, suggestion, msg) = suggestions.pop().unwrap();