Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #98129

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -609,13 +609,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
});

// `static |_task_context| -> <ret_ty> { 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,
Expand Down Expand Up @@ -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;
Expand All @@ -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(
Expand Down Expand Up @@ -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!(
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
29 changes: 1 addition & 28 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand Down
22 changes: 12 additions & 10 deletions compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -336,7 +337,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
Some(RegionName {
name: region_name,
source: RegionNameSource::SynthesizedFreeEnvRegion(
args_span,
fn_decl_span,
note.to_string(),
),
})
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
};

Expand Down
Loading