Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #137284

Merged
merged 25 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7de250f
Stabilize const_slice_flatten
DaniPopes Jan 1, 2025
9cb7432
Improve instant docs
hkBst Jan 30, 2025
ca58e23
Update fs.rs
allevo Jan 31, 2025
82af73d
Stabilize file_lock
cberner Feb 9, 2025
18d7ffa
Prepare `./x setup` to handle more IDEs; make minor improvements
ChaiTRex Feb 15, 2025
d9f125d
Add support for the Zed IDE to `./x setup`
ChaiTRex Feb 15, 2025
8417684
Check all IDE config hashes in `./x test bootstrap`, update Helix hash
ChaiTRex Feb 15, 2025
410331c
Add Zed to dev guide suggested workflows page
ChaiTRex Feb 18, 2025
aecde19
docs(dev): Remove reference to features_untracked
epage Feb 18, 2025
5e92241
docs(dev): Access features as functions, not members
epage Feb 18, 2025
6eb4882
Don't mention `FromResidual` on bad `?`
estebank Feb 18, 2025
d9b91de
coverage: Add some more cases to `tests/coverage/holes.rs`
Zalathar Feb 18, 2025
51f704f
coverage: Get hole spans from nested items without fully visiting them
Zalathar Feb 18, 2025
d38f688
coverage: Make `HolesVisitor::visit_hole_span` a regular method
Zalathar Feb 18, 2025
73b6482
x86_win64 ABI: do not use xmm0 with softfloat ABI
RalfJung Feb 18, 2025
3ad8477
Update library/std/src/fs.rs
allevo Feb 19, 2025
be36bd2
Rollup merge of #127793 - ChaiTRex:zed_support, r=Kobzol
matthiaskrgr Feb 19, 2025
2c380a4
Rollup merge of #134995 - DaniPopes:stable-const_slice_flatten, r=Ama…
matthiaskrgr Feb 19, 2025
2c1e1bd
Rollup merge of #136301 - hkBst:patch-33, r=thomcc
matthiaskrgr Feb 19, 2025
e6406ad
Rollup merge of #136347 - allevo:patch-1, r=Amanieu
matthiaskrgr Feb 19, 2025
ce72b8d
Rollup merge of #136794 - cberner:stabilize, r=joshtriplett
matthiaskrgr Feb 19, 2025
d8debbd
Rollup merge of #137094 - RalfJung:softfloat-means-no-simd, r=tgross35
matthiaskrgr Feb 19, 2025
fa10786
Rollup merge of #137227 - epage:features_untracked, r=compiler-errors
matthiaskrgr Feb 19, 2025
dd60b6c
Rollup merge of #137232 - estebank:from-residual-note, r=petrochenkov
matthiaskrgr Feb 19, 2025
3fc6dfd
Rollup merge of #137251 - Zalathar:holes-visitor, r=jieyouxu
matthiaskrgr Feb 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions compiler/rustc_mir_transform/src/coverage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,35 +346,37 @@ fn extract_hole_spans_from_hir<'tcx>(
body_span: Span, // Usually `hir_body.value.span`, but not always
hir_body: &hir::Body<'tcx>,
) -> Vec<Span> {
struct HolesVisitor<'hir, F> {
tcx: TyCtxt<'hir>,
visit_hole_span: F,
struct HolesVisitor<'tcx> {
tcx: TyCtxt<'tcx>,
body_span: Span,
hole_spans: Vec<Span>,
}

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

fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
fn maybe_tcx(&mut self) -> TyCtxt<'tcx> {
self.tcx
}

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

// We override `visit_expr` instead of the more specific expression
// visitors, so that we have direct access to the expression span.
fn visit_expr(&mut self, expr: &'hir hir::Expr<'hir>) {
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
match expr.kind {
hir::ExprKind::Closure(_) | hir::ExprKind::ConstBlock(_) => {
(self.visit_hole_span)(expr.span);
self.visit_hole_span(expr.span);
// Having visited this expression, we don't care about its
// children, so don't call `walk_expr`.
}
Expand All @@ -384,18 +386,17 @@ fn extract_hole_spans_from_hir<'tcx>(
}
}
}

let mut hole_spans = vec![];
let mut visitor = HolesVisitor {
tcx,
visit_hole_span: |hole_span| {
impl HolesVisitor<'_> {
fn visit_hole_span(&mut self, hole_span: Span) {
// Discard any holes that aren't directly visible within the body span.
if body_span.contains(hole_span) && body_span.eq_ctxt(hole_span) {
hole_spans.push(hole_span);
if self.body_span.contains(hole_span) && self.body_span.eq_ctxt(hole_span) {
self.hole_spans.push(hole_span);
}
},
};
}
}

let mut visitor = HolesVisitor { tcx, body_span, hole_spans: vec![] };

visitor.visit_body(hir_body);
hole_spans
visitor.hole_spans
}
16 changes: 10 additions & 6 deletions compiler/rustc_target/src/callconv/x86_win64.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use rustc_abi::{BackendRepr, Float, Integer, Primitive, RegKind, Size};

use crate::callconv::{ArgAbi, FnAbi, Reg};
use crate::spec::HasTargetSpec;
use crate::spec::{HasTargetSpec, RustcAbi};

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

pub(crate) fn compute_abi_info<Ty>(_cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>) {
pub(crate) fn compute_abi_info<Ty>(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>) {
let fixup = |a: &mut ArgAbi<'_, Ty>, is_ret: bool| {
match a.layout.backend_repr {
BackendRepr::Uninhabited | BackendRepr::Memory { sized: false } => {}
Expand All @@ -24,10 +24,14 @@ pub(crate) fn compute_abi_info<Ty>(_cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<
}
BackendRepr::Scalar(scalar) => {
if is_ret && matches!(scalar.primitive(), Primitive::Int(Integer::I128, _)) {
// `i128` is returned in xmm0 by Clang and GCC
// FIXME(#134288): This may change for the `-msvc` targets in the future.
let reg = Reg { kind: RegKind::Vector, size: Size::from_bits(128) };
a.cast_to(reg);
if cx.target_spec().rustc_abi == Some(RustcAbi::X86Softfloat) {
// Use the native `i128` LLVM type for the softfloat ABI -- in other words, adjust nothing.
} else {
// `i128` is returned in xmm0 by Clang and GCC
// FIXME(#134288): This may change for the `-msvc` targets in the future.
let reg = Reg { kind: RegKind::Vector, size: Size::from_bits(128) };
a.cast_to(reg);
}
} else if a.layout.size.bytes() > 8
&& !matches!(scalar.primitive(), Primitive::Float(Float::F128))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3289,6 +3289,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
let mut parent_trait_pred =
self.resolve_vars_if_possible(data.derived.parent_trait_pred);
let parent_def_id = parent_trait_pred.def_id();
if tcx.is_diagnostic_item(sym::FromResidual, parent_def_id)
&& !tcx.features().enabled(sym::try_trait_v2)
{
// If `#![feature(try_trait_v2)]` is not enabled, then there's no point on
// talking about `FromResidual<Result<A, B>>`, as the end user has nothing they
// can do about it. As far as they are concerned, `?` is compiler magic.
return;
}
let self_ty_str =
tcx.short_string(parent_trait_pred.skip_binder().self_ty(), err.long_ty_path());
let trait_name = parent_trait_pred.print_modifiers_and_trait_path().to_string();
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4796,7 +4796,7 @@ impl<T, const N: usize> [[T; N]] {
/// assert!(empty_slice_of_arrays.as_flattened().is_empty());
/// ```
#[stable(feature = "slice_flatten", since = "1.80.0")]
#[rustc_const_unstable(feature = "const_slice_flatten", issue = "95629")]
#[rustc_const_stable(feature = "const_slice_flatten", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_flattened(&self) -> &[T] {
let len = if T::IS_ZST {
self.len().checked_mul(N).expect("slice len overflow")
Expand Down Expand Up @@ -4833,7 +4833,7 @@ impl<T, const N: usize> [[T; N]] {
/// assert_eq!(array, [[6, 7, 8], [9, 10, 11], [12, 13, 14]]);
/// ```
#[stable(feature = "slice_flatten", since = "1.80.0")]
#[rustc_const_unstable(feature = "const_slice_flatten", issue = "95629")]
#[rustc_const_stable(feature = "const_slice_flatten", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_flattened_mut(&mut self) -> &mut [T] {
let len = if T::IS_ZST {
self.len().checked_mul(N).expect("slice len overflow")
Expand Down
16 changes: 6 additions & 10 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,6 @@ impl File {
/// # Examples
///
/// ```no_run
/// #![feature(file_lock)]
/// use std::fs::File;
///
/// fn main() -> std::io::Result<()> {
Expand All @@ -673,7 +672,7 @@ impl File {
/// Ok(())
/// }
/// ```
#[unstable(feature = "file_lock", issue = "130994")]
#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")]
pub fn lock(&self) -> io::Result<()> {
self.inner.lock()
}
Expand Down Expand Up @@ -717,7 +716,6 @@ impl File {
/// # Examples
///
/// ```no_run
/// #![feature(file_lock)]
/// use std::fs::File;
///
/// fn main() -> std::io::Result<()> {
Expand All @@ -726,7 +724,7 @@ impl File {
/// Ok(())
/// }
/// ```
#[unstable(feature = "file_lock", issue = "130994")]
#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")]
pub fn lock_shared(&self) -> io::Result<()> {
self.inner.lock_shared()
}
Expand Down Expand Up @@ -775,7 +773,6 @@ impl File {
/// # Examples
///
/// ```no_run
/// #![feature(file_lock)]
/// use std::fs::File;
///
/// fn main() -> std::io::Result<()> {
Expand All @@ -784,7 +781,7 @@ impl File {
/// Ok(())
/// }
/// ```
#[unstable(feature = "file_lock", issue = "130994")]
#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")]
pub fn try_lock(&self) -> io::Result<bool> {
self.inner.try_lock()
}
Expand Down Expand Up @@ -832,7 +829,6 @@ impl File {
/// # Examples
///
/// ```no_run
/// #![feature(file_lock)]
/// use std::fs::File;
///
/// fn main() -> std::io::Result<()> {
Expand All @@ -841,7 +837,7 @@ impl File {
/// Ok(())
/// }
/// ```
#[unstable(feature = "file_lock", issue = "130994")]
#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")]
pub fn try_lock_shared(&self) -> io::Result<bool> {
self.inner.try_lock_shared()
}
Expand Down Expand Up @@ -869,7 +865,6 @@ impl File {
/// # Examples
///
/// ```no_run
/// #![feature(file_lock)]
/// use std::fs::File;
///
/// fn main() -> std::io::Result<()> {
Expand All @@ -879,7 +874,7 @@ impl File {
/// Ok(())
/// }
/// ```
#[unstable(feature = "file_lock", issue = "130994")]
#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")]
pub fn unlock(&self) -> io::Result<()> {
self.inner.unlock()
}
Expand Down Expand Up @@ -2531,6 +2526,7 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()>
/// * `from` does not exist.
/// * The current process does not have the permission rights to read
/// `from` or write `to`.
/// * The parent directory of `to` doesn't exist.
///
/// # Examples
///
Expand Down
10 changes: 8 additions & 2 deletions library/std/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,17 @@ use crate::sys_common::{FromInner, IntoInner};
/// use std::time::{Instant, Duration};
///
/// let now = Instant::now();
/// let max_seconds = u64::MAX / 1_000_000_000;
/// let duration = Duration::new(max_seconds, 0);
/// let days_per_10_millennia = 365_2425;
/// let solar_seconds_per_day = 60 * 60 * 24;
/// let millenium_in_solar_seconds = 31_556_952_000;
/// assert_eq!(millenium_in_solar_seconds, days_per_10_millennia * solar_seconds_per_day / 10);
///
/// let duration = Duration::new(millenium_in_solar_seconds, 0);
/// println!("{:?}", now + duration);
/// ```
///
/// For cross-platform code, you can comfortably use durations of up to around one hundred years.
///
/// # Underlying System calls
///
/// The following system calls are [currently] being used by `now()` to find out
Expand Down
Loading
Loading