Skip to content

Commit b8e1d7e

Browse files
committed
Auto merge of #3706 - rust-lang:rustup-2024-06-24, r=oli-obk
Automatic Rustup
2 parents aded2be + c660016 commit b8e1d7e

File tree

433 files changed

+10901
-5557
lines changed

Some content is hidden

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

433 files changed

+10901
-5557
lines changed

Cargo.lock

Lines changed: 58 additions & 128 deletions
Large diffs are not rendered by default.

compiler/rustc_ast/src/token.rs

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
pub use BinOpToken::*;
22
pub use LitKind::*;
33
pub use Nonterminal::*;
4+
pub use NtExprKind::*;
5+
pub use NtPatKind::*;
46
pub use TokenKind::*;
57

68
use crate::ast;
@@ -871,6 +873,27 @@ impl PartialEq<TokenKind> for Token {
871873
}
872874
}
873875

876+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable)]
877+
pub enum NtPatKind {
878+
// Matches or-patterns. Was written using `pat` in edition 2021 or later.
879+
PatWithOr,
880+
// Doesn't match or-patterns.
881+
// - `inferred`: was written using `pat` in edition 2015 or 2018.
882+
// - `!inferred`: was written using `pat_param`.
883+
PatParam { inferred: bool },
884+
}
885+
886+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable)]
887+
pub enum NtExprKind {
888+
// Matches expressions using the post-edition 2024. Was written using
889+
// `expr` in edition 2024 or later.
890+
Expr,
891+
// Matches expressions using the pre-edition 2024 rules.
892+
// - `inferred`: was written using `expr` in edition 2021 or earlier.
893+
// - `!inferred`: was written using `expr_2021`.
894+
Expr2021 { inferred: bool },
895+
}
896+
874897
#[derive(Clone, Encodable, Decodable)]
875898
/// For interpolation during macro expansion.
876899
pub enum Nonterminal {
@@ -892,19 +915,8 @@ pub enum NonterminalKind {
892915
Item,
893916
Block,
894917
Stmt,
895-
PatParam {
896-
/// Keep track of whether the user used `:pat_param` or `:pat` and we inferred it from the
897-
/// edition of the span. This is used for diagnostics.
898-
inferred: bool,
899-
},
900-
PatWithOr,
901-
Expr,
902-
/// Matches an expression using the rules from edition 2021 and earlier.
903-
Expr2021 {
904-
/// Keep track of whether the user used `:expr` or `:expr_2021` and we inferred it from the
905-
/// edition of the span. This is used for diagnostics AND feature gating.
906-
inferred: bool,
907-
},
918+
Pat(NtPatKind),
919+
Expr(NtExprKind),
908920
Ty,
909921
Ident,
910922
Lifetime,
@@ -926,20 +938,22 @@ impl NonterminalKind {
926938
sym::item => NonterminalKind::Item,
927939
sym::block => NonterminalKind::Block,
928940
sym::stmt => NonterminalKind::Stmt,
929-
sym::pat => match edition() {
930-
Edition::Edition2015 | Edition::Edition2018 => {
931-
NonterminalKind::PatParam { inferred: true }
941+
sym::pat => {
942+
if edition().at_least_rust_2021() {
943+
NonterminalKind::Pat(PatWithOr)
944+
} else {
945+
NonterminalKind::Pat(PatParam { inferred: true })
932946
}
933-
Edition::Edition2021 | Edition::Edition2024 => NonterminalKind::PatWithOr,
934-
},
935-
sym::pat_param => NonterminalKind::PatParam { inferred: false },
936-
sym::expr => match edition() {
937-
Edition::Edition2015 | Edition::Edition2018 | Edition::Edition2021 => {
938-
NonterminalKind::Expr2021 { inferred: true }
947+
}
948+
sym::pat_param => NonterminalKind::Pat(PatParam { inferred: false }),
949+
sym::expr => {
950+
if edition().at_least_rust_2024() {
951+
NonterminalKind::Expr(Expr)
952+
} else {
953+
NonterminalKind::Expr(Expr2021 { inferred: true })
939954
}
940-
Edition::Edition2024 => NonterminalKind::Expr,
941-
},
942-
sym::expr_2021 => NonterminalKind::Expr2021 { inferred: false },
955+
}
956+
sym::expr_2021 => NonterminalKind::Expr(Expr2021 { inferred: false }),
943957
sym::ty => NonterminalKind::Ty,
944958
sym::ident => NonterminalKind::Ident,
945959
sym::lifetime => NonterminalKind::Lifetime,
@@ -951,15 +965,16 @@ impl NonterminalKind {
951965
_ => return None,
952966
})
953967
}
968+
954969
fn symbol(self) -> Symbol {
955970
match self {
956971
NonterminalKind::Item => sym::item,
957972
NonterminalKind::Block => sym::block,
958973
NonterminalKind::Stmt => sym::stmt,
959-
NonterminalKind::PatParam { inferred: false } => sym::pat_param,
960-
NonterminalKind::PatParam { inferred: true } | NonterminalKind::PatWithOr => sym::pat,
961-
NonterminalKind::Expr | NonterminalKind::Expr2021 { inferred: true } => sym::expr,
962-
NonterminalKind::Expr2021 { inferred: false } => sym::expr_2021,
974+
NonterminalKind::Pat(PatParam { inferred: true } | PatWithOr) => sym::pat,
975+
NonterminalKind::Pat(PatParam { inferred: false }) => sym::pat_param,
976+
NonterminalKind::Expr(Expr2021 { inferred: true } | Expr) => sym::expr,
977+
NonterminalKind::Expr(Expr2021 { inferred: false }) => sym::expr_2021,
963978
NonterminalKind::Ty => sym::ty,
964979
NonterminalKind::Ident => sym::ident,
965980
NonterminalKind::Lifetime => sym::lifetime,

compiler/rustc_ast_passes/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ast_passes_auto_super_lifetime = auto traits cannot have super traits or lifetim
2828
.label = {ast_passes_auto_super_lifetime}
2929
.suggestion = remove the super traits or lifetime bounds
3030
31-
ast_passes_bad_c_variadic = only foreign or `unsafe extern "C"` functions may be C-variadic
31+
ast_passes_bad_c_variadic = only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg
3232
3333
ast_passes_bare_fn_invalid_safety = function pointers cannot be declared with `safe` safety qualifier
3434
.suggestion = remove safe from this item

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ impl<'a> AstValidator<'a> {
637637
(Some(FnCtxt::Foreign), _) => return,
638638
(Some(FnCtxt::Free), Some(header)) => match header.ext {
639639
Extern::Explicit(StrLit { symbol_unescaped: sym::C, .. }, _)
640+
| Extern::Explicit(StrLit { symbol_unescaped: sym::C_dash_unwind, .. }, _)
640641
| Extern::Implicit(_)
641642
if matches!(header.safety, Safety::Unsafe(_)) =>
642643
{
@@ -898,7 +899,7 @@ fn validate_generic_param_order(dcx: DiagCtxtHandle<'_>, generics: &[GenericPara
898899

899900
impl<'a> Visitor<'a> for AstValidator<'a> {
900901
fn visit_attribute(&mut self, attr: &Attribute) {
901-
validate_attr::check_attr(&self.session.psess, attr);
902+
validate_attr::check_attr(&self.features, &self.session.psess, attr);
902903
}
903904

904905
fn visit_ty(&mut self, ty: &'a Ty) {

compiler/rustc_borrowck/src/borrow_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl<'tcx> BorrowSet<'tcx> {
126126
) -> Self {
127127
let mut visitor = GatherBorrows {
128128
tcx,
129-
body: body,
129+
body,
130130
location_map: Default::default(),
131131
activation_map: Default::default(),
132132
local_map: Default::default(),

compiler/rustc_borrowck/src/borrowck_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
213213
via(msg_old),
214214
);
215215

216-
if msg_new == "" {
216+
if msg_new.is_empty() {
217217
// If `msg_new` is empty, then this isn't a borrow of a union field.
218218
err.span_label(span, format!("{kind_new} borrow occurs here"));
219219
err.span_label(old_span, format!("{kind_old} borrow occurs here"));

compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ impl<'mir, 'tcx> ResultsVisitable<'tcx> for BorrowckResults<'mir, 'tcx> {
4343
}
4444

4545
fn reset_to_block_entry(&self, state: &mut Self::FlowState, block: BasicBlock) {
46-
state.borrows.clone_from(&self.borrows.entry_set_for_block(block));
47-
state.uninits.clone_from(&self.uninits.entry_set_for_block(block));
48-
state.ever_inits.clone_from(&self.ever_inits.entry_set_for_block(block));
46+
state.borrows.clone_from(self.borrows.entry_set_for_block(block));
47+
state.uninits.clone_from(self.uninits.entry_set_for_block(block));
48+
state.ever_inits.clone_from(self.ever_inits.entry_set_for_block(block));
4949
}
5050

5151
fn reconstruct_before_statement_effect(

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
895895
for alias_ty in alias_tys {
896896
if alias_ty.span.desugaring_kind().is_some() {
897897
// Skip `async` desugaring `impl Future`.
898-
()
899898
}
900899
if let TyKind::TraitObject(_, lt, _) = alias_ty.kind {
901900
if lt.ident.name == kw::Empty {

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
519519
}
520520

521521
// Otherwise, let's descend into the referent types.
522-
search_stack.push((*referent_ty, &referent_hir_ty.ty));
522+
search_stack.push((*referent_ty, referent_hir_ty.ty));
523523
}
524524

525525
// Match up something like `Foo<'1>`
@@ -558,7 +558,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
558558
}
559559

560560
(ty::RawPtr(mut_ty, _), hir::TyKind::Ptr(mut_hir_ty)) => {
561-
search_stack.push((*mut_ty, &mut_hir_ty.ty));
561+
search_stack.push((*mut_ty, mut_hir_ty.ty));
562562
}
563563

564564
_ => {
@@ -652,7 +652,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
652652
let upvar_index = self.regioncx.get_upvar_index_for_region(self.infcx.tcx, fr)?;
653653
let (upvar_name, upvar_span) = self.regioncx.get_upvar_name_and_span_for_region(
654654
self.infcx.tcx,
655-
&self.upvars,
655+
self.upvars,
656656
upvar_index,
657657
);
658658
let region_name = self.synthesize_region_name();
@@ -717,7 +717,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
717717
.output;
718718
span = output.span();
719719
if let hir::FnRetTy::Return(ret) = output {
720-
hir_ty = Some(self.get_future_inner_return_ty(*ret));
720+
hir_ty = Some(self.get_future_inner_return_ty(ret));
721721
}
722722
" of async function"
723723
}
@@ -958,7 +958,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
958958
{
959959
let (upvar_name, upvar_span) = self.regioncx.get_upvar_name_and_span_for_region(
960960
self.infcx.tcx,
961-
&self.upvars,
961+
self.upvars,
962962
upvar_index,
963963
);
964964
let region_name = self.synthesize_region_name();

compiler/rustc_borrowck/src/nll.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
114114
move_data,
115115
elements,
116116
upvars,
117-
polonius_input,
118117
);
119118

120119
// Create the region inference context, taking ownership of the

0 commit comments

Comments
 (0)