1
Fork 0

Rollup merge of #100617 - chenyukang:fix-100605, r=compiler-errors

Suggest the right help message for as_ref

Fixes #100605
This commit is contained in:
Matthias Krüger 2022-08-20 07:09:00 +02:00 committed by GitHub
commit 61a529d902
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 1 deletions

View file

@ -2079,7 +2079,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
diag.span_suggestion(
span,
*msg,
format!("{}.as_ref()", snippet),
// HACK: fix issue# 100605, suggesting convert from &Option<T> to Option<&T>, remove the extra `&`
format!("{}.as_ref()", snippet.trim_start_matches('&')),
Applicability::MachineApplicable,
);
}