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 7 pull requests #129615

Merged
merged 23 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
803cbaf
Add f16 and f128 to tests/ui/consts/const-float-bits-conv.rs
rezwanahmedsami Aug 17, 2024
9f39427
Added #[cfg(target_arch = x86_64)] to f16 and f128
rezwanahmedsami Aug 18, 2024
9b5a004
feat(core): Add implementations for `unbounded_shl`/`unbounded_shr`
chorman0773 Aug 21, 2024
c89bae0
Manually format functions and use `rhs` instead of `v` from my CE tes…
chorman0773 Aug 21, 2024
38b5a2a
chore: Also format the control flow
chorman0773 Aug 21, 2024
79cbb87
chore: `x fmt` and hopefully fix the tidy issue
chorman0773 Aug 21, 2024
9907f61
fix(core): Add `#![feature(unbounded_shifts)]` to doctests for `unbou…
chorman0773 Aug 21, 2024
27b63b8
chore: `x fmt`
chorman0773 Aug 21, 2024
2cf48ea
fix(core): Use correct operations/values in `unbounded_shr` doctests
chorman0773 Aug 22, 2024
f4dc783
feat(core): Make `unbounded_shl{l,r}` unstably const and remove `rust…
chorman0773 Aug 22, 2024
3153b7d
link to Future::poll from the Poll docs
oconnor663 Aug 25, 2024
687c8a1
pal/hermit: correctly round up microseconds in `Thread::sleep`
mkroening Aug 25, 2024
edeefc5
pal/hermit: saturate `usleep` microseconds at `u64::MAX`
mkroening Aug 25, 2024
4f3ef2a
Remove cfg(test) from library/core
saethlin Aug 25, 2024
c31b9fa
mv `build_reduced_graph_for_external_crate_res` into Resolver
bvanjoi Aug 26, 2024
6982785
Tie `impl_trait_overcaptures` lint to Rust 2024
traviscross Aug 26, 2024
dedfb35
Rollup merge of #129190 - rezwanahmedsami:master, r=tgross35
matthiaskrgr Aug 26, 2024
68aff29
Rollup merge of #129377 - chorman0773:unbounded-shifts-impl, r=scottmcm
matthiaskrgr Aug 26, 2024
b1c9064
Rollup merge of #129539 - oconnor663:poll_link, r=tgross35
matthiaskrgr Aug 26, 2024
d0b3c3a
Rollup merge of #129588 - hermit-os:sleep-micros, r=workingjubilee
matthiaskrgr Aug 26, 2024
b9dfb4d
Rollup merge of #129592 - saethlin:core-cfg-test, r=tgross35
matthiaskrgr Aug 26, 2024
1d58ac0
Rollup merge of #129597 - bvanjoi:resolve, r=petrochenkov
matthiaskrgr Aug 26, 2024
114e60f
Rollup merge of #129600 - traviscross:TC/tie-impl_trait_overcaptures-…
matthiaskrgr Aug 26, 2024
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
10 changes: 6 additions & 4 deletions compiler/rustc_lint/src/impl_trait_overcaptures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
use rustc_middle::ty::{
self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
};
use rustc_session::lint::FutureIncompatibilityReason;
use rustc_session::{declare_lint, declare_lint_pass};
use rustc_span::edition::Edition;
use rustc_span::Span;

use crate::{fluent_generated as fluent, LateContext, LateLintPass};
Expand Down Expand Up @@ -54,10 +56,10 @@ declare_lint! {
pub IMPL_TRAIT_OVERCAPTURES,
Allow,
"`impl Trait` will capture more lifetimes than possibly intended in edition 2024",
//@future_incompatible = FutureIncompatibleInfo {
// reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024),
// reference: "<FIXME>",
//};
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024),
reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/rpit-lifetime-capture.html>",
};
}

declare_lint! {
Expand Down
139 changes: 71 additions & 68 deletions compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,77 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
pub(crate) fn build_reduced_graph_external(&mut self, module: Module<'a>) {
for child in self.tcx.module_children(module.def_id()) {
let parent_scope = ParentScope::module(module, self);
BuildReducedGraphVisitor { r: self, parent_scope }
.build_reduced_graph_for_external_crate_res(child);
self.build_reduced_graph_for_external_crate_res(child, parent_scope)
}
}

/// Builds the reduced graph for a single item in an external crate.
fn build_reduced_graph_for_external_crate_res(
&mut self,
child: &ModChild,
parent_scope: ParentScope<'a>,
) {
let parent = parent_scope.module;
let ModChild { ident, res, vis, ref reexport_chain } = *child;
let span = self.def_span(
reexport_chain
.first()
.and_then(|reexport| reexport.id())
.unwrap_or_else(|| res.def_id()),
);
let res = res.expect_non_local();
let expansion = parent_scope.expansion;
// Record primary definitions.
match res {
Res::Def(DefKind::Mod | DefKind::Enum | DefKind::Trait, def_id) => {
let module = self.expect_module(def_id);
self.define(parent, ident, TypeNS, (module, vis, span, expansion));
}
Res::Def(
DefKind::Struct
| DefKind::Union
| DefKind::Variant
| DefKind::TyAlias
| DefKind::ForeignTy
| DefKind::OpaqueTy
| DefKind::TraitAlias
| DefKind::AssocTy,
_,
)
| Res::PrimTy(..)
| Res::ToolMod => self.define(parent, ident, TypeNS, (res, vis, span, expansion)),
Res::Def(
DefKind::Fn
| DefKind::AssocFn
| DefKind::Static { .. }
| DefKind::Const
| DefKind::AssocConst
| DefKind::Ctor(..),
_,
) => self.define(parent, ident, ValueNS, (res, vis, span, expansion)),
Res::Def(DefKind::Macro(..), _) | Res::NonMacroAttr(..) => {
self.define(parent, ident, MacroNS, (res, vis, span, expansion))
}
Res::Def(
DefKind::TyParam
| DefKind::ConstParam
| DefKind::ExternCrate
| DefKind::Use
| DefKind::ForeignMod
| DefKind::AnonConst
| DefKind::InlineConst
| DefKind::Field
| DefKind::LifetimeParam
| DefKind::GlobalAsm
| DefKind::Closure
| DefKind::Impl { .. },
_,
)
| Res::Local(..)
| Res::SelfTyParam { .. }
| Res::SelfTyAlias { .. }
| Res::SelfCtor(..)
| Res::Err => bug!("unexpected resolution: {:?}", res),
}
}
}
Expand Down Expand Up @@ -967,72 +1036,6 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
}
}

/// Builds the reduced graph for a single item in an external crate.
fn build_reduced_graph_for_external_crate_res(&mut self, child: &ModChild) {
let parent = self.parent_scope.module;
let ModChild { ident, res, vis, ref reexport_chain } = *child;
let span = self.r.def_span(
reexport_chain
.first()
.and_then(|reexport| reexport.id())
.unwrap_or_else(|| res.def_id()),
);
let res = res.expect_non_local();
let expansion = self.parent_scope.expansion;
// Record primary definitions.
match res {
Res::Def(DefKind::Mod | DefKind::Enum | DefKind::Trait, def_id) => {
let module = self.r.expect_module(def_id);
self.r.define(parent, ident, TypeNS, (module, vis, span, expansion));
}
Res::Def(
DefKind::Struct
| DefKind::Union
| DefKind::Variant
| DefKind::TyAlias
| DefKind::ForeignTy
| DefKind::OpaqueTy
| DefKind::TraitAlias
| DefKind::AssocTy,
_,
)
| Res::PrimTy(..)
| Res::ToolMod => self.r.define(parent, ident, TypeNS, (res, vis, span, expansion)),
Res::Def(
DefKind::Fn
| DefKind::AssocFn
| DefKind::Static { .. }
| DefKind::Const
| DefKind::AssocConst
| DefKind::Ctor(..),
_,
) => self.r.define(parent, ident, ValueNS, (res, vis, span, expansion)),
Res::Def(DefKind::Macro(..), _) | Res::NonMacroAttr(..) => {
self.r.define(parent, ident, MacroNS, (res, vis, span, expansion))
}
Res::Def(
DefKind::TyParam
| DefKind::ConstParam
| DefKind::ExternCrate
| DefKind::Use
| DefKind::ForeignMod
| DefKind::AnonConst
| DefKind::InlineConst
| DefKind::Field
| DefKind::LifetimeParam
| DefKind::GlobalAsm
| DefKind::Closure
| DefKind::Impl { .. },
_,
)
| Res::Local(..)
| Res::SelfTyParam { .. }
| Res::SelfTyAlias { .. }
| Res::SelfCtor(..)
| Res::Err => bug!("unexpected resolution: {:?}", res),
}
}

fn add_macro_use_binding(
&mut self,
name: Symbol,
Expand Down
3 changes: 0 additions & 3 deletions library/core/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#![doc = include_str!("error.md")]
#![stable(feature = "error_in_core", since = "1.81.0")]

#[cfg(test)]
mod tests;

use crate::any::TypeId;
use crate::fmt::{Debug, Display, Formatter, Result};

Expand Down
62 changes: 62 additions & 0 deletions library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,34 @@ macro_rules! int_impl {
}
}

/// Unbounded shift left. Computes `self << rhs`, without bounding the value of `rhs`
///
/// If `rhs` is larger or equal to the number of bits in `self`,
/// the entire value is shifted out, and `0` is returned.
///
/// # Examples
///
/// Basic usage:
/// ```
/// #![feature(unbounded_shifts)]
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(4), 0x10);")]
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(129), 0);")]
/// ```
#[unstable(feature = "unbounded_shifts", issue = "129375")]
#[rustc_const_unstable(feature = "const_unbounded_shifts", issue = "129375")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub const fn unbounded_shl(self, rhs: u32) -> $SelfT{
if rhs < Self::BITS {
// SAFETY:
// rhs is just checked to be in-range above
unsafe { self.unchecked_shl(rhs) }
} else {
0
}
}

/// Checked shift right. Computes `self >> rhs`, returning `None` if `rhs` is
/// larger than or equal to the number of bits in `self`.
///
Expand Down Expand Up @@ -1410,6 +1438,40 @@ macro_rules! int_impl {
}
}

/// Unbounded shift right. Computes `self >> rhs`, without bounding the value of `rhs`
///
/// If `rhs` is larger or equal to the number of bits in `self`,
/// the entire value is shifted out, which yields `0` for a positive number,
/// and `-1` for a negative number.
///
/// # Examples
///
/// Basic usage:
/// ```
/// #![feature(unbounded_shifts)]
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(4), 0x1);")]
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(129), 0);")]
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.unbounded_shr(129), -1);")]
/// ```
#[unstable(feature = "unbounded_shifts", issue = "129375")]
#[rustc_const_unstable(feature = "const_unbounded_shifts", issue = "129375")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub const fn unbounded_shr(self, rhs: u32) -> $SelfT{
if rhs < Self::BITS {
// SAFETY:
// rhs is just checked to be in-range above
unsafe { self.unchecked_shr(rhs) }
} else {
// A shift by `Self::BITS-1` suffices for signed integers, because the sign bit is copied for each of the shifted bits.

// SAFETY:
// `Self::BITS-1` is guaranteed to be less than `Self::BITS`
unsafe { self.unchecked_shr(Self::BITS - 1) }
}
}

/// Checked absolute value. Computes `self.abs()`, returning `None` if
/// `self == MIN`.
///
Expand Down
56 changes: 56 additions & 0 deletions library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,34 @@ macro_rules! uint_impl {
}
}

/// Unbounded shift left. Computes `self << rhs`, without bounding the value of `rhs`
///
/// If `rhs` is larger or equal to the number of bits in `self`,
/// the entire value is shifted out, and `0` is returned.
///
/// # Examples
///
/// Basic usage:
/// ```
/// #![feature(unbounded_shifts)]
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(4), 0x10);")]
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(129), 0);")]
/// ```
#[unstable(feature = "unbounded_shifts", issue = "129375")]
#[rustc_const_unstable(feature = "const_unbounded_shifts", issue = "129375")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub const fn unbounded_shl(self, rhs: u32) -> $SelfT{
if rhs < Self::BITS {
// SAFETY:
// rhs is just checked to be in-range above
unsafe { self.unchecked_shl(rhs) }
} else {
0
}
}

/// Checked shift right. Computes `self >> rhs`, returning `None`
/// if `rhs` is larger than or equal to the number of bits in `self`.
///
Expand Down Expand Up @@ -1599,6 +1627,34 @@ macro_rules! uint_impl {
}
}

/// Unbounded shift right. Computes `self >> rhs`, without bounding the value of `rhs`
///
/// If `rhs` is larger or equal to the number of bits in `self`,
/// the entire value is shifted out, and `0` is returned.
///
/// # Examples
///
/// Basic usage:
/// ```
/// #![feature(unbounded_shifts)]
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(4), 0x1);")]
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(129), 0);")]
/// ```
#[unstable(feature = "unbounded_shifts", issue = "129375")]
#[rustc_const_unstable(feature = "const_unbounded_shifts", issue = "129375")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub const fn unbounded_shr(self, rhs: u32) -> $SelfT{
if rhs < Self::BITS {
// SAFETY:
// rhs is just checked to be in-range above
unsafe { self.unchecked_shr(rhs) }
} else {
0
}
}

/// Checked exponentiation. Computes `self.pow(exp)`, returning `None` if
/// overflow occurred.
///
Expand Down
2 changes: 2 additions & 0 deletions library/core/src/task/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use crate::ops::{self, ControlFlow};

/// Indicates whether a value is available or if the current task has been
/// scheduled to receive a wakeup instead.
///
/// This is returned by [`Future::poll`](core::future::Future::poll).
#[must_use = "this `Poll` may be a `Pending` variant, which should be handled"]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[lang = "Poll"]
Expand Down
1 change: 0 additions & 1 deletion library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ mod intrinsics;
mod io;
mod iter;
mod lazy;
#[cfg(test)]
mod macros;
mod manually_drop;
mod mem;
Expand Down
Loading
Loading