Skip to content

Commit 9b7e09b

Browse files
committed
Auto merge of rust-lang#120461 - fmease:rollup-30y3cyy, r=fmease
Rollup of 10 pull requests Successful merges: - rust-lang#116677 (References refer to allocated objects) - rust-lang#119991 (Reject infinitely-sized reads from io::Repeat) - rust-lang#120266 (Improve documentation for [A]Rc::into_inner) - rust-lang#120376 (Update codegen test for LLVM 18) - rust-lang#120402 (Make the coroutine def id of an async closure the child of the closure def id) - rust-lang#120424 (raw pointer metadata API: data address -> data pointer) - rust-lang#120425 (Remove unnecessary unit returns in query declarations) - rust-lang#120428 (hir: Two preparatory changes for rust-lang#120206) - rust-lang#120434 (Revert outdated version of "Add the wasm32-wasi-preview2 target") - rust-lang#120443 (Fixes footnote handling in rustdoc) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8a0b5ae + 83b3958 commit 9b7e09b

File tree

48 files changed

+304
-421
lines changed

Some content is hidden

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

48 files changed

+304
-421
lines changed

Cargo.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -3003,11 +3003,11 @@ dependencies = [
30033003

30043004
[[package]]
30053005
name = "pulldown-cmark"
3006-
version = "0.9.3"
3006+
version = "0.9.5"
30073007
source = "registry+https://github.com/rust-lang/crates.io-index"
3008-
checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998"
3008+
checksum = "80eb9f69aec5cd8828765a75f739383fbbe3e8b9d84370bde1cc90487700794a"
30093009
dependencies = [
3010-
"bitflags 1.3.2",
3010+
"bitflags 2.4.1",
30113011
"memchr",
30123012
"unicase",
30133013
]

compiler/rustc_ast_lowering/src/expr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
153153
}
154154
ExprKind::Let(pat, scrutinee, span, is_recovered) => {
155155
hir::ExprKind::Let(self.arena.alloc(hir::Let {
156-
hir_id: self.next_id(),
157156
span: self.lower_span(*span),
158157
pat: self.lower_pat(pat),
159158
ty: None,

compiler/rustc_ast_lowering/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2305,7 +2305,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23052305
match c.value.kind {
23062306
ExprKind::Underscore => {
23072307
if self.tcx.features().generic_arg_infer {
2308-
hir::ArrayLen::Infer(self.lower_node_id(c.id), self.lower_span(c.value.span))
2308+
hir::ArrayLen::Infer(hir::InferArg {
2309+
hir_id: self.lower_node_id(c.id),
2310+
span: self.lower_span(c.value.span),
2311+
})
23092312
} else {
23102313
feature_err(
23112314
&self.tcx.sess,

compiler/rustc_hir/src/hir.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,6 @@ pub struct Arm<'hir> {
12731273
/// desugaring to if-let. Only let-else supports the type annotation at present.
12741274
#[derive(Debug, Clone, Copy, HashStable_Generic)]
12751275
pub struct Let<'hir> {
1276-
pub hir_id: HirId,
12771276
pub span: Span,
12781277
pub pat: &'hir Pat<'hir>,
12791278
pub ty: Option<&'hir Ty<'hir>>,
@@ -1532,14 +1531,16 @@ pub type Lit = Spanned<LitKind>;
15321531

15331532
#[derive(Copy, Clone, Debug, HashStable_Generic)]
15341533
pub enum ArrayLen {
1535-
Infer(HirId, Span),
1534+
Infer(InferArg),
15361535
Body(AnonConst),
15371536
}
15381537

15391538
impl ArrayLen {
15401539
pub fn hir_id(&self) -> HirId {
15411540
match self {
1542-
&ArrayLen::Infer(hir_id, _) | &ArrayLen::Body(AnonConst { hir_id, .. }) => hir_id,
1541+
ArrayLen::Infer(InferArg { hir_id, .. }) | ArrayLen::Body(AnonConst { hir_id, .. }) => {
1542+
*hir_id
1543+
}
15431544
}
15441545
}
15451546
}
@@ -2424,7 +2425,7 @@ impl<'hir> Ty<'hir> {
24242425
TyKind::Infer => true,
24252426
TyKind::Slice(ty) => ty.is_suggestable_infer_ty(),
24262427
TyKind::Array(ty, length) => {
2427-
ty.is_suggestable_infer_ty() || matches!(length, ArrayLen::Infer(_, _))
2428+
ty.is_suggestable_infer_ty() || matches!(length, ArrayLen::Infer(..))
24282429
}
24292430
TyKind::Tup(tys) => tys.iter().any(Self::is_suggestable_infer_ty),
24302431
TyKind::Ptr(mut_ty) | TyKind::Ref(_, mut_ty) => mut_ty.ty.is_suggestable_infer_ty(),

compiler/rustc_hir/src/intravisit.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,6 @@ pub trait Visitor<'v>: Sized {
341341
fn visit_expr(&mut self, ex: &'v Expr<'v>) {
342342
walk_expr(self, ex)
343343
}
344-
fn visit_let_expr(&mut self, lex: &'v Let<'v>) {
345-
walk_let_expr(self, lex)
346-
}
347344
fn visit_expr_field(&mut self, field: &'v ExprField<'v>) {
348345
walk_expr_field(self, field)
349346
}
@@ -672,7 +669,7 @@ pub fn walk_pat_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v PatField<'
672669

673670
pub fn walk_array_len<'v, V: Visitor<'v>>(visitor: &mut V, len: &'v ArrayLen) {
674671
match len {
675-
&ArrayLen::Infer(hir_id, _span) => visitor.visit_id(hir_id),
672+
ArrayLen::Infer(InferArg { hir_id, span: _ }) => visitor.visit_id(*hir_id),
676673
ArrayLen::Body(c) => visitor.visit_anon_const(c),
677674
}
678675
}
@@ -729,7 +726,12 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
729726
ExprKind::DropTemps(ref subexpression) => {
730727
visitor.visit_expr(subexpression);
731728
}
732-
ExprKind::Let(ref let_expr) => visitor.visit_let_expr(let_expr),
729+
ExprKind::Let(Let { span: _, pat, ty, init, is_recovered: _ }) => {
730+
// match the visit order in walk_local
731+
visitor.visit_expr(init);
732+
visitor.visit_pat(pat);
733+
walk_list!(visitor, visit_ty, ty);
734+
}
733735
ExprKind::If(ref cond, ref then, ref else_opt) => {
734736
visitor.visit_expr(cond);
735737
visitor.visit_expr(then);
@@ -806,14 +808,6 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
806808
}
807809
}
808810

809-
pub fn walk_let_expr<'v, V: Visitor<'v>>(visitor: &mut V, let_expr: &'v Let<'v>) {
810-
// match the visit order in walk_local
811-
visitor.visit_expr(let_expr.init);
812-
visitor.visit_id(let_expr.hir_id);
813-
visitor.visit_pat(let_expr.pat);
814-
walk_list!(visitor, visit_ty, let_expr.ty);
815-
}
816-
817811
pub fn walk_expr_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v ExprField<'v>) {
818812
visitor.visit_id(field.hir_id);
819813
visitor.visit_ident(field.ident);

compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2529,7 +2529,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25292529
}
25302530
hir::TyKind::Array(ty, length) => {
25312531
let length = match length {
2532-
&hir::ArrayLen::Infer(_, span) => self.ct_infer(tcx.types.usize, None, span),
2532+
hir::ArrayLen::Infer(inf) => self.ct_infer(tcx.types.usize, None, inf.span),
25332533
hir::ArrayLen::Body(constant) => {
25342534
ty::Const::from_anon_const(tcx, constant.def_id)
25352535
}

compiler/rustc_hir_analysis/src/collect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ impl<'v> Visitor<'v> for HirPlaceholderCollector {
146146
}
147147
}
148148
fn visit_array_length(&mut self, length: &'v hir::ArrayLen) {
149-
if let &hir::ArrayLen::Infer(_, span) = length {
150-
self.0.push(span);
149+
if let hir::ArrayLen::Infer(inf) = length {
150+
self.0.push(inf.span);
151151
}
152152
intravisit::walk_array_len(self, length)
153153
}

compiler/rustc_hir_pretty/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ impl<'a> State<'a> {
956956

957957
fn print_array_length(&mut self, len: &hir::ArrayLen) {
958958
match len {
959-
hir::ArrayLen::Infer(_, _) => self.word("_"),
959+
hir::ArrayLen::Infer(..) => self.word("_"),
960960
hir::ArrayLen::Body(ct) => self.print_anon_const(ct),
961961
}
962962
}

compiler/rustc_hir_typeck/src/expr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
320320
}
321321
ExprKind::Ret(ref expr_opt) => self.check_expr_return(expr_opt.as_deref(), expr),
322322
ExprKind::Become(call) => self.check_expr_become(call, expr),
323-
ExprKind::Let(let_expr) => self.check_expr_let(let_expr),
323+
ExprKind::Let(let_expr) => self.check_expr_let(let_expr, expr.hir_id),
324324
ExprKind::Loop(body, _, source, _) => {
325325
self.check_expr_loop(body, source, expected, expr)
326326
}
@@ -1259,12 +1259,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12591259
}
12601260
}
12611261

1262-
pub(super) fn check_expr_let(&self, let_expr: &'tcx hir::Let<'tcx>) -> Ty<'tcx> {
1262+
pub(super) fn check_expr_let(&self, let_expr: &'tcx hir::Let<'tcx>, hir_id: HirId) -> Ty<'tcx> {
12631263
// for let statements, this is done in check_stmt
12641264
let init = let_expr.init;
12651265
self.warn_if_unreachable(init.hir_id, init.span, "block in `let` expression");
12661266
// otherwise check exactly as a let statement
1267-
self.check_decl(let_expr.into());
1267+
self.check_decl((let_expr, hir_id).into());
12681268
// but return a bool, for this is a boolean expression
12691269
if let Some(error_guaranteed) = let_expr.is_recovered {
12701270
self.set_tainted_by_errors(error_guaranteed);

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
405405

406406
pub fn array_length_to_const(&self, length: &hir::ArrayLen) -> ty::Const<'tcx> {
407407
match length {
408-
&hir::ArrayLen::Infer(_, span) => self.ct_infer(self.tcx.types.usize, None, span),
408+
hir::ArrayLen::Infer(inf) => self.ct_infer(self.tcx.types.usize, None, inf.span),
409409
hir::ArrayLen::Body(anon_const) => {
410410
let span = self.tcx.def_span(anon_const.def_id);
411411
let c = ty::Const::from_anon_const(self.tcx, anon_const.def_id);

compiler/rustc_hir_typeck/src/gather_locals.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ impl<'a> From<&'a hir::Local<'a>> for Declaration<'a> {
4848
}
4949
}
5050

51-
impl<'a> From<&'a hir::Let<'a>> for Declaration<'a> {
52-
fn from(let_expr: &'a hir::Let<'a>) -> Self {
53-
let hir::Let { hir_id, pat, ty, span, init, is_recovered: _ } = *let_expr;
51+
impl<'a> From<(&'a hir::Let<'a>, hir::HirId)> for Declaration<'a> {
52+
fn from((let_expr, hir_id): (&'a hir::Let<'a>, hir::HirId)) -> Self {
53+
let hir::Let { pat, ty, span, init, is_recovered: _ } = *let_expr;
5454
Declaration { hir_id, pat, ty, span, init: Some(init), origin: DeclOrigin::LetExpr }
5555
}
5656
}
@@ -125,9 +125,11 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
125125
intravisit::walk_local(self, local)
126126
}
127127

128-
fn visit_let_expr(&mut self, let_expr: &'tcx hir::Let<'tcx>) {
129-
self.declare(let_expr.into());
130-
intravisit::walk_let_expr(self, let_expr);
128+
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
129+
if let hir::ExprKind::Let(let_expr) = expr.kind {
130+
self.declare((let_expr, expr.hir_id).into());
131+
}
132+
intravisit::walk_expr(self, expr)
131133
}
132134

133135
fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {

compiler/rustc_middle/src/query/mod.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub use plumbing::{IntoQueryParam, TyCtxtAt, TyCtxtEnsure, TyCtxtEnsureWithValue
109109
// as they will raise an fatal error on query cycles instead.
110110
rustc_queries! {
111111
/// This exists purely for testing the interactions between span_delayed_bug and incremental.
112-
query trigger_span_delayed_bug(key: DefId) -> () {
112+
query trigger_span_delayed_bug(key: DefId) {
113113
desc { "triggering a span delayed bug for testing incremental" }
114114
}
115115

@@ -119,7 +119,7 @@ rustc_queries! {
119119
desc { "compute registered tools for crate" }
120120
}
121121

122-
query early_lint_checks(_: ()) -> () {
122+
query early_lint_checks(_: ()) {
123123
desc { "perform lints prior to macro expansion" }
124124
}
125125

@@ -299,7 +299,7 @@ rustc_queries! {
299299
/// name. This is useful for cases were not all linting code from rustc
300300
/// was called. With the default `None` all registered lints will also
301301
/// be checked for expectation fulfillment.
302-
query check_expectations(key: Option<Symbol>) -> () {
302+
query check_expectations(key: Option<Symbol>) {
303303
eval_always
304304
desc { "checking lint expectations (RFC 2383)" }
305305
}
@@ -906,39 +906,39 @@ rustc_queries! {
906906
}
907907

908908
/// Performs lint checking for the module.
909-
query lint_mod(key: LocalModDefId) -> () {
909+
query lint_mod(key: LocalModDefId) {
910910
desc { |tcx| "linting {}", describe_as_module(key, tcx) }
911911
}
912912

913-
query check_unused_traits(_: ()) -> () {
913+
query check_unused_traits(_: ()) {
914914
desc { "checking unused trait imports in crate" }
915915
}
916916

917917
/// Checks the attributes in the module.
918-
query check_mod_attrs(key: LocalModDefId) -> () {
918+
query check_mod_attrs(key: LocalModDefId) {
919919
desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) }
920920
}
921921

922922
/// Checks for uses of unstable APIs in the module.
923-
query check_mod_unstable_api_usage(key: LocalModDefId) -> () {
923+
query check_mod_unstable_api_usage(key: LocalModDefId) {
924924
desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) }
925925
}
926926

927927
/// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`).
928-
query check_mod_const_bodies(key: LocalModDefId) -> () {
928+
query check_mod_const_bodies(key: LocalModDefId) {
929929
desc { |tcx| "checking consts in {}", describe_as_module(key, tcx) }
930930
}
931931

932932
/// Checks the loops in the module.
933-
query check_mod_loops(key: LocalModDefId) -> () {
933+
query check_mod_loops(key: LocalModDefId) {
934934
desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) }
935935
}
936936

937-
query check_mod_naked_functions(key: LocalModDefId) -> () {
937+
query check_mod_naked_functions(key: LocalModDefId) {
938938
desc { |tcx| "checking naked functions in {}", describe_as_module(key, tcx) }
939939
}
940940

941-
query check_mod_privacy(key: LocalModDefId) -> () {
941+
query check_mod_privacy(key: LocalModDefId) {
942942
desc { |tcx| "checking privacy in {}", describe_as_module(key.to_local_def_id(), tcx) }
943943
}
944944

@@ -958,7 +958,7 @@ rustc_queries! {
958958
desc { "finding live symbols in crate" }
959959
}
960960

961-
query check_mod_deathness(key: LocalModDefId) -> () {
961+
query check_mod_deathness(key: LocalModDefId) {
962962
desc { |tcx| "checking deathness of variables in {}", describe_as_module(key, tcx) }
963963
}
964964

@@ -972,7 +972,7 @@ rustc_queries! {
972972
ensure_forwards_result_if_red
973973
}
974974

975-
query collect_mod_item_types(key: LocalModDefId) -> () {
975+
query collect_mod_item_types(key: LocalModDefId) {
976976
desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) }
977977
}
978978

@@ -1121,7 +1121,7 @@ rustc_queries! {
11211121
eval_always
11221122
desc { "checking effective visibilities" }
11231123
}
1124-
query check_private_in_public(_: ()) -> () {
1124+
query check_private_in_public(_: ()) {
11251125
eval_always
11261126
desc { "checking for private elements in public interfaces" }
11271127
}

compiler/rustc_passes/src/hir_stats.rs

-5
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,6 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
328328
hir_visit::walk_expr(self, e)
329329
}
330330

331-
fn visit_let_expr(&mut self, lex: &'v hir::Let<'v>) {
332-
self.record("Let", Id::Node(lex.hir_id), lex);
333-
hir_visit::walk_let_expr(self, lex)
334-
}
335-
336331
fn visit_expr_field(&mut self, f: &'v hir::ExprField<'v>) {
337332
self.record("ExprField", Id::Node(f.hir_id), f);
338333
hir_visit::walk_expr_field(self, f)

compiler/rustc_resolve/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
[dependencies]
77
# tidy-alphabetical-start
88
bitflags = "2.4.1"
9-
pulldown-cmark = { version = "0.9.3", default-features = false }
9+
pulldown-cmark = { version = "0.9.5", default-features = false }
1010
rustc_arena = { path = "../rustc_arena" }
1111
rustc_ast = { path = "../rustc_ast" }
1212
rustc_ast_pretty = { path = "../rustc_ast_pretty" }

compiler/rustc_resolve/src/def_collector.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,18 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
289289
// we must create two defs.
290290
let closure_def = self.create_def(expr.id, kw::Empty, DefKind::Closure, expr.span);
291291
match closure.coroutine_kind {
292-
Some(coroutine_kind) => self.create_def(
293-
coroutine_kind.closure_id(),
294-
kw::Empty,
295-
DefKind::Closure,
296-
expr.span,
297-
),
292+
Some(coroutine_kind) => {
293+
self.with_parent(closure_def, |this| {
294+
let coroutine_def = this.create_def(
295+
coroutine_kind.closure_id(),
296+
kw::Empty,
297+
DefKind::Closure,
298+
expr.span,
299+
);
300+
this.with_parent(coroutine_def, |this| visit::walk_expr(this, expr));
301+
});
302+
return;
303+
}
298304
None => closure_def,
299305
}
300306
}

compiler/rustc_span/src/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1799,7 +1799,6 @@ symbols! {
17991799
warn,
18001800
wasm_abi,
18011801
wasm_import_module,
1802-
wasm_preview2,
18031802
wasm_target_feature,
18041803
while_let,
18051804
windows,

compiler/rustc_target/src/spec/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,6 @@ supported_targets! {
15741574
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
15751575
("wasm32-unknown-unknown", wasm32_unknown_unknown),
15761576
("wasm32-wasi", wasm32_wasi),
1577-
("wasm32-wasi-preview2", wasm32_wasi_preview2),
15781577
("wasm32-wasi-preview1-threads", wasm32_wasi_preview1_threads),
15791578
("wasm64-unknown-unknown", wasm64_unknown_unknown),
15801579

compiler/rustc_target/src/spec/targets/wasm32_wasi_preview1_threads.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,11 @@
7272
//! best we can with this target. Don't start relying on too much here unless
7373
//! you know what you're getting in to!
7474
75-
use crate::spec::{base, crt_objects, cvs, Cc, LinkSelfContainedDefault, LinkerFlavor, Target};
75+
use crate::spec::{base, crt_objects, Cc, LinkSelfContainedDefault, LinkerFlavor, Target};
7676

7777
pub fn target() -> Target {
7878
let mut options = base::wasm::options();
7979

80-
options.families = cvs!["wasm", "wasi"];
8180
options.os = "wasi".into();
8281

8382
options.add_pre_link_args(

0 commit comments

Comments
 (0)