Skip to content

Commit e643f59

Browse files
committed
Auto merge of #139482 - Zalathar:rollup-h2ht1y6, r=Zalathar
Rollup of 9 pull requests Successful merges: - #139035 (Add new `PatKind::Missing` variants) - #139108 (Simplify `thir::PatKind::ExpandedConstant`) - #139112 (Implement `super let`) - #139365 (Default auto traits: fix perf) - #139397 (coverage: Build the CGU's global file table as late as possible) - #139455 ( Remove support for `extern "rust-intrinsic"` blocks) - #139461 (Stop calling `source_span` query in significant drop order code) - #139465 (add sret handling for scalar autodiff) - #139466 (Trivial tweaks to stop tracking source span directly) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8fb32ab + 6e0b674 commit e643f59

File tree

166 files changed

+1799
-1645
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+1799
-1645
lines changed

compiler/rustc_abi/src/extern_abi.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ pub enum ExternAbi {
6060
System {
6161
unwind: bool,
6262
},
63-
RustIntrinsic,
6463
RustCall,
6564
/// *Not* a stable ABI, just directly use the Rust types to describe the ABI for LLVM. Even
6665
/// normally ABI-compatible Rust types can become ABI-incompatible with this ABI!
@@ -128,7 +127,6 @@ abi_impls! {
128127
RiscvInterruptS =><= "riscv-interrupt-s",
129128
RustCall =><= "rust-call",
130129
RustCold =><= "rust-cold",
131-
RustIntrinsic =><= "rust-intrinsic",
132130
Stdcall { unwind: false } =><= "stdcall",
133131
Stdcall { unwind: true } =><= "stdcall-unwind",
134132
System { unwind: false } =><= "system",
@@ -199,7 +197,7 @@ impl ExternAbi {
199197
/// - are subject to change between compiler versions
200198
pub fn is_rustic_abi(self) -> bool {
201199
use ExternAbi::*;
202-
matches!(self, Rust | RustCall | RustIntrinsic | RustCold)
200+
matches!(self, Rust | RustCall | RustCold)
203201
}
204202

205203
pub fn supports_varargs(self) -> bool {

compiler/rustc_ast/src/ast.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ impl Pat {
563563
/// This is intended for use by diagnostics.
564564
pub fn to_ty(&self) -> Option<P<Ty>> {
565565
let kind = match &self.kind {
566+
PatKind::Missing => unreachable!(),
566567
// In a type expression `_` is an inference variable.
567568
PatKind::Wild => TyKind::Infer,
568569
// An IDENT pattern with no binding mode would be valid as path to a type. E.g. `u32`.
@@ -625,7 +626,8 @@ impl Pat {
625626
| PatKind::Guard(s, _) => s.walk(it),
626627

627628
// These patterns do not contain subpatterns, skip.
628-
PatKind::Wild
629+
PatKind::Missing
630+
| PatKind::Wild
629631
| PatKind::Rest
630632
| PatKind::Never
631633
| PatKind::Expr(_)
@@ -676,6 +678,7 @@ impl Pat {
676678
/// Return a name suitable for diagnostics.
677679
pub fn descr(&self) -> Option<String> {
678680
match &self.kind {
681+
PatKind::Missing => unreachable!(),
679682
PatKind::Wild => Some("_".to_string()),
680683
PatKind::Ident(BindingMode::NONE, ident, None) => Some(format!("{ident}")),
681684
PatKind::Ref(pat, mutbl) => pat.descr().map(|d| format!("&{}{d}", mutbl.prefix_str())),
@@ -769,6 +772,9 @@ pub enum RangeSyntax {
769772
// Adding a new variant? Please update `test_pat` in `tests/ui/macros/stringify.rs`.
770773
#[derive(Clone, Encodable, Decodable, Debug)]
771774
pub enum PatKind {
775+
/// A missing pattern, e.g. for an anonymous param in a bare fn like `fn f(u32)`.
776+
Missing,
777+
772778
/// Represents a wildcard pattern (`_`).
773779
Wild,
774780

@@ -1169,6 +1175,7 @@ pub enum MacStmtStyle {
11691175
#[derive(Clone, Encodable, Decodable, Debug)]
11701176
pub struct Local {
11711177
pub id: NodeId,
1178+
pub super_: Option<Span>,
11721179
pub pat: P<Pat>,
11731180
pub ty: Option<P<Ty>>,
11741181
pub kind: LocalKind,
@@ -3926,7 +3933,7 @@ mod size_asserts {
39263933
static_assert_size!(Item, 144);
39273934
static_assert_size!(ItemKind, 80);
39283935
static_assert_size!(LitKind, 24);
3929-
static_assert_size!(Local, 80);
3936+
static_assert_size!(Local, 96);
39303937
static_assert_size!(MetaItemLit, 40);
39313938
static_assert_size!(Param, 40);
39323939
static_assert_size!(Pat, 72);

compiler/rustc_ast/src/expand/autodiff_attrs.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ pub struct AutoDiffAttrs {
9292
pub input_activity: Vec<DiffActivity>,
9393
}
9494

95+
impl AutoDiffAttrs {
96+
pub fn has_primal_ret(&self) -> bool {
97+
matches!(self.ret_activity, DiffActivity::Active | DiffActivity::Dual)
98+
}
99+
}
100+
95101
impl DiffMode {
96102
pub fn is_rev(&self) -> bool {
97103
matches!(self, DiffMode::Reverse)

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,8 @@ fn walk_parenthesized_parameter_data<T: MutVisitor>(vis: &mut T, args: &mut Pare
704704
}
705705

706706
fn walk_local<T: MutVisitor>(vis: &mut T, local: &mut P<Local>) {
707-
let Local { id, pat, ty, kind, span, colon_sp, attrs, tokens } = local.deref_mut();
707+
let Local { id, super_, pat, ty, kind, span, colon_sp, attrs, tokens } = local.deref_mut();
708+
visit_opt(super_, |sp| vis.visit_span(sp));
708709
vis.visit_id(id);
709710
visit_attrs(vis, attrs);
710711
vis.visit_pat(pat);
@@ -1587,7 +1588,7 @@ pub fn walk_pat<T: MutVisitor>(vis: &mut T, pat: &mut P<Pat>) {
15871588
vis.visit_id(id);
15881589
match kind {
15891590
PatKind::Err(_guar) => {}
1590-
PatKind::Wild | PatKind::Rest | PatKind::Never => {}
1591+
PatKind::Missing | PatKind::Wild | PatKind::Rest | PatKind::Never => {}
15911592
PatKind::Ident(_binding_mode, ident, sub) => {
15921593
vis.visit_ident(ident);
15931594
visit_opt(sub, |sub| vis.visit_pat(sub));

compiler/rustc_ast/src/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ pub fn walk_crate<'a, V: Visitor<'a>>(visitor: &mut V, krate: &'a Crate) -> V::R
323323
}
324324

325325
pub fn walk_local<'a, V: Visitor<'a>>(visitor: &mut V, local: &'a Local) -> V::Result {
326-
let Local { id: _, pat, ty, kind, span: _, colon_sp: _, attrs, tokens: _ } = local;
326+
let Local { id: _, super_: _, pat, ty, kind, span: _, colon_sp: _, attrs, tokens: _ } = local;
327327
walk_list!(visitor, visit_attribute, attrs);
328328
try_visit!(visitor.visit_pat(pat));
329329
visit_opt!(visitor, visit_ty, ty);
@@ -750,7 +750,7 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) -> V::Res
750750
try_visit!(visitor.visit_pat(subpattern));
751751
try_visit!(visitor.visit_expr(guard_condition));
752752
}
753-
PatKind::Wild | PatKind::Rest | PatKind::Never => {}
753+
PatKind::Missing | PatKind::Wild | PatKind::Rest | PatKind::Never => {}
754754
PatKind::Err(_guar) => {}
755755
PatKind::Tuple(elems) | PatKind::Slice(elems) | PatKind::Or(elems) => {
756756
walk_list!(visitor, visit_pat, elems);

compiler/rustc_ast_lowering/src/block.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
9595

9696
fn lower_local(&mut self, l: &Local) -> &'hir hir::LetStmt<'hir> {
9797
// Let statements are allowed to have impl trait in bindings.
98+
let super_ = l.super_;
9899
let ty = l.ty.as_ref().map(|t| {
99100
self.lower_ty(t, self.impl_trait_in_bindings_ctxt(ImplTraitPosition::Variable))
100101
});
@@ -109,7 +110,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
109110
let span = self.lower_span(l.span);
110111
let source = hir::LocalSource::Normal;
111112
self.lower_attrs(hir_id, &l.attrs, l.span);
112-
self.arena.alloc(hir::LetStmt { hir_id, ty, pat, init, els, span, source })
113+
self.arena.alloc(hir::LetStmt { hir_id, super_, ty, pat, init, els, span, source })
113114
}
114115

115116
fn lower_block_check_mode(&mut self, b: &BlockCheckMode) -> hir::BlockCheckMode {

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,18 +1496,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14961496

14971497
fn lower_fn_params_to_names(&mut self, decl: &FnDecl) -> &'hir [Option<Ident>] {
14981498
self.arena.alloc_from_iter(decl.inputs.iter().map(|param| match param.pat.kind {
1499-
PatKind::Ident(_, ident, _) => {
1500-
if ident.name != kw::Empty {
1501-
Some(self.lower_ident(ident))
1502-
} else {
1503-
None
1504-
}
1505-
}
1499+
PatKind::Missing => None,
1500+
PatKind::Ident(_, ident, _) => Some(self.lower_ident(ident)),
15061501
PatKind::Wild => Some(Ident::new(kw::Underscore, self.lower_span(param.pat.span))),
15071502
_ => {
15081503
self.dcx().span_delayed_bug(
15091504
param.pat.span,
1510-
"non-ident/wild param pat must trigger an error",
1505+
"non-missing/ident/wild param pat must trigger an error",
15111506
);
15121507
None
15131508
}
@@ -2223,6 +2218,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22232218
self.attrs.insert(hir_id.local_id, a);
22242219
}
22252220
let local = hir::LetStmt {
2221+
super_: None,
22262222
hir_id,
22272223
init,
22282224
pat,

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2626
let pat_hir_id = self.lower_node_id(pattern.id);
2727
let node = loop {
2828
match &pattern.kind {
29+
PatKind::Missing => break hir::PatKind::Missing,
2930
PatKind::Wild => break hir::PatKind::Wild,
3031
PatKind::Never => break hir::PatKind::Never,
3132
PatKind::Ident(binding_mode, ident, sub) => {

compiler/rustc_ast_lowering/src/stability.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ pub fn extern_abi_stability(abi: ExternAbi) -> Result<(), UnstableAbi> {
7979
| ExternAbi::SysV64 { .. }
8080
| ExternAbi::System { .. }
8181
| ExternAbi::EfiApi => Ok(()),
82-
// implementation details
83-
ExternAbi::RustIntrinsic => {
84-
Err(UnstableAbi { abi, feature: sym::intrinsics, explain: GateReason::ImplDetail })
85-
}
8682
ExternAbi::Unadjusted => {
8783
Err(UnstableAbi { abi, feature: sym::abi_unadjusted, explain: GateReason::ImplDetail })
8884
}

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl<'a> AstValidator<'a> {
244244
fn check_decl_no_pat(decl: &FnDecl, mut report_err: impl FnMut(Span, Option<Ident>, bool)) {
245245
for Param { pat, .. } in &decl.inputs {
246246
match pat.kind {
247-
PatKind::Ident(BindingMode::NONE, _, None) | PatKind::Wild => {}
247+
PatKind::Missing | PatKind::Ident(BindingMode::NONE, _, None) | PatKind::Wild => {}
248248
PatKind::Ident(BindingMode::MUT, ident, None) => {
249249
report_err(pat.span, Some(ident), true)
250250
}

0 commit comments

Comments
 (0)