Skip to content

Commit 2616ab1

Browse files
committed
Auto merge of #83811 - JohnTitor:rollup-hnw1xwz, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #82487 (Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6`) - #83756 (rustdoc: Rename internal uses of `spotlight`) - #83780 (Document "standard" conventions for error messages) - #83787 (Monomorphization doc fix) - #83803 (add fp-armv8 for ARM_ALLOWED_FEATURES) - #83804 (Remove nightly features in rustc_type_ir) - #83810 (Fix rustc_lint_defs documentation typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0b417ab + b2daca7 commit 2616ab1

File tree

15 files changed

+71
-52
lines changed

15 files changed

+71
-52
lines changed

compiler/rustc_codegen_ssa/src/target_features.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const ARM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
2626
("vfp2", Some(sym::arm_target_feature)),
2727
("vfp3", Some(sym::arm_target_feature)),
2828
("vfp4", Some(sym::arm_target_feature)),
29+
("fp-armv8", Some(sym::arm_target_feature)),
2930
// This is needed for inline assembly, but shouldn't be stabilized as-is
3031
// since it should be enabled per-function using #[instruction_set], not
3132
// #[target_feature].

compiler/rustc_index/src/vec.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,17 @@ macro_rules! newtype_index {
124124

125125
#[inline]
126126
$v const fn from_usize(value: usize) -> Self {
127-
assert!(value <= ($max as usize));
127+
// FIXME: replace with `assert!(value <= ($max as usize));` once `const_panic` is stable
128+
[()][(value > ($max as usize)) as usize];
128129
unsafe {
129130
Self::from_u32_unchecked(value as u32)
130131
}
131132
}
132133

133134
#[inline]
134135
$v const fn from_u32(value: u32) -> Self {
135-
assert!(value <= $max);
136+
// FIXME: replace with `assert!(value <= $max);` once `const_panic` is stable
137+
[()][(value > $max) as usize];
136138
unsafe {
137139
Self::from_u32_unchecked(value)
138140
}

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ declare_lint! {
547547
/// Also consider if you intended to use an _inner attribute_ (with a `!`
548548
/// such as `#![allow(unused)]`) which applies to the item the attribute
549549
/// is within, or an _outer attribute_ (without a `!` such as
550-
/// `#[allow(unsued)]`) which applies to the item *following* the
550+
/// `#[allow(unused)]`) which applies to the item *following* the
551551
/// attribute.
552552
///
553553
/// [attributes]: https://doc.rust-lang.org/reference/attributes.html

compiler/rustc_mir/src/monomorphize/collector.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,15 @@
5959
//!
6060
//! ### Discovering roots
6161
//!
62-
//! The roots of the mono item graph correspond to the non-generic
62+
//! The roots of the mono item graph correspond to the public non-generic
6363
//! syntactic items in the source code. We find them by walking the HIR of the
64-
//! crate, and whenever we hit upon a function, method, or static item, we
65-
//! create a mono item consisting of the items DefId and, since we only
66-
//! consider non-generic items, an empty type-substitution set.
64+
//! crate, and whenever we hit upon a public function, method, or static item,
65+
//! we create a mono item consisting of the items DefId and, since we only
66+
//! consider non-generic items, an empty type-substitution set. (In eager
67+
//! collection mode, during incremental compilation, all non-generic functions
68+
//! are considered as roots, as well as when the `-Clink-dead-code` option is
69+
//! specified. Functions marked `#[no_mangle]` and functions called by inlinable
70+
//! functions also always act as roots.)
6771
//!
6872
//! ### Finding neighbor nodes
6973
//! Given a mono item node, we can discover neighbors by inspecting its

compiler/rustc_type_ir/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
#![feature(never_type)]
2-
#![feature(const_panic)]
3-
#![feature(control_flow_enum)]
4-
51
#[macro_use]
62
extern crate bitflags;
73
#[macro_use]

library/std/src/error.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,22 @@ use crate::string;
3333
use crate::sync::Arc;
3434

3535
/// `Error` is a trait representing the basic expectations for error values,
36-
/// i.e., values of type `E` in [`Result<T, E>`]. Errors must describe
37-
/// themselves through the [`Display`] and [`Debug`] traits, and may provide
38-
/// cause chain information:
36+
/// i.e., values of type `E` in [`Result<T, E>`].
3937
///
40-
/// [`Error::source()`] is generally used when errors cross
41-
/// "abstraction boundaries". If one module must report an error that is caused
42-
/// by an error from a lower-level module, it can allow accessing that error
43-
/// via [`Error::source()`]. This makes it possible for the high-level
44-
/// module to provide its own errors while also revealing some of the
38+
/// Errors must describe themselves through the [`Display`] and [`Debug`]
39+
/// traits. Error messages are typically concise lowercase sentences without
40+
/// trailing punctuation:
41+
///
42+
/// ```
43+
/// let err = "NaN".parse::<u32>().unwrap_err();
44+
/// assert_eq!(err.to_string(), "invalid digit found in string");
45+
/// ```
46+
///
47+
/// Errors may provide cause chain information. [`Error::source()`] is generally
48+
/// used when errors cross "abstraction boundaries". If one module must report
49+
/// an error that is caused by an error from a lower-level module, it can allow
50+
/// accessing that error via [`Error::source()`]. This makes it possible for the
51+
/// high-level module to provide its own errors while also revealing some of the
4552
/// implementation for debugging via `source` chains.
4653
#[stable(feature = "rust1", since = "1.0.0")]
4754
pub trait Error: Debug + Display {

library/std/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249
#![feature(const_ip)]
250250
#![feature(const_ipv6)]
251251
#![feature(const_raw_ptr_deref)]
252+
#![feature(const_socketaddr)]
252253
#![feature(const_ipv4)]
253254
#![feature(container_error_extra)]
254255
#![feature(core_intrinsics)]

library/std/src/net/addr.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ impl SocketAddr {
149149
/// assert_eq!(socket.ip(), IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
150150
/// ```
151151
#[stable(feature = "ip_addr", since = "1.7.0")]
152-
pub fn ip(&self) -> IpAddr {
152+
#[rustc_const_unstable(feature = "const_socketaddr", issue = "82485")]
153+
pub const fn ip(&self) -> IpAddr {
153154
match *self {
154155
SocketAddr::V4(ref a) => IpAddr::V4(*a.ip()),
155156
SocketAddr::V6(ref a) => IpAddr::V6(*a.ip()),
@@ -188,7 +189,8 @@ impl SocketAddr {
188189
/// assert_eq!(socket.port(), 8080);
189190
/// ```
190191
#[stable(feature = "rust1", since = "1.0.0")]
191-
pub fn port(&self) -> u16 {
192+
#[rustc_const_unstable(feature = "const_socketaddr", issue = "82485")]
193+
pub const fn port(&self) -> u16 {
192194
match *self {
193195
SocketAddr::V4(ref a) => a.port(),
194196
SocketAddr::V6(ref a) => a.port(),
@@ -230,7 +232,8 @@ impl SocketAddr {
230232
/// assert_eq!(socket.is_ipv6(), false);
231233
/// ```
232234
#[stable(feature = "sockaddr_checker", since = "1.16.0")]
233-
pub fn is_ipv4(&self) -> bool {
235+
#[rustc_const_unstable(feature = "const_socketaddr", issue = "82485")]
236+
pub const fn is_ipv4(&self) -> bool {
234237
matches!(*self, SocketAddr::V4(_))
235238
}
236239

@@ -250,7 +253,8 @@ impl SocketAddr {
250253
/// assert_eq!(socket.is_ipv6(), true);
251254
/// ```
252255
#[stable(feature = "sockaddr_checker", since = "1.16.0")]
253-
pub fn is_ipv6(&self) -> bool {
256+
#[rustc_const_unstable(feature = "const_socketaddr", issue = "82485")]
257+
pub const fn is_ipv6(&self) -> bool {
254258
matches!(*self, SocketAddr::V6(_))
255259
}
256260
}
@@ -290,7 +294,8 @@ impl SocketAddrV4 {
290294
/// assert_eq!(socket.ip(), &Ipv4Addr::new(127, 0, 0, 1));
291295
/// ```
292296
#[stable(feature = "rust1", since = "1.0.0")]
293-
pub fn ip(&self) -> &Ipv4Addr {
297+
#[rustc_const_unstable(feature = "const_socketaddr", issue = "82485")]
298+
pub const fn ip(&self) -> &Ipv4Addr {
294299
// SAFETY: `Ipv4Addr` is `#[repr(C)] struct { _: in_addr; }`.
295300
// It is safe to cast from `&in_addr` to `&Ipv4Addr`.
296301
unsafe { &*(&self.inner.sin_addr as *const c::in_addr as *const Ipv4Addr) }
@@ -323,7 +328,8 @@ impl SocketAddrV4 {
323328
/// assert_eq!(socket.port(), 8080);
324329
/// ```
325330
#[stable(feature = "rust1", since = "1.0.0")]
326-
pub fn port(&self) -> u16 {
331+
#[rustc_const_unstable(feature = "const_socketaddr", issue = "82485")]
332+
pub const fn port(&self) -> u16 {
327333
ntohs(self.inner.sin_port)
328334
}
329335

@@ -386,7 +392,8 @@ impl SocketAddrV6 {
386392
/// assert_eq!(socket.ip(), &Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
387393
/// ```
388394
#[stable(feature = "rust1", since = "1.0.0")]
389-
pub fn ip(&self) -> &Ipv6Addr {
395+
#[rustc_const_unstable(feature = "const_socketaddr", issue = "82485")]
396+
pub const fn ip(&self) -> &Ipv6Addr {
390397
unsafe { &*(&self.inner.sin6_addr as *const c::in6_addr as *const Ipv6Addr) }
391398
}
392399

@@ -417,7 +424,8 @@ impl SocketAddrV6 {
417424
/// assert_eq!(socket.port(), 8080);
418425
/// ```
419426
#[stable(feature = "rust1", since = "1.0.0")]
420-
pub fn port(&self) -> u16 {
427+
#[rustc_const_unstable(feature = "const_socketaddr", issue = "82485")]
428+
pub const fn port(&self) -> u16 {
421429
ntohs(self.inner.sin6_port)
422430
}
423431

@@ -458,7 +466,8 @@ impl SocketAddrV6 {
458466
/// assert_eq!(socket.flowinfo(), 10);
459467
/// ```
460468
#[stable(feature = "rust1", since = "1.0.0")]
461-
pub fn flowinfo(&self) -> u32 {
469+
#[rustc_const_unstable(feature = "const_socketaddr", issue = "82485")]
470+
pub const fn flowinfo(&self) -> u32 {
462471
self.inner.sin6_flowinfo
463472
}
464473

@@ -496,7 +505,8 @@ impl SocketAddrV6 {
496505
/// assert_eq!(socket.scope_id(), 78);
497506
/// ```
498507
#[stable(feature = "rust1", since = "1.0.0")]
499-
pub fn scope_id(&self) -> u32 {
508+
#[rustc_const_unstable(feature = "const_socketaddr", issue = "82485")]
509+
pub const fn scope_id(&self) -> u32 {
500510
self.inner.sin6_scope_id
501511
}
502512

src/librustdoc/clean/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ crate fn record_extern_trait(cx: &mut DocContext<'_>, did: DefId) {
624624

625625
let trait_ = clean::TraitWithExtraInfo {
626626
trait_,
627-
is_spotlight: clean::utils::has_doc_flag(cx.tcx.get_attrs(did), sym::notable_trait),
627+
is_notable: clean::utils::has_doc_flag(cx.tcx.get_attrs(did), sym::notable_trait),
628628
};
629629
cx.external_traits.borrow_mut().insert(did, trait_);
630630
cx.active_extern_traits.remove(&did);

src/librustdoc/clean/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ crate struct Crate {
6565
#[derive(Clone, Debug)]
6666
crate struct TraitWithExtraInfo {
6767
crate trait_: Trait,
68-
crate is_spotlight: bool,
68+
crate is_notable: bool,
6969
}
7070

7171
#[derive(Clone, Debug)]

0 commit comments

Comments
 (0)