Skip to content

Commit ac667ef

Browse files
authored
Merge pull request rust-lang#4082 from RalfJung/rustup
Rustup
2 parents a33b4b1 + c498e7f commit ac667ef

File tree

313 files changed

+2694
-1526
lines changed

Some content is hidden

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

313 files changed

+2694
-1526
lines changed

Cargo.lock

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

28152815
[[package]]
28162816
name = "psm"
2817-
version = "0.1.23"
2817+
version = "0.1.24"
28182818
source = "registry+https://github.com/rust-lang/crates.io-index"
2819-
checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205"
2819+
checksum = "200b9ff220857e53e184257720a14553b2f4aa02577d2ed9842d45d4b9654810"
28202820
dependencies = [
28212821
"cc",
28222822
]

RELEASES.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ Compatibility Notes
503503
* We have renamed `std::panic::PanicInfo` to `std::panic::PanicHookInfo`. The old name will continue to work as an alias, but will result in a deprecation warning starting in Rust 1.82.0.
504504

505505
`core::panic::PanicInfo` will remain unchanged, however, as this is now a *different type*.
506-
506+
507507
The reason is that these types have different roles: `std::panic::PanicHookInfo` is the argument to the [panic hook](https://doc.rust-lang.org/stable/std/panic/fn.set_hook.html) in std context (where panics can have an arbitrary payload), while `core::panic::PanicInfo` is the argument to the [`#[panic_handler]`](https://doc.rust-lang.org/nomicon/panic-handler.html) in no_std context (where panics always carry a formatted *message*). Separating these types allows us to add more useful methods to these types, such as `std::panic::PanicHookInfo::payload_as_str()` and `core::panic::PanicInfo::message()`.
508508

509509
* The new sort implementations may panic if a type's implementation of [`Ord`](https://doc.rust-lang.org/std/cmp/trait.Ord.html) (or the given comparison function) does not implement a [total order](https://en.wikipedia.org/wiki/Total_order) as the trait requires. `Ord`'s supertraits (`PartialOrd`, `Eq`, and `PartialEq`) must also be consistent. The previous implementations would not "notice" any problem, but the new implementations have a good chance of detecting inconsistencies, throwing a panic rather than returning knowingly unsorted data.
@@ -584,7 +584,7 @@ Stabilized APIs
584584
- [`impl Default for Arc<CStr>`](https://doc.rust-lang.org/beta/alloc/sync/struct.Arc.html#impl-Default-for-Arc%3CCStr%3E)
585585
- [`impl Default for Arc<[T]>`](https://doc.rust-lang.org/beta/alloc/sync/struct.Arc.html#impl-Default-for-Arc%3C%5BT%5D%3E)
586586
- [`impl IntoIterator for Box<[T]>`](https://doc.rust-lang.org/beta/alloc/boxed/struct.Box.html#impl-IntoIterator-for-Box%3C%5BI%5D,+A%3E)
587-
- [`impl FromIterator<String> for Box<str>`](https://doc.rust-lang.org/beta/alloc/boxed/struct.Box.html#impl-FromIterator%3CString%3E-for-Box%3Cstr%3E)
587+
- [`impl FromIterator<String> for Box<str>`](https://doc.rust-lang.org/beta/alloc/boxed/struct.Box.html#impl-FromIterator%3CString%3E-for-Box%3Cstr%3E)
588588
- [`impl FromIterator<char> for Box<str>`](https://doc.rust-lang.org/beta/alloc/boxed/struct.Box.html#impl-FromIterator%3Cchar%3E-for-Box%3Cstr%3E)
589589
- [`LazyCell`](https://doc.rust-lang.org/beta/core/cell/struct.LazyCell.html)
590590
- [`LazyLock`](https://doc.rust-lang.org/beta/std/sync/struct.LazyLock.html)
@@ -1816,7 +1816,7 @@ Compiler
18161816
- [Detect uninhabited types early in const eval](https://github.com/rust-lang/rust/pull/109435/)
18171817
- [Switch to LLD as default linker for {arm,thumb}v4t-none-eabi](https://github.com/rust-lang/rust/pull/109721/)
18181818
- [Add tier 3 target `loongarch64-unknown-linux-gnu`](https://github.com/rust-lang/rust/pull/96971)
1819-
- [Add tier 3 target for `i586-pc-nto-qnx700` (QNX Neutrino RTOS, version 7.0)](https://github.com/rust-lang/rust/pull/109173/),
1819+
- [Add tier 3 target for `i586-pc-nto-qnx700` (QNX Neutrino RTOS, version 7.0)](https://github.com/rust-lang/rust/pull/109173/),
18201820
- [Insert alignment checks for pointer dereferences as debug assertions](https://github.com/rust-lang/rust/pull/98112)
18211821
This catches undefined behavior at runtime, and may cause existing code to fail.
18221822

@@ -2023,7 +2023,7 @@ Compatibility Notes
20232023
If `tools = [...]` is set in config.toml, we will respect a missing rustdoc in that list. By
20242024
default rustdoc remains included. To retain the prior behavior explicitly add `"rustdoc"` to the
20252025
list.
2026-
2026+
20272027
<a id="1.69.0-Internal-Changes"></a>
20282028

20292029
Internal Changes

compiler/rustc_ast/src/ast.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,11 @@ impl Pat {
627627
| PatKind::Or(s) => s.iter().for_each(|p| p.walk(it)),
628628

629629
// Trivial wrappers over inner patterns.
630-
PatKind::Box(s) | PatKind::Deref(s) | PatKind::Ref(s, _) | PatKind::Paren(s) => {
631-
s.walk(it)
632-
}
630+
PatKind::Box(s)
631+
| PatKind::Deref(s)
632+
| PatKind::Ref(s, _)
633+
| PatKind::Paren(s)
634+
| PatKind::Guard(s, _) => s.walk(it),
633635

634636
// These patterns do not contain subpatterns, skip.
635637
PatKind::Wild
@@ -839,6 +841,9 @@ pub enum PatKind {
839841
// A never pattern `!`.
840842
Never,
841843

844+
/// A guard pattern (e.g., `x if guard(x)`).
845+
Guard(P<Pat>, P<Expr>),
846+
842847
/// Parentheses in patterns used for grouping (i.e., `(PAT)`).
843848
Paren(P<Pat>),
844849

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,10 @@ pub fn walk_pat<T: MutVisitor>(vis: &mut T, pat: &mut P<Pat>) {
15251525
visit_opt(e2, |e| vis.visit_expr(e));
15261526
vis.visit_span(span);
15271527
}
1528+
PatKind::Guard(p, e) => {
1529+
vis.visit_pat(p);
1530+
vis.visit_expr(e);
1531+
}
15281532
PatKind::Tuple(elems) | PatKind::Slice(elems) | PatKind::Or(elems) => {
15291533
visit_thin_vec(elems, |elem| vis.visit_pat(elem))
15301534
}

compiler/rustc_ast/src/visit.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,10 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) -> V::Res
682682
visit_opt!(visitor, visit_expr, lower_bound);
683683
visit_opt!(visitor, visit_expr, upper_bound);
684684
}
685+
PatKind::Guard(subpattern, guard_condition) => {
686+
try_visit!(visitor.visit_pat(subpattern));
687+
try_visit!(visitor.visit_expr(guard_condition));
688+
}
685689
PatKind::Wild | PatKind::Rest | PatKind::Never => {}
686690
PatKind::Err(_guar) => {}
687691
PatKind::Tuple(elems) | PatKind::Slice(elems) | PatKind::Or(elems) => {

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
114114
self.lower_range_end(end, e2.is_some()),
115115
);
116116
}
117+
// FIXME(guard_patterns): lower pattern guards to HIR
118+
PatKind::Guard(inner, _) => pattern = inner,
117119
PatKind::Slice(pats) => break self.lower_pat_slice(pats),
118120
PatKind::Rest => {
119121
// If we reach here the `..` pattern is not semantically allowed.

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
556556
gate_all!(builtin_syntax, "`builtin #` syntax is unstable");
557557
gate_all!(explicit_tail_calls, "`become` expression is experimental");
558558
gate_all!(generic_const_items, "generic const items are experimental");
559+
gate_all!(guard_patterns, "guard patterns are experimental", "consider using match arm guards");
559560
gate_all!(fn_delegation, "functions delegation is not yet fully implemented");
560561
gate_all!(postfix_match, "postfix match is experimental");
561562
gate_all!(mut_ref, "mutable by-reference bindings are experimental");

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,14 @@ impl<'a> State<'a> {
17091709
self.print_expr(e, FixupContext::default());
17101710
}
17111711
}
1712+
PatKind::Guard(subpat, condition) => {
1713+
self.popen();
1714+
self.print_pat(subpat);
1715+
self.space();
1716+
self.word_space("if");
1717+
self.print_expr(condition, FixupContext::default());
1718+
self.pclose();
1719+
}
17121720
PatKind::Slice(elts) => {
17131721
self.word("[");
17141722
self.commasep(Inconsistent, elts, |s, p| s.print_pat(p));

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,6 +1450,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
14501450
ty::Param(param_ty) => Ok((
14511451
generics.type_param(param_ty, tcx),
14521452
predicate.trait_ref.print_trait_sugared().to_string(),
1453+
Some(predicate.trait_ref.def_id),
14531454
)),
14541455
_ => Err(()),
14551456
}
@@ -1463,9 +1464,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
14631464
tcx,
14641465
hir_generics,
14651466
err,
1466-
predicates
1467-
.iter()
1468-
.map(|(param, constraint)| (param.name.as_str(), &**constraint, None)),
1467+
predicates.iter().map(|(param, constraint, def_id)| {
1468+
(param.name.as_str(), &**constraint, *def_id)
1469+
}),
14691470
None,
14701471
);
14711472
}

compiler/rustc_codegen_cranelift/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,6 @@ impl CodegenBackend for CraneliftCodegenBackend {
227227
sess: &Session,
228228
outputs: &OutputFilenames,
229229
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>) {
230-
let _timer = sess.timer("finish_ongoing_codegen");
231-
232230
ongoing_codegen.downcast::<driver::aot::OngoingCodegen>().unwrap().join(sess, outputs)
233231
}
234232
}

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 75 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -352,84 +352,84 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
352352
| sym::saturating_add
353353
| sym::saturating_sub => {
354354
let ty = arg_tys[0];
355-
match int_type_width_signed(ty, self) {
356-
Some((width, signed)) => match name {
357-
sym::ctlz | sym::cttz => {
358-
let y = self.const_bool(false);
359-
let ret = self.call_intrinsic(&format!("llvm.{name}.i{width}"), &[
360-
args[0].immediate(),
361-
y,
362-
]);
363-
364-
self.intcast(ret, llret_ty, false)
365-
}
366-
sym::ctlz_nonzero => {
367-
let y = self.const_bool(true);
368-
let llvm_name = &format!("llvm.ctlz.i{width}");
369-
let ret = self.call_intrinsic(llvm_name, &[args[0].immediate(), y]);
370-
self.intcast(ret, llret_ty, false)
371-
}
372-
sym::cttz_nonzero => {
373-
let y = self.const_bool(true);
374-
let llvm_name = &format!("llvm.cttz.i{width}");
375-
let ret = self.call_intrinsic(llvm_name, &[args[0].immediate(), y]);
376-
self.intcast(ret, llret_ty, false)
377-
}
378-
sym::ctpop => {
379-
let ret = self.call_intrinsic(&format!("llvm.ctpop.i{width}"), &[args
380-
[0]
381-
.immediate()]);
382-
self.intcast(ret, llret_ty, false)
383-
}
384-
sym::bswap => {
385-
if width == 8 {
386-
args[0].immediate() // byte swap a u8/i8 is just a no-op
387-
} else {
388-
self.call_intrinsic(&format!("llvm.bswap.i{width}"), &[
389-
args[0].immediate()
390-
])
391-
}
392-
}
393-
sym::bitreverse => self
394-
.call_intrinsic(&format!("llvm.bitreverse.i{width}"), &[
355+
if !ty.is_integral() {
356+
tcx.dcx().emit_err(InvalidMonomorphization::BasicIntegerType {
357+
span,
358+
name,
359+
ty,
360+
});
361+
return Ok(());
362+
}
363+
let (size, signed) = ty.int_size_and_signed(self.tcx);
364+
let width = size.bits();
365+
match name {
366+
sym::ctlz | sym::cttz => {
367+
let y = self.const_bool(false);
368+
let ret = self.call_intrinsic(&format!("llvm.{name}.i{width}"), &[
369+
args[0].immediate(),
370+
y,
371+
]);
372+
373+
self.intcast(ret, llret_ty, false)
374+
}
375+
sym::ctlz_nonzero => {
376+
let y = self.const_bool(true);
377+
let llvm_name = &format!("llvm.ctlz.i{width}");
378+
let ret = self.call_intrinsic(llvm_name, &[args[0].immediate(), y]);
379+
self.intcast(ret, llret_ty, false)
380+
}
381+
sym::cttz_nonzero => {
382+
let y = self.const_bool(true);
383+
let llvm_name = &format!("llvm.cttz.i{width}");
384+
let ret = self.call_intrinsic(llvm_name, &[args[0].immediate(), y]);
385+
self.intcast(ret, llret_ty, false)
386+
}
387+
sym::ctpop => {
388+
let ret = self.call_intrinsic(&format!("llvm.ctpop.i{width}"), &[
389+
args[0].immediate()
390+
]);
391+
self.intcast(ret, llret_ty, false)
392+
}
393+
sym::bswap => {
394+
if width == 8 {
395+
args[0].immediate() // byte swap a u8/i8 is just a no-op
396+
} else {
397+
self.call_intrinsic(&format!("llvm.bswap.i{width}"), &[
395398
args[0].immediate()
396-
]),
397-
sym::rotate_left | sym::rotate_right => {
398-
let is_left = name == sym::rotate_left;
399-
let val = args[0].immediate();
400-
let raw_shift = args[1].immediate();
401-
// rotate = funnel shift with first two args the same
402-
let llvm_name =
403-
&format!("llvm.fsh{}.i{}", if is_left { 'l' } else { 'r' }, width);
404-
405-
// llvm expects shift to be the same type as the values, but rust
406-
// always uses `u32`.
407-
let raw_shift = self.intcast(raw_shift, self.val_ty(val), false);
408-
409-
self.call_intrinsic(llvm_name, &[val, val, raw_shift])
399+
])
410400
}
411-
sym::saturating_add | sym::saturating_sub => {
412-
let is_add = name == sym::saturating_add;
413-
let lhs = args[0].immediate();
414-
let rhs = args[1].immediate();
415-
let llvm_name = &format!(
416-
"llvm.{}{}.sat.i{}",
417-
if signed { 's' } else { 'u' },
418-
if is_add { "add" } else { "sub" },
419-
width
420-
);
421-
self.call_intrinsic(llvm_name, &[lhs, rhs])
422-
}
423-
_ => bug!(),
424-
},
425-
None => {
426-
tcx.dcx().emit_err(InvalidMonomorphization::BasicIntegerType {
427-
span,
428-
name,
429-
ty,
430-
});
431-
return Ok(());
432401
}
402+
sym::bitreverse => self
403+
.call_intrinsic(&format!("llvm.bitreverse.i{width}"), &[
404+
args[0].immediate()
405+
]),
406+
sym::rotate_left | sym::rotate_right => {
407+
let is_left = name == sym::rotate_left;
408+
let val = args[0].immediate();
409+
let raw_shift = args[1].immediate();
410+
// rotate = funnel shift with first two args the same
411+
let llvm_name =
412+
&format!("llvm.fsh{}.i{}", if is_left { 'l' } else { 'r' }, width);
413+
414+
// llvm expects shift to be the same type as the values, but rust
415+
// always uses `u32`.
416+
let raw_shift = self.intcast(raw_shift, self.val_ty(val), false);
417+
418+
self.call_intrinsic(llvm_name, &[val, val, raw_shift])
419+
}
420+
sym::saturating_add | sym::saturating_sub => {
421+
let is_add = name == sym::saturating_add;
422+
let lhs = args[0].immediate();
423+
let rhs = args[1].immediate();
424+
let llvm_name = &format!(
425+
"llvm.{}{}.sat.i{}",
426+
if signed { 's' } else { 'u' },
427+
if is_add { "add" } else { "sub" },
428+
width
429+
);
430+
self.call_intrinsic(llvm_name, &[lhs, rhs])
431+
}
432+
_ => bug!(),
433433
}
434434
}
435435

@@ -2531,19 +2531,3 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
25312531

25322532
span_bug!(span, "unknown SIMD intrinsic");
25332533
}
2534-
2535-
// Returns the width of an int Ty, and if it's signed or not
2536-
// Returns None if the type is not an integer
2537-
// FIXME: there’s multiple of this functions, investigate using some of the already existing
2538-
// stuffs.
2539-
fn int_type_width_signed(ty: Ty<'_>, cx: &CodegenCx<'_, '_>) -> Option<(u64, bool)> {
2540-
match ty.kind() {
2541-
ty::Int(t) => {
2542-
Some((t.bit_width().unwrap_or(u64::from(cx.tcx.sess.target.pointer_width)), true))
2543-
}
2544-
ty::Uint(t) => {
2545-
Some((t.bit_width().unwrap_or(u64::from(cx.tcx.sess.target.pointer_width)), false))
2546-
}
2547-
_ => None,
2548-
}
2549-
}

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use rustc_codegen_ssa::back::write::{
3636
use rustc_codegen_ssa::traits::*;
3737
use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen};
3838
use rustc_data_structures::fx::FxIndexMap;
39-
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, FatalError};
39+
use rustc_errors::{DiagCtxtHandle, FatalError};
4040
use rustc_metadata::EncodedMetadata;
4141
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
4242
use rustc_middle::ty::TyCtxt;
@@ -370,19 +370,14 @@ impl CodegenBackend for LlvmCodegenBackend {
370370
(codegen_results, work_products)
371371
}
372372

373-
fn link(
374-
&self,
375-
sess: &Session,
376-
codegen_results: CodegenResults,
377-
outputs: &OutputFilenames,
378-
) -> Result<(), ErrorGuaranteed> {
373+
fn link(&self, sess: &Session, codegen_results: CodegenResults, outputs: &OutputFilenames) {
379374
use rustc_codegen_ssa::back::link::link_binary;
380375

381376
use crate::back::archive::LlvmArchiveBuilderBuilder;
382377

383378
// Run the linker on any artifacts that resulted from the LLVM run.
384379
// This should produce either a finished executable or library.
385-
link_binary(sess, &LlvmArchiveBuilderBuilder, codegen_results, outputs)
380+
link_binary(sess, &LlvmArchiveBuilderBuilder, codegen_results, outputs);
386381
}
387382
}
388383

0 commit comments

Comments
 (0)