Skip to content

Commit 515395a

Browse files
committed
Auto merge of rust-lang#129615 - matthiaskrgr:rollup-lw733x7, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#129190 (Add f16 and f128 to tests/ui/consts/const-float-bits-conv.rs) - rust-lang#129377 (Add implementations for `unbounded_shl`/`unbounded_shr`) - rust-lang#129539 (link to Future::poll from the Poll docs) - rust-lang#129588 (pal/hermit: correctly round up microseconds in `Thread::sleep`) - rust-lang#129592 (Remove cfg(test) from library/core) - rust-lang#129597 (mv `build_reduced_graph_for_external_crate_res` into Resolver) - rust-lang#129600 (Tie `impl_trait_overcaptures` lint to Rust 2024) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 22572d0 + 114e60f commit 515395a

File tree

15 files changed

+941
-739
lines changed

15 files changed

+941
-739
lines changed

Diff for: compiler/rustc_lint/src/impl_trait_overcaptures.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
1010
use rustc_middle::ty::{
1111
self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
1212
};
13+
use rustc_session::lint::FutureIncompatibilityReason;
1314
use rustc_session::{declare_lint, declare_lint_pass};
15+
use rustc_span::edition::Edition;
1416
use rustc_span::Span;
1517

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

6365
declare_lint! {

Diff for: compiler/rustc_resolve/src/build_reduced_graph.rs

+71-68
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,77 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
197197
pub(crate) fn build_reduced_graph_external(&mut self, module: Module<'a>) {
198198
for child in self.tcx.module_children(module.def_id()) {
199199
let parent_scope = ParentScope::module(module, self);
200-
BuildReducedGraphVisitor { r: self, parent_scope }
201-
.build_reduced_graph_for_external_crate_res(child);
200+
self.build_reduced_graph_for_external_crate_res(child, parent_scope)
201+
}
202+
}
203+
204+
/// Builds the reduced graph for a single item in an external crate.
205+
fn build_reduced_graph_for_external_crate_res(
206+
&mut self,
207+
child: &ModChild,
208+
parent_scope: ParentScope<'a>,
209+
) {
210+
let parent = parent_scope.module;
211+
let ModChild { ident, res, vis, ref reexport_chain } = *child;
212+
let span = self.def_span(
213+
reexport_chain
214+
.first()
215+
.and_then(|reexport| reexport.id())
216+
.unwrap_or_else(|| res.def_id()),
217+
);
218+
let res = res.expect_non_local();
219+
let expansion = parent_scope.expansion;
220+
// Record primary definitions.
221+
match res {
222+
Res::Def(DefKind::Mod | DefKind::Enum | DefKind::Trait, def_id) => {
223+
let module = self.expect_module(def_id);
224+
self.define(parent, ident, TypeNS, (module, vis, span, expansion));
225+
}
226+
Res::Def(
227+
DefKind::Struct
228+
| DefKind::Union
229+
| DefKind::Variant
230+
| DefKind::TyAlias
231+
| DefKind::ForeignTy
232+
| DefKind::OpaqueTy
233+
| DefKind::TraitAlias
234+
| DefKind::AssocTy,
235+
_,
236+
)
237+
| Res::PrimTy(..)
238+
| Res::ToolMod => self.define(parent, ident, TypeNS, (res, vis, span, expansion)),
239+
Res::Def(
240+
DefKind::Fn
241+
| DefKind::AssocFn
242+
| DefKind::Static { .. }
243+
| DefKind::Const
244+
| DefKind::AssocConst
245+
| DefKind::Ctor(..),
246+
_,
247+
) => self.define(parent, ident, ValueNS, (res, vis, span, expansion)),
248+
Res::Def(DefKind::Macro(..), _) | Res::NonMacroAttr(..) => {
249+
self.define(parent, ident, MacroNS, (res, vis, span, expansion))
250+
}
251+
Res::Def(
252+
DefKind::TyParam
253+
| DefKind::ConstParam
254+
| DefKind::ExternCrate
255+
| DefKind::Use
256+
| DefKind::ForeignMod
257+
| DefKind::AnonConst
258+
| DefKind::InlineConst
259+
| DefKind::Field
260+
| DefKind::LifetimeParam
261+
| DefKind::GlobalAsm
262+
| DefKind::Closure
263+
| DefKind::Impl { .. },
264+
_,
265+
)
266+
| Res::Local(..)
267+
| Res::SelfTyParam { .. }
268+
| Res::SelfTyAlias { .. }
269+
| Res::SelfCtor(..)
270+
| Res::Err => bug!("unexpected resolution: {:?}", res),
202271
}
203272
}
204273
}
@@ -967,72 +1036,6 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
9671036
}
9681037
}
9691038

970-
/// Builds the reduced graph for a single item in an external crate.
971-
fn build_reduced_graph_for_external_crate_res(&mut self, child: &ModChild) {
972-
let parent = self.parent_scope.module;
973-
let ModChild { ident, res, vis, ref reexport_chain } = *child;
974-
let span = self.r.def_span(
975-
reexport_chain
976-
.first()
977-
.and_then(|reexport| reexport.id())
978-
.unwrap_or_else(|| res.def_id()),
979-
);
980-
let res = res.expect_non_local();
981-
let expansion = self.parent_scope.expansion;
982-
// Record primary definitions.
983-
match res {
984-
Res::Def(DefKind::Mod | DefKind::Enum | DefKind::Trait, def_id) => {
985-
let module = self.r.expect_module(def_id);
986-
self.r.define(parent, ident, TypeNS, (module, vis, span, expansion));
987-
}
988-
Res::Def(
989-
DefKind::Struct
990-
| DefKind::Union
991-
| DefKind::Variant
992-
| DefKind::TyAlias
993-
| DefKind::ForeignTy
994-
| DefKind::OpaqueTy
995-
| DefKind::TraitAlias
996-
| DefKind::AssocTy,
997-
_,
998-
)
999-
| Res::PrimTy(..)
1000-
| Res::ToolMod => self.r.define(parent, ident, TypeNS, (res, vis, span, expansion)),
1001-
Res::Def(
1002-
DefKind::Fn
1003-
| DefKind::AssocFn
1004-
| DefKind::Static { .. }
1005-
| DefKind::Const
1006-
| DefKind::AssocConst
1007-
| DefKind::Ctor(..),
1008-
_,
1009-
) => self.r.define(parent, ident, ValueNS, (res, vis, span, expansion)),
1010-
Res::Def(DefKind::Macro(..), _) | Res::NonMacroAttr(..) => {
1011-
self.r.define(parent, ident, MacroNS, (res, vis, span, expansion))
1012-
}
1013-
Res::Def(
1014-
DefKind::TyParam
1015-
| DefKind::ConstParam
1016-
| DefKind::ExternCrate
1017-
| DefKind::Use
1018-
| DefKind::ForeignMod
1019-
| DefKind::AnonConst
1020-
| DefKind::InlineConst
1021-
| DefKind::Field
1022-
| DefKind::LifetimeParam
1023-
| DefKind::GlobalAsm
1024-
| DefKind::Closure
1025-
| DefKind::Impl { .. },
1026-
_,
1027-
)
1028-
| Res::Local(..)
1029-
| Res::SelfTyParam { .. }
1030-
| Res::SelfTyAlias { .. }
1031-
| Res::SelfCtor(..)
1032-
| Res::Err => bug!("unexpected resolution: {:?}", res),
1033-
}
1034-
}
1035-
10361039
fn add_macro_use_binding(
10371040
&mut self,
10381041
name: Symbol,

Diff for: library/core/src/error.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#![doc = include_str!("error.md")]
22
#![stable(feature = "error_in_core", since = "1.81.0")]
33

4-
#[cfg(test)]
5-
mod tests;
6-
74
use crate::any::TypeId;
85
use crate::fmt::{Debug, Display, Formatter, Result};
96

Diff for: library/core/src/num/int_macros.rs

+62
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,34 @@ macro_rules! int_impl {
13121312
}
13131313
}
13141314

1315+
/// Unbounded shift left. Computes `self << rhs`, without bounding the value of `rhs`
1316+
///
1317+
/// If `rhs` is larger or equal to the number of bits in `self`,
1318+
/// the entire value is shifted out, and `0` is returned.
1319+
///
1320+
/// # Examples
1321+
///
1322+
/// Basic usage:
1323+
/// ```
1324+
/// #![feature(unbounded_shifts)]
1325+
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(4), 0x10);")]
1326+
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(129), 0);")]
1327+
/// ```
1328+
#[unstable(feature = "unbounded_shifts", issue = "129375")]
1329+
#[rustc_const_unstable(feature = "const_unbounded_shifts", issue = "129375")]
1330+
#[must_use = "this returns the result of the operation, \
1331+
without modifying the original"]
1332+
#[inline]
1333+
pub const fn unbounded_shl(self, rhs: u32) -> $SelfT{
1334+
if rhs < Self::BITS {
1335+
// SAFETY:
1336+
// rhs is just checked to be in-range above
1337+
unsafe { self.unchecked_shl(rhs) }
1338+
} else {
1339+
0
1340+
}
1341+
}
1342+
13151343
/// Checked shift right. Computes `self >> rhs`, returning `None` if `rhs` is
13161344
/// larger than or equal to the number of bits in `self`.
13171345
///
@@ -1410,6 +1438,40 @@ macro_rules! int_impl {
14101438
}
14111439
}
14121440

1441+
/// Unbounded shift right. Computes `self >> rhs`, without bounding the value of `rhs`
1442+
///
1443+
/// If `rhs` is larger or equal to the number of bits in `self`,
1444+
/// the entire value is shifted out, which yields `0` for a positive number,
1445+
/// and `-1` for a negative number.
1446+
///
1447+
/// # Examples
1448+
///
1449+
/// Basic usage:
1450+
/// ```
1451+
/// #![feature(unbounded_shifts)]
1452+
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(4), 0x1);")]
1453+
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(129), 0);")]
1454+
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.unbounded_shr(129), -1);")]
1455+
/// ```
1456+
#[unstable(feature = "unbounded_shifts", issue = "129375")]
1457+
#[rustc_const_unstable(feature = "const_unbounded_shifts", issue = "129375")]
1458+
#[must_use = "this returns the result of the operation, \
1459+
without modifying the original"]
1460+
#[inline]
1461+
pub const fn unbounded_shr(self, rhs: u32) -> $SelfT{
1462+
if rhs < Self::BITS {
1463+
// SAFETY:
1464+
// rhs is just checked to be in-range above
1465+
unsafe { self.unchecked_shr(rhs) }
1466+
} else {
1467+
// A shift by `Self::BITS-1` suffices for signed integers, because the sign bit is copied for each of the shifted bits.
1468+
1469+
// SAFETY:
1470+
// `Self::BITS-1` is guaranteed to be less than `Self::BITS`
1471+
unsafe { self.unchecked_shr(Self::BITS - 1) }
1472+
}
1473+
}
1474+
14131475
/// Checked absolute value. Computes `self.abs()`, returning `None` if
14141476
/// `self == MIN`.
14151477
///

Diff for: library/core/src/num/uint_macros.rs

+56
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,34 @@ macro_rules! uint_impl {
15011501
}
15021502
}
15031503

1504+
/// Unbounded shift left. Computes `self << rhs`, without bounding the value of `rhs`
1505+
///
1506+
/// If `rhs` is larger or equal to the number of bits in `self`,
1507+
/// the entire value is shifted out, and `0` is returned.
1508+
///
1509+
/// # Examples
1510+
///
1511+
/// Basic usage:
1512+
/// ```
1513+
/// #![feature(unbounded_shifts)]
1514+
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(4), 0x10);")]
1515+
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(129), 0);")]
1516+
/// ```
1517+
#[unstable(feature = "unbounded_shifts", issue = "129375")]
1518+
#[rustc_const_unstable(feature = "const_unbounded_shifts", issue = "129375")]
1519+
#[must_use = "this returns the result of the operation, \
1520+
without modifying the original"]
1521+
#[inline]
1522+
pub const fn unbounded_shl(self, rhs: u32) -> $SelfT{
1523+
if rhs < Self::BITS {
1524+
// SAFETY:
1525+
// rhs is just checked to be in-range above
1526+
unsafe { self.unchecked_shl(rhs) }
1527+
} else {
1528+
0
1529+
}
1530+
}
1531+
15041532
/// Checked shift right. Computes `self >> rhs`, returning `None`
15051533
/// if `rhs` is larger than or equal to the number of bits in `self`.
15061534
///
@@ -1599,6 +1627,34 @@ macro_rules! uint_impl {
15991627
}
16001628
}
16011629

1630+
/// Unbounded shift right. Computes `self >> rhs`, without bounding the value of `rhs`
1631+
///
1632+
/// If `rhs` is larger or equal to the number of bits in `self`,
1633+
/// the entire value is shifted out, and `0` is returned.
1634+
///
1635+
/// # Examples
1636+
///
1637+
/// Basic usage:
1638+
/// ```
1639+
/// #![feature(unbounded_shifts)]
1640+
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(4), 0x1);")]
1641+
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(129), 0);")]
1642+
/// ```
1643+
#[unstable(feature = "unbounded_shifts", issue = "129375")]
1644+
#[rustc_const_unstable(feature = "const_unbounded_shifts", issue = "129375")]
1645+
#[must_use = "this returns the result of the operation, \
1646+
without modifying the original"]
1647+
#[inline]
1648+
pub const fn unbounded_shr(self, rhs: u32) -> $SelfT{
1649+
if rhs < Self::BITS {
1650+
// SAFETY:
1651+
// rhs is just checked to be in-range above
1652+
unsafe { self.unchecked_shr(rhs) }
1653+
} else {
1654+
0
1655+
}
1656+
}
1657+
16021658
/// Checked exponentiation. Computes `self.pow(exp)`, returning `None` if
16031659
/// overflow occurred.
16041660
///

Diff for: library/core/src/task/poll.rs

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use crate::ops::{self, ControlFlow};
55

66
/// Indicates whether a value is available or if the current task has been
77
/// scheduled to receive a wakeup instead.
8+
///
9+
/// This is returned by [`Future::poll`](core::future::Future::poll).
810
#[must_use = "this `Poll` may be a `Pending` variant, which should be handled"]
911
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
1012
#[lang = "Poll"]

Diff for: library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ mod intrinsics;
141141
mod io;
142142
mod iter;
143143
mod lazy;
144-
#[cfg(test)]
145144
mod macros;
146145
mod manually_drop;
147146
mod mem;

0 commit comments

Comments
 (0)