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

Commit aa46e73

Browse files
committed
Auto merge of rust-lang#122788 - GuillaumeGomez:rollup-ya75903, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - rust-lang#122644 (pattern analysis: add a custom test harness) - rust-lang#122696 (Add bare metal riscv32 target.) - rust-lang#122723 (Use same file permissions for ar_archive_writer as the LLVM archive writer) - rust-lang#122729 (Relax SeqCst ordering in standard library.) - rust-lang#122740 (use more accurate terminology) - rust-lang#122764 (coverage: Remove incorrect assertions from counter allocation) - rust-lang#122765 (Add `usize::MAX` arg tests for Vec) - rust-lang#122776 (Rename `hir::Let` into `hir::LetExpr`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e3df96c + 8cf4525 commit aa46e73

File tree

57 files changed

+1017
-215
lines changed

Some content is hidden

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

57 files changed

+1017
-215
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4440,6 +4440,8 @@ dependencies = [
44404440
"rustc_target",
44414441
"smallvec",
44424442
"tracing",
4443+
"tracing-subscriber",
4444+
"tracing-tree",
44434445
]
44444446

44454447
[[package]]

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
157157
hir::ExprKind::AddrOf(*k, *m, ohs)
158158
}
159159
ExprKind::Let(pat, scrutinee, span, is_recovered) => {
160-
hir::ExprKind::Let(self.arena.alloc(hir::Let {
160+
hir::ExprKind::Let(self.arena.alloc(hir::LetExpr {
161161
span: self.lower_span(*span),
162162
pat: self.lower_pat(pat),
163163
ty: None,

compiler/rustc_codegen_ssa/src/back/archive.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use object::read::macho::FatArch;
1313
use tempfile::Builder as TempFileBuilder;
1414

1515
use std::error::Error;
16-
use std::fs::File;
16+
use std::fs::{self, File};
1717
use std::io::{self, Write};
1818
use std::path::{Path, PathBuf};
1919

@@ -276,29 +276,34 @@ impl<'a> ArArchiveBuilder<'a> {
276276
// This prevents programs (including rustc) from attempting to read a partial archive.
277277
// It also enables writing an archive with the same filename as a dependency on Windows as
278278
// required by a test.
279-
let mut archive_tmpfile = TempFileBuilder::new()
279+
// The tempfile crate currently uses 0o600 as mode for the temporary files and directories
280+
// it creates. We need it to be the default mode for back compat reasons however. (See
281+
// #107495) To handle this we are telling tempfile to create a temporary directory instead
282+
// and then inside this directory create a file using File::create.
283+
let archive_tmpdir = TempFileBuilder::new()
280284
.suffix(".temp-archive")
281-
.tempfile_in(output.parent().unwrap_or_else(|| Path::new("")))
282-
.map_err(|err| io_error_context("couldn't create a temp file", err))?;
283-
284-
write_archive_to_stream(
285-
archive_tmpfile.as_file_mut(),
286-
&entries,
287-
true,
288-
archive_kind,
289-
true,
290-
false,
291-
)?;
285+
.tempdir_in(output.parent().unwrap_or_else(|| Path::new("")))
286+
.map_err(|err| {
287+
io_error_context("couldn't create a directory for the temp file", err)
288+
})?;
289+
let archive_tmpfile_path = archive_tmpdir.path().join("tmp.a");
290+
let mut archive_tmpfile = File::create_new(&archive_tmpfile_path)
291+
.map_err(|err| io_error_context("couldn't create the temp file", err))?;
292+
293+
write_archive_to_stream(&mut archive_tmpfile, &entries, true, archive_kind, true, false)?;
294+
drop(archive_tmpfile);
292295

293296
let any_entries = !entries.is_empty();
294297
drop(entries);
295298
// Drop src_archives to unmap all input archives, which is necessary if we want to write the
296299
// output archive to the same location as an input archive on Windows.
297300
drop(self.src_archives);
298301

299-
archive_tmpfile
300-
.persist(output)
301-
.map_err(|err| io_error_context("failed to rename archive file", err.error))?;
302+
fs::rename(archive_tmpfile_path, output)
303+
.map_err(|err| io_error_context("failed to rename archive file", err))?;
304+
archive_tmpdir
305+
.close()
306+
.map_err(|err| io_error_context("failed to remove temporary directory", err))?;
302307

303308
Ok(any_entries)
304309
}

compiler/rustc_hir/src/hir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ pub struct Arm<'hir> {
12591259
/// In an `if let`, imagine it as `if (let <pat> = <expr>) { ... }`; in a let-else, it is part of
12601260
/// the desugaring to if-let. Only let-else supports the type annotation at present.
12611261
#[derive(Debug, Clone, Copy, HashStable_Generic)]
1262-
pub struct Let<'hir> {
1262+
pub struct LetExpr<'hir> {
12631263
pub span: Span,
12641264
pub pat: &'hir Pat<'hir>,
12651265
pub ty: Option<&'hir Ty<'hir>>,
@@ -1852,7 +1852,7 @@ pub enum ExprKind<'hir> {
18521852
///
18531853
/// These are not `Local` and only occur as expressions.
18541854
/// The `let Some(x) = foo()` in `if let Some(x) = foo()` is an example of `Let(..)`.
1855-
Let(&'hir Let<'hir>),
1855+
Let(&'hir LetExpr<'hir>),
18561856
/// An `if` block, with an optional else block.
18571857
///
18581858
/// I.e., `if <expr> { <expr> } else { <expr> }`.

compiler/rustc_hir/src/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
753753
ExprKind::DropTemps(ref subexpression) => {
754754
try_visit!(visitor.visit_expr(subexpression));
755755
}
756-
ExprKind::Let(Let { span: _, pat, ty, init, is_recovered: _ }) => {
756+
ExprKind::Let(LetExpr { span: _, pat, ty, init, is_recovered: _ }) => {
757757
// match the visit order in walk_local
758758
try_visit!(visitor.visit_expr(init));
759759
try_visit!(visitor.visit_pat(pat));

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ impl<'a> State<'a> {
13871387
// Print `}`:
13881388
self.bclose_maybe_open(expr.span, true);
13891389
}
1390-
hir::ExprKind::Let(&hir::Let { pat, ty, init, .. }) => {
1390+
hir::ExprKind::Let(&hir::LetExpr { pat, ty, init, .. }) => {
13911391
self.print_let(pat, ty, init);
13921392
}
13931393
hir::ExprKind::If(test, blk, elseopt) => {

compiler/rustc_hir_typeck/src/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
317317
err.note("`if` expressions without `else` evaluate to `()`");
318318
err.help("consider adding an `else` block that evaluates to the expected type");
319319
*error = true;
320-
if let ExprKind::Let(hir::Let { span, pat, init, .. }) = cond_expr.kind
320+
if let ExprKind::Let(hir::LetExpr { span, pat, init, .. }) = cond_expr.kind
321321
&& let ExprKind::Block(block, _) = then_expr.kind
322322
// Refutability checks occur on the MIR, so we approximate it here by checking
323323
// if we have an enum with a single variant or a struct in the pattern.

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12611261
}
12621262
}
12631263

1264-
pub(super) fn check_expr_let(&self, let_expr: &'tcx hir::Let<'tcx>, hir_id: HirId) -> Ty<'tcx> {
1264+
pub(super) fn check_expr_let(
1265+
&self,
1266+
let_expr: &'tcx hir::LetExpr<'tcx>,
1267+
hir_id: HirId,
1268+
) -> Ty<'tcx> {
12651269
// for let statements, this is done in check_stmt
12661270
let init = let_expr.init;
12671271
self.warn_if_unreachable(init.hir_id, init.span, "block in `let` expression");

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
245245
}
246246
}
247247

248-
hir::ExprKind::Let(hir::Let { pat, init, .. }) => {
248+
hir::ExprKind::Let(hir::LetExpr { pat, init, .. }) => {
249249
self.walk_local(init, pat, None, |t| t.borrow_expr(init, ty::ImmBorrow))
250250
}
251251

compiler/rustc_hir_typeck/src/gather_locals.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<'a> DeclOrigin<'a> {
2929
}
3030
}
3131

32-
/// A declaration is an abstraction of [hir::Local] and [hir::Let].
32+
/// A declaration is an abstraction of [hir::Local] and [hir::LetExpr].
3333
///
3434
/// It must have a hir_id, as this is how we connect gather_locals to the check functions.
3535
pub(super) struct Declaration<'a> {
@@ -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>, 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;
51+
impl<'a> From<(&'a hir::LetExpr<'a>, hir::HirId)> for Declaration<'a> {
52+
fn from((let_expr, hir_id): (&'a hir::LetExpr<'a>, hir::HirId)) -> Self {
53+
let hir::LetExpr { pat, ty, span, init, is_recovered: _ } = *let_expr;
5454
Declaration { hir_id, pat, ty, span, init: Some(init), origin: DeclOrigin::LetExpr }
5555
}
5656
}

0 commit comments

Comments
 (0)