Skip to content

Commit 3f391b8

Browse files
committed
Auto merge of #96087 - Dylan-DPC:rollup-k6yzk55, r=Dylan-DPC
Rollup of 11 pull requests Successful merges: - #94457 (Stabilize `derive_default_enum`) - #94461 (Create (unstable) 2024 edition) - #94849 (Check var scope if it exist) - #95194 (remove find_use_placement) - #95749 (only downgrade selection Error -> Ambiguous if type error is in predicate) - #96026 (couple of clippy::complexity fixes) - #96027 (remove function parameters only used in recursion) - #96034 ([test] Add test cases of untested functions for BTreeSet ) - #96040 (Use u32 instead of i32 for futexes.) - #96062 (docs: Update tests chapter for Termination stabilization) - #96065 (Refactor: Use `format-args-capture` and remove unnecessary nested blocks in rustc_typeck) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1e6fe58 + fa281fd commit 3f391b8

File tree

94 files changed

+1020
-1064
lines changed

Some content is hidden

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

94 files changed

+1020
-1064
lines changed

compiler/rustc_ast/src/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ impl NonterminalKind {
722722
Edition::Edition2015 | Edition::Edition2018 => {
723723
NonterminalKind::PatParam { inferred: true }
724724
}
725-
Edition::Edition2021 => NonterminalKind::PatWithOr,
725+
Edition::Edition2021 | Edition::Edition2024 => NonterminalKind::PatWithOr,
726726
},
727727
sym::pat_param => NonterminalKind::PatParam { inferred: false },
728728
sym::expr => NonterminalKind::Expr,

compiler/rustc_ast_lowering/src/index.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ pub(super) fn index_hir<'hir>(
5252
};
5353

5454
match item {
55-
OwnerNode::Crate(citem) => collector.visit_mod(&citem, citem.inner, hir::CRATE_HIR_ID),
55+
OwnerNode::Crate(citem) => {
56+
collector.visit_mod(&citem, citem.spans.inner_span, hir::CRATE_HIR_ID)
57+
}
5658
OwnerNode::Item(item) => collector.visit_item(item),
5759
OwnerNode::TraitItem(item) => collector.visit_trait_item(item),
5860
OwnerNode::ImplItem(item) => collector.visit_impl_item(item),

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
124124
debug_assert_eq!(self.resolver.local_def_id(CRATE_NODE_ID), CRATE_DEF_ID);
125125

126126
self.with_lctx(CRATE_NODE_ID, |lctx| {
127-
let module = lctx.lower_mod(&c.items, c.spans.inner_span);
127+
let module = lctx.lower_mod(&c.items, &c.spans);
128128
lctx.lower_attrs(hir::CRATE_HIR_ID, &c.attrs);
129129
hir::OwnerNode::Crate(lctx.arena.alloc(module))
130130
})
@@ -186,9 +186,12 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
186186
}
187187

188188
impl<'hir> LoweringContext<'_, 'hir> {
189-
pub(super) fn lower_mod(&mut self, items: &[P<Item>], inner: Span) -> hir::Mod<'hir> {
189+
pub(super) fn lower_mod(&mut self, items: &[P<Item>], spans: &ModSpans) -> hir::Mod<'hir> {
190190
hir::Mod {
191-
inner: self.lower_span(inner),
191+
spans: hir::ModSpans {
192+
inner_span: self.lower_span(spans.inner_span),
193+
inject_use_span: self.lower_span(spans.inject_use_span),
194+
},
192195
item_ids: self.arena.alloc_from_iter(items.iter().flat_map(|x| self.lower_item_ref(x))),
193196
}
194197
}
@@ -308,8 +311,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
308311
})
309312
}
310313
ItemKind::Mod(_, ref mod_kind) => match mod_kind {
311-
ModKind::Loaded(items, _, ModSpans { inner_span, inject_use_span: _ }) => {
312-
hir::ItemKind::Mod(self.lower_mod(items, *inner_span))
314+
ModKind::Loaded(items, _, spans) => {
315+
hir::ItemKind::Mod(self.lower_mod(items, spans))
313316
}
314317
ModKind::Unloaded => panic!("`mod` items should have been loaded by now"),
315318
},

compiler/rustc_builtin_macros/src/deriving/default.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,7 @@ pub fn expand_deriving_default(
4646
StaticStruct(_, fields) => {
4747
default_struct_substructure(cx, trait_span, substr, fields)
4848
}
49-
StaticEnum(enum_def, _) => {
50-
if !cx.sess.features_untracked().derive_default_enum {
51-
rustc_session::parse::feature_err(
52-
cx.parse_sess(),
53-
sym::derive_default_enum,
54-
span,
55-
"deriving `Default` on enums is experimental",
56-
)
57-
.emit();
58-
}
59-
default_enum_substructure(cx, trait_span, enum_def)
60-
}
49+
StaticEnum(enum_def, _) => default_enum_substructure(cx, trait_span, enum_def),
6150
_ => cx.span_bug(trait_span, "method in `derive(Default)`"),
6251
}
6352
})),

compiler/rustc_builtin_macros/src/standard_library_imports.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ pub fn inject(
7070
Edition2015 => sym::rust_2015,
7171
Edition2018 => sym::rust_2018,
7272
Edition2021 => sym::rust_2021,
73+
Edition2024 => sym::rust_2024,
7374
}])
7475
.map(|&symbol| Ident::new(symbol, span))
7576
.collect();

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ impl Diagnostic {
832832
name: impl Into<Cow<'static, str>>,
833833
arg: DiagnosticArgValue<'static>,
834834
) -> &mut Self {
835-
self.args.push((name.into(), arg.into()));
835+
self.args.push((name.into(), arg));
836836
self
837837
}
838838

compiler/rustc_expand/src/mbe/macro_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ fn check_binders(
270270
MISSING_FRAGMENT_SPECIFIER,
271271
span,
272272
node_id,
273-
&format!("missing fragment specifier"),
273+
"missing fragment specifier",
274274
);
275275
}
276276
if !macros.is_empty() {

compiler/rustc_expand/src/mbe/macro_parser.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ use crate::mbe::{KleeneOp, TokenTree};
7777

7878
use rustc_ast::token::{self, DocComment, Nonterminal, NonterminalKind, Token};
7979
use rustc_parse::parser::{NtOrTt, Parser};
80-
use rustc_session::parse::ParseSess;
8180
use rustc_span::symbol::MacroRulesNormalizedIdent;
8281
use rustc_span::Span;
8382

@@ -128,9 +127,8 @@ pub(super) enum MatcherLoc {
128127
Eof,
129128
}
130129

131-
pub(super) fn compute_locs(sess: &ParseSess, matcher: &[TokenTree]) -> Vec<MatcherLoc> {
130+
pub(super) fn compute_locs(matcher: &[TokenTree]) -> Vec<MatcherLoc> {
132131
fn inner(
133-
sess: &ParseSess,
134132
tts: &[TokenTree],
135133
locs: &mut Vec<MatcherLoc>,
136134
next_metavar: &mut usize,
@@ -147,7 +145,7 @@ pub(super) fn compute_locs(sess: &ParseSess, matcher: &[TokenTree]) -> Vec<Match
147145

148146
locs.push(MatcherLoc::Delimited);
149147
locs.push(MatcherLoc::Token { token: open_token });
150-
inner(sess, &delimited.tts, locs, next_metavar, seq_depth);
148+
inner(&delimited.tts, locs, next_metavar, seq_depth);
151149
locs.push(MatcherLoc::Token { token: close_token });
152150
}
153151
TokenTree::Sequence(_, seq) => {
@@ -162,7 +160,7 @@ pub(super) fn compute_locs(sess: &ParseSess, matcher: &[TokenTree]) -> Vec<Match
162160
let op = seq.kleene.op;
163161
let idx_first = locs.len();
164162
let idx_seq = idx_first - 1;
165-
inner(sess, &seq.tts, locs, next_metavar, seq_depth + 1);
163+
inner(&seq.tts, locs, next_metavar, seq_depth + 1);
166164

167165
if let Some(separator) = &seq.separator {
168166
locs.push(MatcherLoc::SequenceSep { separator: separator.clone() });
@@ -197,7 +195,7 @@ pub(super) fn compute_locs(sess: &ParseSess, matcher: &[TokenTree]) -> Vec<Match
197195

198196
let mut locs = vec![];
199197
let mut next_metavar = 0;
200-
inner(sess, matcher, &mut locs, &mut next_metavar, /* seq_depth */ 0);
198+
inner(matcher, &mut locs, &mut next_metavar, /* seq_depth */ 0);
201199

202200
// A final entry is needed for eof.
203201
locs.push(MatcherLoc::Eof);

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ pub fn compile_declarative_macro(
435435
),
436436
];
437437
// Convert it into `MatcherLoc` form.
438-
let argument_gram = mbe::macro_parser::compute_locs(&sess.parse_sess, &argument_gram);
438+
let argument_gram = mbe::macro_parser::compute_locs(&argument_gram);
439439

440440
let parser = Parser::new(&sess.parse_sess, body, true, rustc_parse::MACRO_ARGUMENTS);
441441
let mut tt_parser =
@@ -478,7 +478,7 @@ pub fn compile_declarative_macro(
478478
)
479479
.pop()
480480
.unwrap();
481-
valid &= check_lhs_nt_follows(&sess.parse_sess, features, &def, &tt);
481+
valid &= check_lhs_nt_follows(&sess.parse_sess, &def, &tt);
482482
return tt;
483483
}
484484
sess.parse_sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs")
@@ -540,7 +540,7 @@ pub fn compile_declarative_macro(
540540
// Ignore the delimiters around the matcher.
541541
match lhs {
542542
mbe::TokenTree::Delimited(_, delimited) => {
543-
mbe::macro_parser::compute_locs(&sess.parse_sess, &delimited.tts)
543+
mbe::macro_parser::compute_locs(&delimited.tts)
544544
}
545545
_ => sess.parse_sess.span_diagnostic.span_bug(def.span, "malformed macro lhs"),
546546
}
@@ -563,16 +563,11 @@ pub fn compile_declarative_macro(
563563
}))
564564
}
565565

566-
fn check_lhs_nt_follows(
567-
sess: &ParseSess,
568-
features: &Features,
569-
def: &ast::Item,
570-
lhs: &mbe::TokenTree,
571-
) -> bool {
566+
fn check_lhs_nt_follows(sess: &ParseSess, def: &ast::Item, lhs: &mbe::TokenTree) -> bool {
572567
// lhs is going to be like TokenTree::Delimited(...), where the
573568
// entire lhs is those tts. Or, it can be a "bare sequence", not wrapped in parens.
574569
if let mbe::TokenTree::Delimited(_, delimited) = lhs {
575-
check_matcher(sess, features, def, &delimited.tts)
570+
check_matcher(sess, def, &delimited.tts)
576571
} else {
577572
let msg = "invalid macro matcher; matchers must be contained in balanced delimiters";
578573
sess.span_diagnostic.span_err(lhs.span(), msg);
@@ -632,16 +627,11 @@ fn check_rhs(sess: &ParseSess, rhs: &mbe::TokenTree) -> bool {
632627
false
633628
}
634629

635-
fn check_matcher(
636-
sess: &ParseSess,
637-
features: &Features,
638-
def: &ast::Item,
639-
matcher: &[mbe::TokenTree],
640-
) -> bool {
630+
fn check_matcher(sess: &ParseSess, def: &ast::Item, matcher: &[mbe::TokenTree]) -> bool {
641631
let first_sets = FirstSets::new(matcher);
642632
let empty_suffix = TokenSet::empty();
643633
let err = sess.span_diagnostic.err_count();
644-
check_matcher_core(sess, features, def, &first_sets, matcher, &empty_suffix);
634+
check_matcher_core(sess, def, &first_sets, matcher, &empty_suffix);
645635
err == sess.span_diagnostic.err_count()
646636
}
647637

@@ -955,7 +945,6 @@ impl<'tt> TokenSet<'tt> {
955945
// see `FirstSets::new`.
956946
fn check_matcher_core<'tt>(
957947
sess: &ParseSess,
958-
features: &Features,
959948
def: &ast::Item,
960949
first_sets: &FirstSets<'tt>,
961950
matcher: &'tt [mbe::TokenTree],
@@ -1008,7 +997,7 @@ fn check_matcher_core<'tt>(
1008997
token::CloseDelim(d.delim),
1009998
span.close,
1010999
));
1011-
check_matcher_core(sess, features, def, first_sets, &d.tts, &my_suffix);
1000+
check_matcher_core(sess, def, first_sets, &d.tts, &my_suffix);
10121001
// don't track non NT tokens
10131002
last.replace_with_irrelevant();
10141003

@@ -1040,8 +1029,7 @@ fn check_matcher_core<'tt>(
10401029
// At this point, `suffix_first` is built, and
10411030
// `my_suffix` is some TokenSet that we can use
10421031
// for checking the interior of `seq_rep`.
1043-
let next =
1044-
check_matcher_core(sess, features, def, first_sets, &seq_rep.tts, my_suffix);
1032+
let next = check_matcher_core(sess, def, first_sets, &seq_rep.tts, my_suffix);
10451033
if next.maybe_empty {
10461034
last.add_all(&next);
10471035
} else {
@@ -1114,7 +1102,7 @@ fn check_matcher_core<'tt>(
11141102
err.span_label(sp, format!("not allowed after `{}` fragments", kind));
11151103

11161104
if kind == NonterminalKind::PatWithOr
1117-
&& sess.edition == Edition::Edition2021
1105+
&& sess.edition.rust_2021()
11181106
&& next_token.is_token(&BinOp(token::BinOpToken::Or))
11191107
{
11201108
let suggestion = quoted_tt_to_string(&TokenTree::MetaVarDecl(

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ declare_features! (
126126
(accepted, default_type_params, "1.0.0", None, None),
127127
/// Allows `#[deprecated]` attribute.
128128
(accepted, deprecated, "1.9.0", Some(29935), None),
129+
/// Allows `#[derive(Default)]` and `#[default]` on enums.
130+
(accepted, derive_default_enum, "1.62.0", Some(86985), None),
129131
/// Allows the use of destructuring assignments.
130132
(accepted, destructuring_assignment, "1.59.0", Some(71126), None),
131133
/// Allows `#[doc(alias = "...")]`.

0 commit comments

Comments
 (0)