use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxHashSet;
-use rustc_errors::{Applicability, DiagnosticBuilder, ErrorReported};
+use rustc_errors::{Applicability, Diagnostic, ErrorReported};
use rustc_hir as hir;
use rustc_hir::def::{CtorOf, DefKind, Res};
use rustc_hir::def_id::DefId;
) => {
// A reborrow has no effect before a dereference.
}
+ // Catch cases which have Deref(None)
+ // having them slip to bug! causes ICE
+ // see #94291 for more info
+ (&[Adjustment { kind: Adjust::Deref(None), .. }], _) => {
+ self.tcx.sess.delay_span_bug(
+ DUMMY_SP,
+ &format!("Can't compose Deref(None) expressions"),
+ )
+ }
// FIXME: currently we never try to compose autoderefs
// and ReifyFnPointer/UnsafeFnPointer, but we could.
_ => bug!(
formal_args: &[Ty<'tcx>],
) -> Vec<Ty<'tcx>> {
let formal_ret = self.resolve_vars_with_obligations(formal_ret);
- let ret_ty = match expected_ret.only_has_type(self) {
- Some(ret) => ret,
- None => return Vec::new(),
- };
+ let Some(ret_ty) = expected_ret.only_has_type(self) else { return Vec::new() };
let expect_args = self
.fudge_inference_if_ok(|| {
// Attempt to apply a subtyping relationship between the formal
pub(in super::super) fn note_internal_mutation_in_method(
&self,
- err: &mut DiagnosticBuilder<'_>,
+ err: &mut Diagnostic,
expr: &hir::Expr<'_>,
expected: Ty<'tcx>,
found: Ty<'tcx>,
pub(in super::super) fn note_need_for_fn_pointer(
&self,
- err: &mut DiagnosticBuilder<'_>,
+ err: &mut Diagnostic,
expected: Ty<'tcx>,
found: Ty<'tcx>,
) {
// Be helpful when the user wrote `{... expr;}` and
// taking the `;` off is enough to fix the error.
let last_stmt = blk.stmts.last()?;
- let last_expr = match last_stmt.kind {
- hir::StmtKind::Semi(ref e) => e,
- _ => return None,
+ let hir::StmtKind::Semi(ref last_expr) = last_stmt.kind else {
+ return None;
};
let last_expr_ty = self.node_ty(last_expr.hir_id);
let needs_box = match (last_expr_ty.kind(), expected_ty.kind()) {
last_def_id, last_bounds, exp_def_id, exp_bounds
);
- let (last_local_id, exp_local_id) =
- match (last_def_id.as_local(), exp_def_id.as_local()) {
- (Some(last_hir_id), Some(exp_hir_id)) => (last_hir_id, exp_hir_id),
- (_, _) => return None,
- };
+ let last_local_id = last_def_id.as_local()?;
+ let exp_local_id = exp_def_id.as_local()?;
match (
&self.tcx.hir().expect_item(last_local_id).kind,