Skip to content

Commit 526aa8c

Browse files
authored
Merge branch 'master' into u32-from-char-opt
2 parents 79fdc9b + 686bfc4 commit 526aa8c

File tree

675 files changed

+6235
-4787
lines changed

Some content is hidden

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

675 files changed

+6235
-4787
lines changed

.github/workflows/ci.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ jobs:
5252
- name: Checkout the source code
5353
uses: actions/checkout@v4
5454
- name: Calculate the CI job matrix
55+
env:
56+
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
5557
run: python3 src/ci/github-actions/calculate-job-matrix.py >> $GITHUB_OUTPUT
5658
id: jobs
5759
job:
@@ -75,14 +77,6 @@ jobs:
7577
matrix:
7678
# Check the `calculate_matrix` job to see how is the matrix defined.
7779
include: ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }}
78-
# GitHub Actions fails the workflow if an empty list of jobs is provided to
79-
# the workflow, so we need to skip this job if nothing was produced by
80-
# the Python script.
81-
#
82-
# Unfortunately checking whether a list is empty is not possible in a nice
83-
# way due to GitHub Actions expressions limits.
84-
# This hack is taken from https://github.com/ferrocene/ferrocene/blob/d43edc6b7697cf1719ec1c17c54904ab94825763/.github/workflows/release.yml#L75-L82
85-
if: fromJSON(needs.calculate_matrix.outputs.jobs)[0] != null
8680
steps:
8781
- if: contains(matrix.os, 'windows')
8882
uses: msys2/[email protected]

Cargo.lock

+8-15
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,9 @@ version = "0.1.0"
479479

480480
[[package]]
481481
name = "cc"
482-
version = "1.0.92"
482+
version = "1.0.97"
483483
source = "registry+https://github.com/rust-lang/crates.io-index"
484-
checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41"
484+
checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4"
485485

486486
[[package]]
487487
name = "cfg-if"
@@ -1218,9 +1218,9 @@ dependencies = [
12181218

12191219
[[package]]
12201220
name = "ena"
1221-
version = "0.14.2"
1221+
version = "0.14.3"
12221222
source = "registry+https://github.com/rust-lang/crates.io-index"
1223-
checksum = "c533630cf40e9caa44bd91aadc88a75d75a4c3a12b4cfde353cbed41daa1e1f1"
1223+
checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5"
12241224
dependencies = [
12251225
"log",
12261226
]
@@ -2219,7 +2219,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
22192219
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
22202220
dependencies = [
22212221
"cfg-if",
2222-
"windows-targets 0.48.5",
2222+
"windows-targets 0.52.4",
22232223
]
22242224

22252225
[[package]]
@@ -2760,7 +2760,7 @@ dependencies = [
27602760
"tabled",
27612761
"tar",
27622762
"tempfile",
2763-
"xz",
2763+
"xz2",
27642764
"zip",
27652765
]
27662766

@@ -3746,8 +3746,10 @@ name = "rustc_codegen_ssa"
37463746
version = "0.0.0"
37473747
dependencies = [
37483748
"ar_archive_writer",
3749+
"arrayvec",
37493750
"bitflags 2.5.0",
37503751
"cc",
3752+
"either",
37513753
"itertools 0.12.1",
37523754
"jobserver",
37533755
"libc",
@@ -6586,15 +6588,6 @@ dependencies = [
65866588
"rustix",
65876589
]
65886590

6589-
[[package]]
6590-
name = "xz"
6591-
version = "0.1.0"
6592-
source = "registry+https://github.com/rust-lang/crates.io-index"
6593-
checksum = "3c887690ff2a2e233e8e49633461521f98ec57fbff9d59a884c9a4f04ec1da34"
6594-
dependencies = [
6595-
"xz2",
6596-
]
6597-
65986591
[[package]]
65996592
name = "xz2"
66006593
version = "0.1.7"

compiler/rustc_abi/src/layout.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::borrow::{Borrow, Cow};
22
use std::cmp;
33
use std::fmt::{self, Write};
44
use std::iter;
5+
use std::num::NonZero;
56
use std::ops::Bound;
67
use std::ops::Deref;
78

@@ -10,8 +11,8 @@ use tracing::debug;
1011

1112
use crate::{
1213
Abi, AbiAndPrefAlign, Align, FieldsShape, IndexSlice, IndexVec, Integer, LayoutS, Niche,
13-
NonZeroUsize, Primitive, ReprOptions, Scalar, Size, StructKind, TagEncoding, TargetDataLayout,
14-
Variants, WrappingRange,
14+
Primitive, ReprOptions, Scalar, Size, StructKind, TagEncoding, TargetDataLayout, Variants,
15+
WrappingRange,
1516
};
1617

1718
// A variant is absent if it's uninhabited and only has ZST fields.
@@ -327,7 +328,7 @@ pub trait LayoutCalculator {
327328

328329
Some(LayoutS {
329330
variants: Variants::Single { index: VariantIdx::new(0) },
330-
fields: FieldsShape::Union(NonZeroUsize::new(only_variant.len())?),
331+
fields: FieldsShape::Union(NonZero::new(only_variant.len())?),
331332
abi,
332333
largest_niche: None,
333334
align,

compiler/rustc_abi/src/lib.rs

+40-14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![cfg_attr(feature = "nightly", feature(rustdoc_internals))]
55

66
use std::fmt;
7-
use std::num::{NonZeroUsize, ParseIntError};
7+
use std::num::{NonZero, ParseIntError};
88
use std::ops::{Add, AddAssign, Mul, RangeInclusive, Sub};
99
use std::str::FromStr;
1010

@@ -926,6 +926,41 @@ impl Integer {
926926
}
927927
}
928928

929+
/// Floating-point types.
930+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
931+
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
932+
pub enum Float {
933+
F16,
934+
F32,
935+
F64,
936+
F128,
937+
}
938+
939+
impl Float {
940+
pub fn size(self) -> Size {
941+
use Float::*;
942+
943+
match self {
944+
F16 => Size::from_bits(16),
945+
F32 => Size::from_bits(32),
946+
F64 => Size::from_bits(64),
947+
F128 => Size::from_bits(128),
948+
}
949+
}
950+
951+
pub fn align<C: HasDataLayout>(self, cx: &C) -> AbiAndPrefAlign {
952+
use Float::*;
953+
let dl = cx.data_layout();
954+
955+
match self {
956+
F16 => dl.f16_align,
957+
F32 => dl.f32_align,
958+
F64 => dl.f64_align,
959+
F128 => dl.f128_align,
960+
}
961+
}
962+
}
963+
929964
/// Fundamental unit of memory access and layout.
930965
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
931966
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
@@ -938,10 +973,7 @@ pub enum Primitive {
938973
/// a negative integer passed by zero-extension will appear positive in
939974
/// the callee, and most operations on it will produce the wrong values.
940975
Int(Integer, bool),
941-
F16,
942-
F32,
943-
F64,
944-
F128,
976+
Float(Float),
945977
Pointer(AddressSpace),
946978
}
947979

@@ -952,10 +984,7 @@ impl Primitive {
952984

953985
match self {
954986
Int(i, _) => i.size(),
955-
F16 => Size::from_bits(16),
956-
F32 => Size::from_bits(32),
957-
F64 => Size::from_bits(64),
958-
F128 => Size::from_bits(128),
987+
Float(f) => f.size(),
959988
// FIXME(erikdesjardins): ignoring address space is technically wrong, pointers in
960989
// different address spaces can have different sizes
961990
// (but TargetDataLayout doesn't currently parse that part of the DL string)
@@ -969,10 +998,7 @@ impl Primitive {
969998

970999
match self {
9711000
Int(i, _) => i.align(dl),
972-
F16 => dl.f16_align,
973-
F32 => dl.f32_align,
974-
F64 => dl.f64_align,
975-
F128 => dl.f128_align,
1001+
Float(f) => f.align(dl),
9761002
// FIXME(erikdesjardins): ignoring address space is technically wrong, pointers in
9771003
// different address spaces can have different alignments
9781004
// (but TargetDataLayout doesn't currently parse that part of the DL string)
@@ -1149,7 +1175,7 @@ pub enum FieldsShape<FieldIdx: Idx> {
11491175
Primitive,
11501176

11511177
/// All fields start at no offset. The `usize` is the field count.
1152-
Union(NonZeroUsize),
1178+
Union(NonZero<usize>),
11531179

11541180
/// Array/vector-like placement, with all fields of identical types.
11551181
Array { stride: Size, count: u64 },

compiler/rustc_ast/src/ast.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ pub enum ExprKind {
14221422
/// of `if` / `while` expressions. (e.g., `if let 0 = x { .. }`).
14231423
///
14241424
/// `Span` represents the whole `let pat = expr` statement.
1425-
Let(P<Pat>, P<Expr>, Span, Option<ErrorGuaranteed>),
1425+
Let(P<Pat>, P<Expr>, Span, Recovered),
14261426
/// An `if` block, with an optional `else` block.
14271427
///
14281428
/// `if expr { block } else { expr }`
@@ -2164,7 +2164,7 @@ pub enum TyKind {
21642164
MacCall(P<MacCall>),
21652165
/// Placeholder for a `va_list`.
21662166
CVarArgs,
2167-
/// Pattern types like `pattern_type!(u32 is 1..=)`, which is the same as `NonZeroU32`,
2167+
/// Pattern types like `pattern_type!(u32 is 1..=)`, which is the same as `NonZero<u32>`,
21682168
/// just as part of the type system.
21692169
Pat(P<Ty>, P<Pat>),
21702170
/// Sometimes we need a dummy value when no error has occurred.
@@ -2729,7 +2729,7 @@ pub enum UseTreeKind {
27292729
/// `use prefix` or `use prefix as rename`
27302730
Simple(Option<Ident>),
27312731
/// `use prefix::{...}`
2732-
Nested(ThinVec<(UseTree, NodeId)>),
2732+
Nested { items: ThinVec<(UseTree, NodeId)>, span: Span },
27332733
/// `use prefix::*`
27342734
Glob,
27352735
}
@@ -2881,17 +2881,20 @@ pub struct FieldDef {
28812881
pub is_placeholder: bool,
28822882
}
28832883

2884+
/// Was parsing recovery performed?
2885+
#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable_Generic)]
2886+
pub enum Recovered {
2887+
No,
2888+
Yes(ErrorGuaranteed),
2889+
}
2890+
28842891
/// Fields and constructor ids of enum variants and structs.
28852892
#[derive(Clone, Encodable, Decodable, Debug)]
28862893
pub enum VariantData {
28872894
/// Struct variant.
28882895
///
28892896
/// E.g., `Bar { .. }` as in `enum Foo { Bar { .. } }`.
2890-
Struct {
2891-
fields: ThinVec<FieldDef>,
2892-
// FIXME: investigate making this a `Option<ErrorGuaranteed>`
2893-
recovered: bool,
2894-
},
2897+
Struct { fields: ThinVec<FieldDef>, recovered: Recovered },
28952898
/// Tuple variant.
28962899
///
28972900
/// E.g., `Bar(..)` as in `enum Foo { Bar(..) }`.

compiler/rustc_ast/src/mut_visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ fn noop_visit_use_tree<T: MutVisitor>(use_tree: &mut UseTree, vis: &mut T) {
441441
vis.visit_path(prefix);
442442
match kind {
443443
UseTreeKind::Simple(rename) => visit_opt(rename, |rename| vis.visit_ident(rename)),
444-
UseTreeKind::Nested(items) => {
444+
UseTreeKind::Nested { items, .. } => {
445445
for (tree, id) in items {
446446
vis.visit_use_tree(tree);
447447
vis.visit_id(id);

compiler/rustc_ast/src/visit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,8 @@ pub fn walk_use_tree<'a, V: Visitor<'a>>(
517517
visit_opt!(visitor, visit_ident, rename);
518518
}
519519
UseTreeKind::Glob => {}
520-
UseTreeKind::Nested(ref use_trees) => {
521-
for &(ref nested_tree, nested_id) in use_trees {
520+
UseTreeKind::Nested { ref items, .. } => {
521+
for &(ref nested_tree, nested_id) in items {
522522
try_visit!(visitor.visit_use_tree(nested_tree, nested_id, true));
523523
}
524524
}

compiler/rustc_ast_lowering/src/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
158158
let ohs = self.lower_expr(ohs);
159159
hir::ExprKind::AddrOf(*k, *m, ohs)
160160
}
161-
ExprKind::Let(pat, scrutinee, span, is_recovered) => {
161+
ExprKind::Let(pat, scrutinee, span, recovered) => {
162162
hir::ExprKind::Let(self.arena.alloc(hir::LetExpr {
163163
span: self.lower_span(*span),
164164
pat: self.lower_pat(pat),
165165
ty: None,
166166
init: self.lower_expr(scrutinee),
167-
is_recovered: *is_recovered,
167+
recovered: *recovered,
168168
}))
169169
}
170170
ExprKind::If(cond, then, else_opt) => {

compiler/rustc_ast_lowering/src/item.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
135135

136136
fn lower_item_id_use_tree(&mut self, tree: &UseTree, vec: &mut SmallVec<[hir::ItemId; 1]>) {
137137
match &tree.kind {
138-
UseTreeKind::Nested(nested_vec) => {
139-
for &(ref nested, id) in nested_vec {
138+
UseTreeKind::Nested { items, .. } => {
139+
for &(ref nested, id) in items {
140140
vec.push(hir::ItemId {
141141
owner_id: hir::OwnerId { def_id: self.local_def_id(id) },
142142
});
@@ -518,7 +518,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
518518
let path = self.lower_use_path(res, &path, ParamMode::Explicit);
519519
hir::ItemKind::Use(path, hir::UseKind::Glob)
520520
}
521-
UseTreeKind::Nested(ref trees) => {
521+
UseTreeKind::Nested { items: ref trees, .. } => {
522522
// Nested imports are desugared into simple imports.
523523
// So, if we start with
524524
//

compiler/rustc_ast_lowering/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12831283
fields.iter().enumerate().map(|f| this.lower_field_def(f)),
12841284
);
12851285
let span = t.span;
1286-
let variant_data = hir::VariantData::Struct { fields, recovered: false };
1286+
let variant_data =
1287+
hir::VariantData::Struct { fields, recovered: ast::Recovered::No };
12871288
// FIXME: capture the generics from the outer adt.
12881289
let generics = hir::Generics::empty();
12891290
let kind = match t.kind {

compiler/rustc_ast_pretty/src/pprust/state/item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ impl<'a> State<'a> {
715715
}
716716
self.word("*");
717717
}
718-
ast::UseTreeKind::Nested(items) => {
718+
ast::UseTreeKind::Nested { items, .. } => {
719719
if !tree.prefix.segments.is_empty() {
720720
self.print_path(&tree.prefix, false, 0);
721721
self.word("::");
@@ -734,7 +734,7 @@ impl<'a> State<'a> {
734734
self.print_use_tree(&use_tree.0);
735735
if !is_last {
736736
self.word(",");
737-
if let ast::UseTreeKind::Nested(_) = use_tree.0.kind {
737+
if let ast::UseTreeKind::Nested { .. } = use_tree.0.kind {
738738
self.hardbreak();
739739
} else {
740740
self.space();

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use rustc_middle::mir::{
2222
Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator,
2323
TerminatorKind, VarBindingForm,
2424
};
25+
use rustc_middle::ty::print::PrintTraitRefExt as _;
2526
use rustc_middle::ty::{
2627
self, suggest_constraining_type_params, PredicateKind, ToPredicate, Ty, TyCtxt,
2728
TypeSuperVisitable, TypeVisitor,
@@ -494,7 +495,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
494495
{
495496
self.suggest_cloning(err, ty, expr, None, Some(move_spans));
496497
} else if self.suggest_hoisting_call_outside_loop(err, expr) {
497-
// The place where the the type moves would be misleading to suggest clone.
498+
// The place where the type moves would be misleading to suggest clone.
498499
// #121466
499500
self.suggest_cloning(err, ty, expr, None, Some(move_spans));
500501
}

0 commit comments

Comments
 (0)