Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 515395a

Browse files
committedAug 26, 2024·
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
 

‎compiler/rustc_lint/src/impl_trait_overcaptures.rs

Lines changed: 6 additions & 4 deletions
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! {

‎compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 71 additions & 68 deletions
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,

‎library/core/src/error.rs

Lines changed: 0 additions & 3 deletions
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

‎library/core/src/num/int_macros.rs

Lines changed: 62 additions & 0 deletions
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
///

‎library/core/src/num/uint_macros.rs

Lines changed: 56 additions & 0 deletions
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
///

‎library/core/src/task/poll.rs

Lines changed: 2 additions & 0 deletions
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"]

‎library/core/tests/lib.rs

Lines changed: 0 additions & 1 deletion
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;

‎library/core/tests/num/int_macros.rs

Lines changed: 378 additions & 381 deletions
Large diffs are not rendered by default.

‎library/core/tests/num/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ fn test_can_not_overflow() {
178178

179179
// Check u128 separately:
180180
for base in 2..=36 {
181-
let num = u128::MAX as u128;
181+
let num = <u128>::MAX;
182182
let max_len_string = format_radix(num, base as u128);
183183
// base 16 fits perfectly for u128 and won't overflow:
184184
assert_eq!(can_overflow::<u128>(base, &max_len_string), base != 16);

‎library/core/tests/num/uint_macros.rs

Lines changed: 270 additions & 273 deletions
Large diffs are not rendered by default.

‎library/std/src/sys/pal/hermit/thread.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ impl Thread {
7777

7878
#[inline]
7979
pub fn sleep(dur: Duration) {
80+
let micros = dur.as_micros() + if dur.subsec_nanos() % 1_000 > 0 { 1 } else { 0 };
81+
let micros = u64::try_from(micros).unwrap_or(u64::MAX);
82+
8083
unsafe {
81-
hermit_abi::usleep(dur.as_micros() as u64);
84+
hermit_abi::usleep(micros);
8285
}
8386
}
8487

‎tests/ui/consts/const-float-bits-conv.rs

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
#![feature(const_float_bits_conv)]
55
#![feature(const_float_classify)]
6+
#![feature(f16)]
7+
#![feature(f128)]
68
#![allow(unused_macro_rules)]
7-
89
// Don't promote
910
const fn nop<T>(x: T) -> T { x }
1011

@@ -28,6 +29,37 @@ fn has_broken_floats() -> bool {
2829
std::env::var("TARGET").is_ok_and(|v| v.contains("i586"))
2930
}
3031

32+
#[cfg(target_arch = "x86_64")]
33+
fn f16(){
34+
const_assert!((1f16).to_bits(), 0x3c00);
35+
const_assert!(u16::from_be_bytes(1f16.to_be_bytes()), 0x3c00);
36+
const_assert!((12.5f16).to_bits(), 0x4a40);
37+
const_assert!(u16::from_le_bytes(12.5f16.to_le_bytes()), 0x4a40);
38+
const_assert!((1337f16).to_bits(), 0x6539);
39+
const_assert!(u16::from_ne_bytes(1337f16.to_ne_bytes()), 0x6539);
40+
const_assert!((-14.25f16).to_bits(), 0xcb20);
41+
const_assert!(f16::from_bits(0x3c00), 1.0);
42+
const_assert!(f16::from_be_bytes(0x3c00u16.to_be_bytes()), 1.0);
43+
const_assert!(f16::from_bits(0x4a40), 12.5);
44+
const_assert!(f16::from_le_bytes(0x4a40u16.to_le_bytes()), 12.5);
45+
const_assert!(f16::from_bits(0x5be0), 252.0);
46+
const_assert!(f16::from_ne_bytes(0x5be0u16.to_ne_bytes()), 252.0);
47+
const_assert!(f16::from_bits(0xcb20), -14.25);
48+
49+
// Check that NaNs roundtrip their bits regardless of signalingness
50+
// 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits
51+
// NOTE: These names assume `f{BITS}::NAN` is a quiet NAN and IEEE754-2008's NaN rules apply!
52+
const QUIET_NAN: u16 = f16::NAN.to_bits() ^ 0x0155;
53+
const SIGNALING_NAN: u16 = f16::NAN.to_bits() ^ 0x02AA;
54+
55+
const_assert!(f16::from_bits(QUIET_NAN).is_nan());
56+
const_assert!(f16::from_bits(SIGNALING_NAN).is_nan());
57+
const_assert!(f16::from_bits(QUIET_NAN).to_bits(), QUIET_NAN);
58+
if !has_broken_floats() {
59+
const_assert!(f16::from_bits(SIGNALING_NAN).to_bits(), SIGNALING_NAN);
60+
}
61+
}
62+
3163
fn f32() {
3264
const_assert!((1f32).to_bits(), 0x3f800000);
3365
const_assert!(u32::from_be_bytes(1f32.to_be_bytes()), 0x3f800000);
@@ -88,7 +120,43 @@ fn f64() {
88120
}
89121
}
90122

123+
#[cfg(target_arch = "x86_64")]
124+
fn f128() {
125+
const_assert!((1f128).to_bits(), 0x3fff0000000000000000000000000000);
126+
const_assert!(u128::from_be_bytes(1f128.to_be_bytes()), 0x3fff0000000000000000000000000000);
127+
const_assert!((12.5f128).to_bits(), 0x40029000000000000000000000000000);
128+
const_assert!(u128::from_le_bytes(12.5f128.to_le_bytes()), 0x40029000000000000000000000000000);
129+
const_assert!((1337f128).to_bits(), 0x40094e40000000000000000000000000);
130+
const_assert!(u128::from_ne_bytes(1337f128.to_ne_bytes()), 0x40094e40000000000000000000000000);
131+
const_assert!((-14.25f128).to_bits(), 0xc002c800000000000000000000000000);
132+
const_assert!(f128::from_bits(0x3fff0000000000000000000000000000), 1.0);
133+
const_assert!(f128::from_be_bytes(0x3fff0000000000000000000000000000u128.to_be_bytes()), 1.0);
134+
const_assert!(f128::from_bits(0x40029000000000000000000000000000), 12.5);
135+
const_assert!(f128::from_le_bytes(0x40029000000000000000000000000000u128.to_le_bytes()), 12.5);
136+
const_assert!(f128::from_bits(0x40094e40000000000000000000000000), 1337.0);
137+
assert_eq!(f128::from_ne_bytes(0x40094e40000000000000000000000000u128.to_ne_bytes()), 1337.0);
138+
const_assert!(f128::from_bits(0xc002c800000000000000000000000000), -14.25);
139+
140+
// Check that NaNs roundtrip their bits regardless of signalingness
141+
// 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits
142+
// NOTE: These names assume `f{BITS}::NAN` is a quiet NAN and IEEE754-2008's NaN rules apply!
143+
const QUIET_NAN: u128 = f128::NAN.to_bits() | 0x0000_AAAA_AAAA_AAAA_AAAA_AAAA_AAAA_AAAA;
144+
const SIGNALING_NAN: u128 = f128::NAN.to_bits() ^ 0x0000_5555_5555_5555_5555_5555_5555_5555;
145+
146+
const_assert!(f128::from_bits(QUIET_NAN).is_nan());
147+
const_assert!(f128::from_bits(SIGNALING_NAN).is_nan());
148+
const_assert!(f128::from_bits(QUIET_NAN).to_bits(), QUIET_NAN);
149+
if !has_broken_floats() {
150+
const_assert!(f128::from_bits(SIGNALING_NAN).to_bits(), SIGNALING_NAN);
151+
}
152+
}
153+
91154
fn main() {
155+
#[cfg(target_arch = "x86_64")]
156+
{
157+
f16();
158+
f128();
159+
}
92160
f32();
93161
f64();
94162
}

‎tests/ui/impl-trait/precise-capturing/overcaptures-2024.fixed

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55

66
fn named<'a>(x: &'a i32) -> impl Sized + use<> { *x }
77
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
8+
//~| WARN this changes meaning in Rust 2024
89

910
fn implicit(x: &i32) -> impl Sized + use<> { *x }
1011
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
12+
//~| WARN this changes meaning in Rust 2024
1113

1214
struct W;
1315
impl W {
1416
fn hello(&self, x: &i32) -> impl Sized + '_ + use<'_> { self }
1517
//~^ ERROR `impl Sized + '_` will capture more lifetimes than possibly intended in edition 2024
18+
//~| WARN this changes meaning in Rust 2024
1619
}
1720

1821
trait Higher<'a> {
@@ -24,5 +27,6 @@ impl Higher<'_> for () {
2427

2528
fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized + use<>> {}
2629
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
30+
//~| WARN this changes meaning in Rust 2024
2731

2832
fn main() {}

‎tests/ui/impl-trait/precise-capturing/overcaptures-2024.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55

66
fn named<'a>(x: &'a i32) -> impl Sized { *x }
77
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
8+
//~| WARN this changes meaning in Rust 2024
89

910
fn implicit(x: &i32) -> impl Sized { *x }
1011
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
12+
//~| WARN this changes meaning in Rust 2024
1113

1214
struct W;
1315
impl W {
1416
fn hello(&self, x: &i32) -> impl Sized + '_ { self }
1517
//~^ ERROR `impl Sized + '_` will capture more lifetimes than possibly intended in edition 2024
18+
//~| WARN this changes meaning in Rust 2024
1619
}
1720

1821
trait Higher<'a> {
@@ -24,5 +27,6 @@ impl Higher<'_> for () {
2427

2528
fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized> {}
2629
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024
30+
//~| WARN this changes meaning in Rust 2024
2731

2832
fn main() {}

‎tests/ui/impl-trait/precise-capturing/overcaptures-2024.stderr

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ error: `impl Sized` will capture more lifetimes than possibly intended in editio
44
LL | fn named<'a>(x: &'a i32) -> impl Sized { *x }
55
| ^^^^^^^^^^
66
|
7+
= warning: this changes meaning in Rust 2024
8+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/rpit-lifetime-capture.html>
79
note: specifically, this lifetime is in scope but not mentioned in the type's bounds
810
--> $DIR/overcaptures-2024.rs:6:10
911
|
@@ -21,13 +23,15 @@ LL | fn named<'a>(x: &'a i32) -> impl Sized + use<> { *x }
2123
| +++++++
2224

2325
error: `impl Sized` will capture more lifetimes than possibly intended in edition 2024
24-
--> $DIR/overcaptures-2024.rs:9:25
26+
--> $DIR/overcaptures-2024.rs:10:25
2527
|
2628
LL | fn implicit(x: &i32) -> impl Sized { *x }
2729
| ^^^^^^^^^^
2830
|
31+
= warning: this changes meaning in Rust 2024
32+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/rpit-lifetime-capture.html>
2933
note: specifically, this lifetime is in scope but not mentioned in the type's bounds
30-
--> $DIR/overcaptures-2024.rs:9:16
34+
--> $DIR/overcaptures-2024.rs:10:16
3135
|
3236
LL | fn implicit(x: &i32) -> impl Sized { *x }
3337
| ^
@@ -38,13 +42,15 @@ LL | fn implicit(x: &i32) -> impl Sized + use<> { *x }
3842
| +++++++
3943

4044
error: `impl Sized + '_` will capture more lifetimes than possibly intended in edition 2024
41-
--> $DIR/overcaptures-2024.rs:14:33
45+
--> $DIR/overcaptures-2024.rs:16:33
4246
|
4347
LL | fn hello(&self, x: &i32) -> impl Sized + '_ { self }
4448
| ^^^^^^^^^^^^^^^
4549
|
50+
= warning: this changes meaning in Rust 2024
51+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/rpit-lifetime-capture.html>
4652
note: specifically, this lifetime is in scope but not mentioned in the type's bounds
47-
--> $DIR/overcaptures-2024.rs:14:24
53+
--> $DIR/overcaptures-2024.rs:16:24
4854
|
4955
LL | fn hello(&self, x: &i32) -> impl Sized + '_ { self }
5056
| ^
@@ -55,13 +61,15 @@ LL | fn hello(&self, x: &i32) -> impl Sized + '_ + use<'_> { self }
5561
| +++++++++
5662

5763
error: `impl Sized` will capture more lifetimes than possibly intended in edition 2024
58-
--> $DIR/overcaptures-2024.rs:25:47
64+
--> $DIR/overcaptures-2024.rs:28:47
5965
|
6066
LL | fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized> {}
6167
| ^^^^^^^^^^
6268
|
69+
= warning: this changes meaning in Rust 2024
70+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/rpit-lifetime-capture.html>
6371
note: specifically, this lifetime is in scope but not mentioned in the type's bounds
64-
--> $DIR/overcaptures-2024.rs:25:23
72+
--> $DIR/overcaptures-2024.rs:28:23
6573
|
6674
LL | fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized> {}
6775
| ^^

0 commit comments

Comments
 (0)
This repository has been archived.