Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f280acf

Browse files
committedFeb 19, 2025·
Auto merge of rust-lang#137284 - matthiaskrgr:rollup-deuhk46, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#127793 (Added project-specific Zed IDE settings) - rust-lang#134995 (Stabilize const_slice_flatten) - rust-lang#136301 (Improve instant docs) - rust-lang#136347 (Add a bullet point to `std::fs::copy`) - rust-lang#136794 (Stabilize file_lock) - rust-lang#137094 (x86_win64 ABI: do not use xmm0 with softfloat ABI) - rust-lang#137227 (docs(dev): Update the feature-gate instructions) - rust-lang#137232 (Don't mention `FromResidual` on bad `?`) - rust-lang#137251 (coverage: Get hole spans from nested items without fully visiting them) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ed49386 + 3fc6dfd commit f280acf

File tree

21 files changed

+330
-125
lines changed

21 files changed

+330
-125
lines changed
 

‎compiler/rustc_mir_transform/src/coverage/mod.rs

+26-25
Original file line numberDiff line numberDiff line change
@@ -346,35 +346,37 @@ fn extract_hole_spans_from_hir<'tcx>(
346346
body_span: Span, // Usually `hir_body.value.span`, but not always
347347
hir_body: &hir::Body<'tcx>,
348348
) -> Vec<Span> {
349-
struct HolesVisitor<'hir, F> {
350-
tcx: TyCtxt<'hir>,
351-
visit_hole_span: F,
349+
struct HolesVisitor<'tcx> {
350+
tcx: TyCtxt<'tcx>,
351+
body_span: Span,
352+
hole_spans: Vec<Span>,
352353
}
353354

354-
impl<'hir, F: FnMut(Span)> Visitor<'hir> for HolesVisitor<'hir, F> {
355-
/// - We need `NestedFilter::INTRA = true` so that `visit_item` will be called.
356-
/// - Bodies of nested items don't actually get visited, because of the
357-
/// `visit_item` override.
358-
/// - For nested bodies that are not part of an item, we do want to visit any
359-
/// items contained within them.
360-
type NestedFilter = nested_filter::All;
355+
impl<'tcx> Visitor<'tcx> for HolesVisitor<'tcx> {
356+
/// We have special handling for nested items, but we still want to
357+
/// traverse into nested bodies of things that are not considered items,
358+
/// such as "anon consts" (e.g. array lengths).
359+
type NestedFilter = nested_filter::OnlyBodies;
361360

362-
fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
361+
fn maybe_tcx(&mut self) -> TyCtxt<'tcx> {
363362
self.tcx
364363
}
365364

366-
fn visit_item(&mut self, item: &'hir hir::Item<'hir>) {
367-
(self.visit_hole_span)(item.span);
365+
/// We override `visit_nested_item` instead of `visit_item` because we
366+
/// only need the item's span, not the item itself.
367+
fn visit_nested_item(&mut self, id: hir::ItemId) -> Self::Result {
368+
let span = self.tcx.def_span(id.owner_id.def_id);
369+
self.visit_hole_span(span);
368370
// Having visited this item, we don't care about its children,
369371
// so don't call `walk_item`.
370372
}
371373

372374
// We override `visit_expr` instead of the more specific expression
373375
// visitors, so that we have direct access to the expression span.
374-
fn visit_expr(&mut self, expr: &'hir hir::Expr<'hir>) {
376+
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
375377
match expr.kind {
376378
hir::ExprKind::Closure(_) | hir::ExprKind::ConstBlock(_) => {
377-
(self.visit_hole_span)(expr.span);
379+
self.visit_hole_span(expr.span);
378380
// Having visited this expression, we don't care about its
379381
// children, so don't call `walk_expr`.
380382
}
@@ -384,18 +386,17 @@ fn extract_hole_spans_from_hir<'tcx>(
384386
}
385387
}
386388
}
387-
388-
let mut hole_spans = vec![];
389-
let mut visitor = HolesVisitor {
390-
tcx,
391-
visit_hole_span: |hole_span| {
389+
impl HolesVisitor<'_> {
390+
fn visit_hole_span(&mut self, hole_span: Span) {
392391
// Discard any holes that aren't directly visible within the body span.
393-
if body_span.contains(hole_span) && body_span.eq_ctxt(hole_span) {
394-
hole_spans.push(hole_span);
392+
if self.body_span.contains(hole_span) && self.body_span.eq_ctxt(hole_span) {
393+
self.hole_spans.push(hole_span);
395394
}
396-
},
397-
};
395+
}
396+
}
397+
398+
let mut visitor = HolesVisitor { tcx, body_span, hole_spans: vec![] };
398399

399400
visitor.visit_body(hir_body);
400-
hole_spans
401+
visitor.hole_spans
401402
}

‎compiler/rustc_target/src/callconv/x86_win64.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use rustc_abi::{BackendRepr, Float, Integer, Primitive, RegKind, Size};
22

33
use crate::callconv::{ArgAbi, FnAbi, Reg};
4-
use crate::spec::HasTargetSpec;
4+
use crate::spec::{HasTargetSpec, RustcAbi};
55

66
// Win64 ABI: https://docs.microsoft.com/en-us/cpp/build/parameter-passing
77

8-
pub(crate) fn compute_abi_info<Ty>(_cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>) {
8+
pub(crate) fn compute_abi_info<Ty>(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>) {
99
let fixup = |a: &mut ArgAbi<'_, Ty>, is_ret: bool| {
1010
match a.layout.backend_repr {
1111
BackendRepr::Uninhabited | BackendRepr::Memory { sized: false } => {}
@@ -24,10 +24,14 @@ pub(crate) fn compute_abi_info<Ty>(_cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<
2424
}
2525
BackendRepr::Scalar(scalar) => {
2626
if is_ret && matches!(scalar.primitive(), Primitive::Int(Integer::I128, _)) {
27-
// `i128` is returned in xmm0 by Clang and GCC
28-
// FIXME(#134288): This may change for the `-msvc` targets in the future.
29-
let reg = Reg { kind: RegKind::Vector, size: Size::from_bits(128) };
30-
a.cast_to(reg);
27+
if cx.target_spec().rustc_abi == Some(RustcAbi::X86Softfloat) {
28+
// Use the native `i128` LLVM type for the softfloat ABI -- in other words, adjust nothing.
29+
} else {
30+
// `i128` is returned in xmm0 by Clang and GCC
31+
// FIXME(#134288): This may change for the `-msvc` targets in the future.
32+
let reg = Reg { kind: RegKind::Vector, size: Size::from_bits(128) };
33+
a.cast_to(reg);
34+
}
3135
} else if a.layout.size.bytes() > 8
3236
&& !matches!(scalar.primitive(), Primitive::Float(Float::F128))
3337
{

‎compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs

+8
Original file line numberDiff line numberDiff line change
@@ -3289,6 +3289,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
32893289
let mut parent_trait_pred =
32903290
self.resolve_vars_if_possible(data.derived.parent_trait_pred);
32913291
let parent_def_id = parent_trait_pred.def_id();
3292+
if tcx.is_diagnostic_item(sym::FromResidual, parent_def_id)
3293+
&& !tcx.features().enabled(sym::try_trait_v2)
3294+
{
3295+
// If `#![feature(try_trait_v2)]` is not enabled, then there's no point on
3296+
// talking about `FromResidual<Result<A, B>>`, as the end user has nothing they
3297+
// can do about it. As far as they are concerned, `?` is compiler magic.
3298+
return;
3299+
}
32923300
let self_ty_str =
32933301
tcx.short_string(parent_trait_pred.skip_binder().self_ty(), err.long_ty_path());
32943302
let trait_name = parent_trait_pred.print_modifiers_and_trait_path().to_string();

‎library/core/src/slice/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4796,7 +4796,7 @@ impl<T, const N: usize> [[T; N]] {
47964796
/// assert!(empty_slice_of_arrays.as_flattened().is_empty());
47974797
/// ```
47984798
#[stable(feature = "slice_flatten", since = "1.80.0")]
4799-
#[rustc_const_unstable(feature = "const_slice_flatten", issue = "95629")]
4799+
#[rustc_const_stable(feature = "const_slice_flatten", since = "CURRENT_RUSTC_VERSION")]
48004800
pub const fn as_flattened(&self) -> &[T] {
48014801
let len = if T::IS_ZST {
48024802
self.len().checked_mul(N).expect("slice len overflow")
@@ -4833,7 +4833,7 @@ impl<T, const N: usize> [[T; N]] {
48334833
/// assert_eq!(array, [[6, 7, 8], [9, 10, 11], [12, 13, 14]]);
48344834
/// ```
48354835
#[stable(feature = "slice_flatten", since = "1.80.0")]
4836-
#[rustc_const_unstable(feature = "const_slice_flatten", issue = "95629")]
4836+
#[rustc_const_stable(feature = "const_slice_flatten", since = "CURRENT_RUSTC_VERSION")]
48374837
pub const fn as_flattened_mut(&mut self) -> &mut [T] {
48384838
let len = if T::IS_ZST {
48394839
self.len().checked_mul(N).expect("slice len overflow")

‎library/std/src/fs.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,6 @@ impl File {
664664
/// # Examples
665665
///
666666
/// ```no_run
667-
/// #![feature(file_lock)]
668667
/// use std::fs::File;
669668
///
670669
/// fn main() -> std::io::Result<()> {
@@ -673,7 +672,7 @@ impl File {
673672
/// Ok(())
674673
/// }
675674
/// ```
676-
#[unstable(feature = "file_lock", issue = "130994")]
675+
#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")]
677676
pub fn lock(&self) -> io::Result<()> {
678677
self.inner.lock()
679678
}
@@ -717,7 +716,6 @@ impl File {
717716
/// # Examples
718717
///
719718
/// ```no_run
720-
/// #![feature(file_lock)]
721719
/// use std::fs::File;
722720
///
723721
/// fn main() -> std::io::Result<()> {
@@ -726,7 +724,7 @@ impl File {
726724
/// Ok(())
727725
/// }
728726
/// ```
729-
#[unstable(feature = "file_lock", issue = "130994")]
727+
#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")]
730728
pub fn lock_shared(&self) -> io::Result<()> {
731729
self.inner.lock_shared()
732730
}
@@ -775,7 +773,6 @@ impl File {
775773
/// # Examples
776774
///
777775
/// ```no_run
778-
/// #![feature(file_lock)]
779776
/// use std::fs::File;
780777
///
781778
/// fn main() -> std::io::Result<()> {
@@ -784,7 +781,7 @@ impl File {
784781
/// Ok(())
785782
/// }
786783
/// ```
787-
#[unstable(feature = "file_lock", issue = "130994")]
784+
#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")]
788785
pub fn try_lock(&self) -> io::Result<bool> {
789786
self.inner.try_lock()
790787
}
@@ -832,7 +829,6 @@ impl File {
832829
/// # Examples
833830
///
834831
/// ```no_run
835-
/// #![feature(file_lock)]
836832
/// use std::fs::File;
837833
///
838834
/// fn main() -> std::io::Result<()> {
@@ -841,7 +837,7 @@ impl File {
841837
/// Ok(())
842838
/// }
843839
/// ```
844-
#[unstable(feature = "file_lock", issue = "130994")]
840+
#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")]
845841
pub fn try_lock_shared(&self) -> io::Result<bool> {
846842
self.inner.try_lock_shared()
847843
}
@@ -869,7 +865,6 @@ impl File {
869865
/// # Examples
870866
///
871867
/// ```no_run
872-
/// #![feature(file_lock)]
873868
/// use std::fs::File;
874869
///
875870
/// fn main() -> std::io::Result<()> {
@@ -879,7 +874,7 @@ impl File {
879874
/// Ok(())
880875
/// }
881876
/// ```
882-
#[unstable(feature = "file_lock", issue = "130994")]
877+
#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")]
883878
pub fn unlock(&self) -> io::Result<()> {
884879
self.inner.unlock()
885880
}
@@ -2531,6 +2526,7 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()>
25312526
/// * `from` does not exist.
25322527
/// * The current process does not have the permission rights to read
25332528
/// `from` or write `to`.
2529+
/// * The parent directory of `to` doesn't exist.
25342530
///
25352531
/// # Examples
25362532
///

‎library/std/src/time.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,17 @@ use crate::sys_common::{FromInner, IntoInner};
9393
/// use std::time::{Instant, Duration};
9494
///
9595
/// let now = Instant::now();
96-
/// let max_seconds = u64::MAX / 1_000_000_000;
97-
/// let duration = Duration::new(max_seconds, 0);
96+
/// let days_per_10_millennia = 365_2425;
97+
/// let solar_seconds_per_day = 60 * 60 * 24;
98+
/// let millenium_in_solar_seconds = 31_556_952_000;
99+
/// assert_eq!(millenium_in_solar_seconds, days_per_10_millennia * solar_seconds_per_day / 10);
100+
///
101+
/// let duration = Duration::new(millenium_in_solar_seconds, 0);
98102
/// println!("{:?}", now + duration);
99103
/// ```
100104
///
105+
/// For cross-platform code, you can comfortably use durations of up to around one hundred years.
106+
///
101107
/// # Underlying System calls
102108
///
103109
/// The following system calls are [currently] being used by `now()` to find out
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Please sign in to comment.