1
Fork 0

Rollup merge of #115196 - chenyukang:yukang-fix-86094, r=estebank

Suggest adding `return` if the for semi which can coerce to the fn return type

Fixes #86094
r? `@estebank`
This commit is contained in:
Matthias Krüger 2023-10-16 06:26:20 +02:00 committed by GitHub
commit 1de910fc0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 230 additions and 12 deletions

View file

@ -17,7 +17,7 @@ use crate::traits::{
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_errors::{
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
MultiSpan, Style,
MultiSpan, StashKey, Style,
};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Namespace, Res};
@ -2049,14 +2049,14 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
// begin with in those cases.
if self.tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) {
if let None = self.tainted_by_errors() {
self.emit_inference_failure_err(
let err = self.emit_inference_failure_err(
obligation.cause.body_id,
span,
trait_ref.self_ty().skip_binder().into(),
ErrorCode::E0282,
false,
)
.emit();
);
err.stash(span, StashKey::MaybeForgetReturn);
}
return;
}