diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 3a33a9debaa..0786ae330e0 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -577,7 +577,7 @@ impl<'hir> LoweringContext<'_, 'hir> { }; // The closure/generator `FnDecl` takes a single (resume) argument of type `input_ty`. - let decl = self.arena.alloc(hir::FnDecl { + let fn_decl = self.arena.alloc(hir::FnDecl { inputs: arena_vec![self; input_ty], output, c_variadic: false, @@ -598,7 +598,7 @@ impl<'hir> LoweringContext<'_, 'hir> { }; let params = arena_vec![self; param]; - let body_id = self.lower_body(move |this| { + let body = self.lower_body(move |this| { this.generator_kind = Some(hir::GeneratorKind::Async(async_gen_kind)); let old_ctx = this.task_context; @@ -609,13 +609,13 @@ impl<'hir> LoweringContext<'_, 'hir> { }); // `static |_task_context| -> { body }`: - let generator_kind = hir::ExprKind::Closure( + let generator_kind = hir::ExprKind::Closure { capture_clause, - decl, - body_id, - self.lower_span(span), - Some(hir::Movability::Static), - ); + fn_decl, + body, + fn_decl_span: self.lower_span(span), + movability: Some(hir::Movability::Static), + }; let generator = hir::Expr { hir_id: self.lower_node_id(closure_node_id), kind: generator_kind, @@ -840,7 +840,7 @@ impl<'hir> LoweringContext<'_, 'hir> { body: &Expr, fn_decl_span: Span, ) -> hir::ExprKind<'hir> { - let (body_id, generator_option) = self.with_new_scopes(move |this| { + let (body, generator_option) = self.with_new_scopes(move |this| { let prev = this.current_item; this.current_item = Some(fn_decl_span); let mut generator_kind = None; @@ -858,13 +858,13 @@ impl<'hir> LoweringContext<'_, 'hir> { // Lower outside new scope to preserve `is_in_loop_condition`. let fn_decl = self.lower_fn_decl(decl, None, FnDeclKind::Closure, None); - hir::ExprKind::Closure( + hir::ExprKind::Closure { capture_clause, fn_decl, - body_id, - self.lower_span(fn_decl_span), - generator_option, - ) + body, + fn_decl_span: self.lower_span(fn_decl_span), + movability: generator_option, + } } fn generator_movability_for_fn( @@ -911,7 +911,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let outer_decl = FnDecl { inputs: decl.inputs.clone(), output: FnRetTy::Default(fn_decl_span) }; - let body_id = self.with_new_scopes(|this| { + let body = self.with_new_scopes(|this| { // FIXME(cramertj): allow `async` non-`move` closures with arguments. if capture_clause == CaptureBy::Ref && !decl.inputs.is_empty() { struct_span_err!( @@ -950,13 +950,13 @@ impl<'hir> LoweringContext<'_, 'hir> { // closure argument types. let fn_decl = self.lower_fn_decl(&outer_decl, None, FnDeclKind::Closure, None); - hir::ExprKind::Closure( + hir::ExprKind::Closure { capture_clause, fn_decl, - body_id, - self.lower_span(fn_decl_span), - None, - ) + body, + fn_decl_span: self.lower_span(fn_decl_span), + movability: None, + } } /// Destructure the LHS of complex assignments. diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 6db9c46dcef..4024f883f37 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -406,8 +406,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { // Emit errors for non-staged-api crates. if !self.features.staged_api { - if attr.has_name(sym::rustc_deprecated) - || attr.has_name(sym::unstable) + if attr.has_name(sym::unstable) || attr.has_name(sym::stable) || attr.has_name(sym::rustc_const_unstable) || attr.has_name(sym::rustc_const_stable) diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index bdf86825f0d..ce7c0eb72cd 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -720,18 +720,10 @@ where let is_rustc = sess.features_untracked().staged_api; 'outer: for attr in attrs_iter { - if !(attr.has_name(sym::deprecated) || attr.has_name(sym::rustc_deprecated)) { + if !attr.has_name(sym::deprecated) { continue; } - // FIXME(jhpratt) remove this eventually - if attr.has_name(sym::rustc_deprecated) { - diagnostic - .struct_span_err(attr.span, "`#[rustc_deprecated]` has been removed") - .help("use `#[deprecated]` instead") - .emit(); - } - let Some(meta) = attr.meta() else { continue; }; @@ -787,25 +779,6 @@ where continue 'outer; } } - // FIXME(jhpratt) remove this eventually - sym::reason if attr.has_name(sym::rustc_deprecated) => { - if !get(mi, &mut note) { - continue 'outer; - } - - let mut diag = diagnostic - .struct_span_err(mi.span, "`reason` has been renamed"); - match note { - Some(note) => diag.span_suggestion( - mi.span, - "use `note` instead", - format!("note = \"{note}\""), - Applicability::MachineApplicable, - ), - None => diag.span_help(mi.span, "use `note` instead"), - }; - diag.emit(); - } sym::suggestion => { if !sess.features_untracked().deprecated_suggestion { let mut diag = sess.struct_span_err( diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 97e49cb472f..fbc3a8cc088 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -896,7 +896,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(local_did); let expr = &self.infcx.tcx.hir().expect_expr(hir_id).kind; debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr); - if let hir::ExprKind::Closure(.., body_id, args_span, _) = expr { + if let hir::ExprKind::Closure { body, fn_decl_span, .. } = expr { for (captured_place, place) in self .infcx .tcx @@ -909,11 +909,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { if target_place == place.as_ref() => { debug!("closure_span: found captured local {:?}", place); - let body = self.infcx.tcx.hir().body(*body_id); + let body = self.infcx.tcx.hir().body(*body); let generator_kind = body.generator_kind(); return Some(( - *args_span, + *fn_decl_span, generator_kind, captured_place.get_capture_kind_span(self.infcx.tcx), captured_place.get_path_span(self.infcx.tcx), diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index fcb6ae438fe..d6b5089712a 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -311,8 +311,9 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { // Can't have BrEnv in functions, constants or generators. bug!("BrEnv outside of closure."); }; - let hir::ExprKind::Closure(_, _, _, args_span, _) = - tcx.hir().expect_expr(self.mir_hir_id()).kind else { + let hir::ExprKind::Closure { fn_decl_span, .. } + = tcx.hir().expect_expr(self.mir_hir_id()).kind + else { bug!("Closure is not defined by a closure expr"); }; let region_name = self.synthesize_region_name(); @@ -336,7 +337,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { Some(RegionName { name: region_name, source: RegionNameSource::SynthesizedFreeEnvRegion( - args_span, + fn_decl_span, note.to_string(), ), }) @@ -683,16 +684,16 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { let (return_span, mir_description, hir_ty) = match hir.get(mir_hir_id) { hir::Node::Expr(hir::Expr { - kind: hir::ExprKind::Closure(_, return_ty, body_id, span, _), + kind: hir::ExprKind::Closure { fn_decl, body, fn_decl_span, .. }, .. }) => { - let (mut span, mut hir_ty) = match return_ty.output { + let (mut span, mut hir_ty) = match fn_decl.output { hir::FnRetTy::DefaultReturn(_) => { - (tcx.sess.source_map().end_point(*span), None) + (tcx.sess.source_map().end_point(*fn_decl_span), None) } - hir::FnRetTy::Return(hir_ty) => (return_ty.output.span(), Some(hir_ty)), + hir::FnRetTy::Return(hir_ty) => (fn_decl.output.span(), Some(hir_ty)), }; - let mir_description = match hir.body(*body_id).generator_kind { + let mir_description = match hir.body(*body).generator_kind { Some(hir::GeneratorKind::Async(gen)) => match gen { hir::AsyncGeneratorKind::Block => " of async block", hir::AsyncGeneratorKind::Closure => " of async closure", @@ -822,8 +823,9 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { let yield_span = match tcx.hir().get(self.mir_hir_id()) { hir::Node::Expr(hir::Expr { - kind: hir::ExprKind::Closure(_, _, _, span, _), .. - }) => (tcx.sess.source_map().end_point(*span)), + kind: hir::ExprKind::Closure { fn_decl_span, .. }, + .. + }) => (tcx.sess.source_map().end_point(*fn_decl_span)), _ => self.body.span, }; diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 34c53597dde..d4452a79dfb 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -489,11 +489,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ // ========================================================================== ungated!(feature, CrateLevel, template!(List: "name1, name2, ..."), DuplicatesOk), - // FIXME(jhpratt) remove this eventually - ungated!( - rustc_deprecated, Normal, - template!(List: r#"since = "version", note = "...""#), ErrorFollowing - ), // DuplicatesOk since it has its own validation ungated!( stable, Normal, template!(List: r#"feature = "name", since = "version""#), DuplicatesOk, diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index bd5973f31cf..5a06f8eab7e 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1652,7 +1652,7 @@ impl Expr<'_> { ExprKind::Let(..) => ExprPrecedence::Let, ExprKind::Loop(..) => ExprPrecedence::Loop, ExprKind::Match(..) => ExprPrecedence::Match, - ExprKind::Closure(..) => ExprPrecedence::Closure, + ExprKind::Closure { .. } => ExprPrecedence::Closure, ExprKind::Block(..) => ExprPrecedence::Block, ExprKind::Assign(..) => ExprPrecedence::Assign, ExprKind::AssignOp(..) => ExprPrecedence::AssignOp, @@ -1712,7 +1712,7 @@ impl Expr<'_> { | ExprKind::Tup(..) | ExprKind::If(..) | ExprKind::Match(..) - | ExprKind::Closure(..) + | ExprKind::Closure { .. } | ExprKind::Block(..) | ExprKind::Repeat(..) | ExprKind::Array(..) @@ -1795,7 +1795,7 @@ impl Expr<'_> { | ExprKind::Match(..) | ExprKind::MethodCall(..) | ExprKind::Call(..) - | ExprKind::Closure(..) + | ExprKind::Closure { .. } | ExprKind::Block(..) | ExprKind::Repeat(..) | ExprKind::Break(..) @@ -1930,7 +1930,13 @@ pub enum ExprKind<'hir> { /// /// This may also be a generator literal or an `async block` as indicated by the /// `Option`. - Closure(CaptureBy, &'hir FnDecl<'hir>, BodyId, Span, Option), + Closure { + capture_clause: CaptureBy, + fn_decl: &'hir FnDecl<'hir>, + body: BodyId, + fn_decl_span: Span, + movability: Option, + }, /// A block (e.g., `'label: { ... }`). Block(&'hir Block<'hir>, Option