Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 904164b

Browse files
committed
Merge remote-tracking branch 'origin' into mingw-split
2 parents d06081f + fda6892 commit 904164b

File tree

457 files changed

+13224
-3214
lines changed

Some content is hidden

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

457 files changed

+13224
-3214
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ dependencies = [
111111

112112
[[package]]
113113
name = "anstream"
114-
version = "0.6.17"
114+
version = "0.6.18"
115115
source = "registry+https://github.com/rust-lang/crates.io-index"
116-
checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338"
116+
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
117117
dependencies = [
118118
"anstyle",
119119
"anstyle-parse",

RELEASES.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -670,13 +670,6 @@ Cargo
670670
- [Support `target.<triple>.rustdocflags` officially](https://github.com/rust-lang/cargo/pull/13197/)
671671
- [Stabilize global cache data tracking](https://github.com/rust-lang/cargo/pull/13492/)
672672

673-
<a id="1.78.0-Misc"></a>
674-
675-
Misc
676-
----
677-
678-
- [rustdoc: add `--test-builder-wrapper` arg to support wrappers such as RUSTC_WRAPPER when building doctests](https://github.com/rust-lang/rust/pull/114651/)
679-
680673
<a id="1.78.0-Compatibility-Notes"></a>
681674

682675
Compatibility Notes

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ pub trait MutVisitor: Sized {
330330
fn visit_capture_by(&mut self, capture_by: &mut CaptureBy) {
331331
walk_capture_by(self, capture_by)
332332
}
333+
334+
fn visit_fn_ret_ty(&mut self, fn_ret_ty: &mut FnRetTy) {
335+
walk_fn_ret_ty(self, fn_ret_ty)
336+
}
333337
}
334338

335339
/// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
@@ -609,7 +613,7 @@ fn walk_angle_bracketed_parameter_data<T: MutVisitor>(vis: &mut T, data: &mut An
609613
fn walk_parenthesized_parameter_data<T: MutVisitor>(vis: &mut T, args: &mut ParenthesizedArgs) {
610614
let ParenthesizedArgs { inputs, output, span, inputs_span } = args;
611615
visit_thin_vec(inputs, |input| vis.visit_ty(input));
612-
walk_fn_ret_ty(vis, output);
616+
vis.visit_fn_ret_ty(output);
613617
vis.visit_span(span);
614618
vis.visit_span(inputs_span);
615619
}
@@ -911,7 +915,7 @@ fn walk_fn<T: MutVisitor>(vis: &mut T, kind: FnKind<'_>) {
911915
fn walk_fn_decl<T: MutVisitor>(vis: &mut T, decl: &mut P<FnDecl>) {
912916
let FnDecl { inputs, output } = decl.deref_mut();
913917
inputs.flat_map_in_place(|param| vis.flat_map_param(param));
914-
walk_fn_ret_ty(vis, output);
918+
vis.visit_fn_ret_ty(output);
915919
}
916920

917921
fn walk_fn_ret_ty<T: MutVisitor>(vis: &mut T, fn_ret_ty: &mut FnRetTy) {

compiler/rustc_ast/src/visit.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ pub trait Visitor<'ast>: Sized {
299299
fn visit_coroutine_kind(&mut self, _coroutine_kind: &'ast CoroutineKind) -> Self::Result {
300300
Self::Result::output()
301301
}
302+
fn visit_fn_decl(&mut self, fn_decl: &'ast FnDecl) -> Self::Result {
303+
walk_fn_decl(self, fn_decl)
304+
}
305+
fn visit_qself(&mut self, qs: &'ast Option<P<QSelf>>) -> Self::Result {
306+
walk_qself(self, qs)
307+
}
302308
}
303309

304310
pub fn walk_crate<'a, V: Visitor<'a>>(visitor: &mut V, krate: &'a Crate) -> V::Result {
@@ -434,13 +440,13 @@ impl WalkItemKind for ItemKind {
434440
body,
435441
from_glob: _,
436442
}) => {
437-
try_visit!(walk_qself(visitor, qself));
443+
try_visit!(visitor.visit_qself(qself));
438444
try_visit!(visitor.visit_path(path, *id));
439445
visit_opt!(visitor, visit_ident, rename);
440446
visit_opt!(visitor, visit_block, body);
441447
}
442448
ItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
443-
try_visit!(walk_qself(visitor, qself));
449+
try_visit!(visitor.visit_qself(qself));
444450
try_visit!(visitor.visit_path(prefix, id));
445451
if let Some(suffixes) = suffixes {
446452
for (ident, rename) in suffixes {
@@ -518,10 +524,10 @@ pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) -> V::Result {
518524
let BareFnTy { safety: _, ext: _, generic_params, decl, decl_span: _ } =
519525
&**function_declaration;
520526
walk_list!(visitor, visit_generic_param, generic_params);
521-
try_visit!(walk_fn_decl(visitor, decl));
527+
try_visit!(visitor.visit_fn_decl(decl));
522528
}
523529
TyKind::Path(maybe_qself, path) => {
524-
try_visit!(walk_qself(visitor, maybe_qself));
530+
try_visit!(visitor.visit_qself(maybe_qself));
525531
try_visit!(visitor.visit_path(path, *id));
526532
}
527533
TyKind::Pat(ty, pat) => {
@@ -652,16 +658,16 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) -> V::Res
652658
let Pat { id, kind, span: _, tokens: _ } = pattern;
653659
match kind {
654660
PatKind::TupleStruct(opt_qself, path, elems) => {
655-
try_visit!(walk_qself(visitor, opt_qself));
661+
try_visit!(visitor.visit_qself(opt_qself));
656662
try_visit!(visitor.visit_path(path, *id));
657663
walk_list!(visitor, visit_pat, elems);
658664
}
659665
PatKind::Path(opt_qself, path) => {
660-
try_visit!(walk_qself(visitor, opt_qself));
666+
try_visit!(visitor.visit_qself(opt_qself));
661667
try_visit!(visitor.visit_path(path, *id))
662668
}
663669
PatKind::Struct(opt_qself, path, fields, _rest) => {
664-
try_visit!(walk_qself(visitor, opt_qself));
670+
try_visit!(visitor.visit_qself(opt_qself));
665671
try_visit!(visitor.visit_path(path, *id));
666672
walk_list!(visitor, visit_pat_field, fields);
667673
}
@@ -846,13 +852,13 @@ pub fn walk_fn<'a, V: Visitor<'a>>(visitor: &mut V, kind: FnKind<'a>) -> V::Resu
846852
// Identifier and visibility are visited as a part of the item.
847853
try_visit!(visitor.visit_fn_header(header));
848854
try_visit!(visitor.visit_generics(generics));
849-
try_visit!(walk_fn_decl(visitor, decl));
855+
try_visit!(visitor.visit_fn_decl(decl));
850856
visit_opt!(visitor, visit_block, body);
851857
}
852858
FnKind::Closure(binder, coroutine_kind, decl, body) => {
853859
try_visit!(visitor.visit_closure_binder(binder));
854860
visit_opt!(visitor, visit_coroutine_kind, coroutine_kind.as_ref());
855-
try_visit!(walk_fn_decl(visitor, decl));
861+
try_visit!(visitor.visit_fn_decl(decl));
856862
try_visit!(visitor.visit_expr(body));
857863
}
858864
}
@@ -902,13 +908,13 @@ impl WalkItemKind for AssocItemKind {
902908
body,
903909
from_glob: _,
904910
}) => {
905-
try_visit!(walk_qself(visitor, qself));
911+
try_visit!(visitor.visit_qself(qself));
906912
try_visit!(visitor.visit_path(path, *id));
907913
visit_opt!(visitor, visit_ident, rename);
908914
visit_opt!(visitor, visit_block, body);
909915
}
910916
AssocItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
911-
try_visit!(walk_qself(visitor, qself));
917+
try_visit!(visitor.visit_qself(qself));
912918
try_visit!(visitor.visit_path(prefix, id));
913919
if let Some(suffixes) = suffixes {
914920
for (ident, rename) in suffixes {
@@ -1023,7 +1029,7 @@ pub fn walk_inline_asm_sym<'a, V: Visitor<'a>>(
10231029
visitor: &mut V,
10241030
InlineAsmSym { id, qself, path }: &'a InlineAsmSym,
10251031
) -> V::Result {
1026-
try_visit!(walk_qself(visitor, qself));
1032+
try_visit!(visitor.visit_qself(qself));
10271033
visitor.visit_path(path, *id)
10281034
}
10291035

@@ -1055,7 +1061,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) -> V
10551061
}
10561062
ExprKind::Struct(se) => {
10571063
let StructExpr { qself, path, fields, rest } = &**se;
1058-
try_visit!(walk_qself(visitor, qself));
1064+
try_visit!(visitor.visit_qself(qself));
10591065
try_visit!(visitor.visit_path(path, *id));
10601066
walk_list!(visitor, visit_expr_field, fields);
10611067
match rest {
@@ -1164,7 +1170,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) -> V
11641170
}
11651171
ExprKind::Underscore => {}
11661172
ExprKind::Path(maybe_qself, path) => {
1167-
try_visit!(walk_qself(visitor, maybe_qself));
1173+
try_visit!(visitor.visit_qself(maybe_qself));
11681174
try_visit!(visitor.visit_path(path, *id));
11691175
}
11701176
ExprKind::Break(opt_label, opt_expr) => {

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 60 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20522052
}
20532053
}
20542054

2055+
/// Used when lowering a type argument that turned out to actually be a const argument.
2056+
///
2057+
/// Only use for that purpose since otherwise it will create a duplicate def.
20552058
#[instrument(level = "debug", skip(self))]
20562059
fn lower_const_path_to_const_arg(
20572060
&mut self,
@@ -2060,51 +2063,58 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20602063
ty_id: NodeId,
20612064
span: Span,
20622065
) -> &'hir hir::ConstArg<'hir> {
2063-
let ct_kind = match res {
2064-
Res::Def(DefKind::ConstParam, _) => {
2065-
let qpath = self.lower_qpath(
2066-
ty_id,
2067-
&None,
2068-
path,
2069-
ParamMode::Optional,
2070-
AllowReturnTypeNotation::No,
2071-
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2072-
None,
2073-
);
2074-
hir::ConstArgKind::Path(qpath)
2075-
}
2076-
_ => {
2077-
// Construct an AnonConst where the expr is the "ty"'s path.
2066+
let tcx = self.tcx;
20782067

2079-
let parent_def_id = self.current_def_id_parent;
2080-
let node_id = self.next_node_id();
2081-
let span = self.lower_span(span);
2082-
2083-
// Add a definition for the in-band const def.
2084-
let def_id =
2085-
self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, span);
2086-
let hir_id = self.lower_node_id(node_id);
2068+
// FIXME(min_generic_const_args): we only allow one-segment const paths for now
2069+
let ct_kind = if path.is_potential_trivial_const_arg()
2070+
&& (tcx.features().min_generic_const_args()
2071+
|| matches!(res, Res::Def(DefKind::ConstParam, _)))
2072+
{
2073+
let qpath = self.lower_qpath(
2074+
ty_id,
2075+
&None,
2076+
path,
2077+
ParamMode::Optional,
2078+
AllowReturnTypeNotation::No,
2079+
// FIXME(min_generic_const_args): update for `fn foo() -> Bar<FOO<impl Trait>>` support
2080+
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2081+
None,
2082+
);
2083+
hir::ConstArgKind::Path(qpath)
2084+
} else {
2085+
// Construct an AnonConst where the expr is the "ty"'s path.
2086+
2087+
let parent_def_id = self.current_def_id_parent;
2088+
let node_id = self.next_node_id();
2089+
let span = self.lower_span(span);
2090+
2091+
// Add a definition for the in-band const def.
2092+
// We're lowering a const argument that was originally thought to be a type argument,
2093+
// so the def collector didn't create the def ahead of time. That's why we have to do
2094+
// it here.
2095+
let def_id =
2096+
self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, span);
2097+
let hir_id = self.lower_node_id(node_id);
2098+
2099+
let path_expr = Expr {
2100+
id: ty_id,
2101+
kind: ExprKind::Path(None, path.clone()),
2102+
span,
2103+
attrs: AttrVec::new(),
2104+
tokens: None,
2105+
};
20872106

2088-
let path_expr = Expr {
2089-
id: ty_id,
2090-
kind: ExprKind::Path(None, path.clone()),
2107+
let ct = self.with_new_scopes(span, |this| {
2108+
self.arena.alloc(hir::AnonConst {
2109+
def_id,
2110+
hir_id,
2111+
body: this.with_def_id_parent(def_id, |this| {
2112+
this.lower_const_body(path_expr.span, Some(&path_expr))
2113+
}),
20912114
span,
2092-
attrs: AttrVec::new(),
2093-
tokens: None,
2094-
};
2095-
2096-
let ct = self.with_new_scopes(span, |this| {
2097-
self.arena.alloc(hir::AnonConst {
2098-
def_id,
2099-
hir_id,
2100-
body: this.with_def_id_parent(def_id, |this| {
2101-
this.lower_const_body(path_expr.span, Some(&path_expr))
2102-
}),
2103-
span,
2104-
})
2105-
});
2106-
hir::ConstArgKind::Anon(ct)
2107-
}
2115+
})
2116+
});
2117+
hir::ConstArgKind::Anon(ct)
21082118
};
21092119

21102120
self.arena.alloc(hir::ConstArg {
@@ -2122,6 +2132,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21222132

21232133
#[instrument(level = "debug", skip(self))]
21242134
fn lower_anon_const_to_const_arg_direct(&mut self, anon: &AnonConst) -> hir::ConstArg<'hir> {
2135+
let tcx = self.tcx;
21252136
// Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments
21262137
// currently have to be wrapped in curly brackets, so it's necessary to special-case.
21272138
let expr = if let ExprKind::Block(block, _) = &anon.value.kind
@@ -2135,18 +2146,19 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21352146
};
21362147
let maybe_res =
21372148
self.resolver.get_partial_res(expr.id).and_then(|partial_res| partial_res.full_res());
2138-
debug!("res={:?}", maybe_res);
2139-
// FIXME(min_generic_const_args): for now we only lower params to ConstArgKind::Path
2140-
if let Some(res) = maybe_res
2141-
&& let Res::Def(DefKind::ConstParam, _) = res
2142-
&& let ExprKind::Path(qself, path) = &expr.kind
2149+
// FIXME(min_generic_const_args): we only allow one-segment const paths for now
2150+
if let ExprKind::Path(None, path) = &expr.kind
2151+
&& path.is_potential_trivial_const_arg()
2152+
&& (tcx.features().min_generic_const_args()
2153+
|| matches!(maybe_res, Some(Res::Def(DefKind::ConstParam, _))))
21432154
{
21442155
let qpath = self.lower_qpath(
21452156
expr.id,
2146-
qself,
2157+
&None,
21472158
path,
21482159
ParamMode::Optional,
21492160
AllowReturnTypeNotation::No,
2161+
// FIXME(min_generic_const_args): update for `fn foo() -> Bar<FOO<impl Trait>>` support
21502162
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
21512163
None,
21522164
);

compiler/rustc_ast_passes/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
pub mod ast_validation;
1919
mod errors;
2020
pub mod feature_gate;
21-
pub mod node_count;
2221
pub mod show_span;
2322

2423
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

0 commit comments

Comments
 (0)