Skip to content

Commit 33e2813

Browse files
committed
Auto merge of #141561 - jhpratt:rollup-1yjbnkh, r=jhpratt
Rollup of 9 pull requests Successful merges: - #134696 (Implement `normalize_lexically`) - #138744 (Add methods to TCP and UDP sockets to modify hop limit (refresh of #94678)) - #140539 (Simplify `attribute_groups`) - #140863 ([rustdoc] Unify type aliases rendering with other ADT) - #140936 (Clarify WTF-8 safety docs) - #140952 (Specify that split_ascii_whitespace uses the same definition as is_ascii_whitespace) - #141472 (Attempt to improve the `std::fs::create_dir_all` docs related to atomicity) - #141502 (ci: move PR job x86_64-gnu-tools to codebuild) - #141559 (const-check: stop recommending the use of rustc_allow_const_fn_unstable) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9f8929f + 8fcd1a7 commit 33e2813

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+997
-524
lines changed

compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::session_diagnostics;
1010

1111
pub(crate) struct AllowInternalUnstableParser;
1212
impl CombineAttributeParser for AllowInternalUnstableParser {
13-
const PATH: &'static [rustc_span::Symbol] = &[sym::allow_internal_unstable];
13+
const PATH: &'static [Symbol] = &[sym::allow_internal_unstable];
1414
type Item = (Symbol, Span);
1515
const CONVERT: ConvertFn<Self::Item> = AttributeKind::AllowInternalUnstable;
1616

@@ -24,7 +24,7 @@ impl CombineAttributeParser for AllowInternalUnstableParser {
2424

2525
pub(crate) struct AllowConstFnUnstableParser;
2626
impl CombineAttributeParser for AllowConstFnUnstableParser {
27-
const PATH: &'static [rustc_span::Symbol] = &[sym::rustc_allow_const_fn_unstable];
27+
const PATH: &'static [Symbol] = &[sym::rustc_allow_const_fn_unstable];
2828
type Item = Symbol;
2929
const CONVERT: ConvertFn<Self::Item> = AttributeKind::AllowConstFnUnstable;
3030

compiler/rustc_attr_parsing/src/attributes/deprecation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ fn get(
4242
}
4343

4444
impl SingleAttributeParser for DeprecationParser {
45-
const PATH: &'static [rustc_span::Symbol] = &[sym::deprecated];
45+
const PATH: &'static [Symbol] = &[sym::deprecated];
4646

47-
fn on_duplicate(cx: &AcceptContext<'_>, first_span: rustc_span::Span) {
47+
fn on_duplicate(cx: &AcceptContext<'_>, first_span: Span) {
4848
// FIXME(jdonszelmann): merge with errors from check_attrs.rs
4949
cx.emit_err(session_diagnostics::UnusedMultiple {
5050
this: cx.attr_span,

compiler/rustc_attr_parsing/src/attributes/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use std::marker::PhantomData;
1818

1919
use rustc_attr_data_structures::AttributeKind;
20-
use rustc_span::Span;
20+
use rustc_span::{Span, Symbol};
2121
use thin_vec::ThinVec;
2222

2323
use crate::context::{AcceptContext, FinalizeContext};
@@ -33,7 +33,7 @@ pub(crate) mod transparency;
3333
pub(crate) mod util;
3434

3535
type AcceptFn<T> = fn(&mut T, &AcceptContext<'_>, &ArgParser<'_>);
36-
type AcceptMapping<T> = &'static [(&'static [rustc_span::Symbol], AcceptFn<T>)];
36+
type AcceptMapping<T> = &'static [(&'static [Symbol], AcceptFn<T>)];
3737

3838
/// An [`AttributeParser`] is a type which searches for syntactic attributes.
3939
///
@@ -72,7 +72,7 @@ pub(crate) trait AttributeParser: Default + 'static {
7272
/// [`SingleAttributeParser`] can only convert attributes one-to-one, and cannot combine multiple
7373
/// attributes together like is necessary for `#[stable()]` and `#[unstable()]` for example.
7474
pub(crate) trait SingleAttributeParser: 'static {
75-
const PATH: &'static [rustc_span::Symbol];
75+
const PATH: &'static [Symbol];
7676

7777
/// Caled when a duplicate attribute is found.
7878
///
@@ -119,7 +119,7 @@ type ConvertFn<E> = fn(ThinVec<E>) -> AttributeKind;
119119
/// [`CombineAttributeParser`] can only convert a single kind of attribute, and cannot combine multiple
120120
/// attributes together like is necessary for `#[stable()]` and `#[unstable()]` for example.
121121
pub(crate) trait CombineAttributeParser: 'static {
122-
const PATH: &'static [rustc_span::Symbol];
122+
const PATH: &'static [Symbol];
123123

124124
type Item;
125125
const CONVERT: ConvertFn<Self::Item>;

compiler/rustc_attr_parsing/src/attributes/repr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_abi::Align;
22
use rustc_ast::{IntTy, LitIntType, LitKind, UintTy};
33
use rustc_attr_data_structures::{AttributeKind, IntType, ReprAttr};
4-
use rustc_span::{Span, Symbol, sym};
4+
use rustc_span::{DUMMY_SP, Span, Symbol, sym};
55

66
use super::{CombineAttributeParser, ConvertFn};
77
use crate::context::AcceptContext;
@@ -21,7 +21,7 @@ pub(crate) struct ReprParser;
2121

2222
impl CombineAttributeParser for ReprParser {
2323
type Item = (ReprAttr, Span);
24-
const PATH: &'static [rustc_span::Symbol] = &[sym::repr];
24+
const PATH: &'static [Symbol] = &[sym::repr];
2525
const CONVERT: ConvertFn<Self::Item> = AttributeKind::Repr;
2626

2727
fn extend<'a>(
@@ -99,7 +99,7 @@ fn parse_repr(cx: &AcceptContext<'_>, param: &MetaItemParser<'_>) -> Option<Repr
9999
let (name, ident_span) = if let Some(ident) = param.path_without_args().word() {
100100
(Some(ident.name), ident.span)
101101
} else {
102-
(None, rustc_span::DUMMY_SP)
102+
(None, DUMMY_SP)
103103
};
104104

105105
let args = param.args();

compiler/rustc_attr_parsing/src/attributes/stability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl AttributeParser for BodyStabilityParser {
117117
pub(crate) struct ConstStabilityIndirectParser;
118118
// FIXME(jdonszelmann): single word attribute group when we have these
119119
impl SingleAttributeParser for ConstStabilityIndirectParser {
120-
const PATH: &'static [rustc_span::Symbol] = &[sym::rustc_const_stable_indirect];
120+
const PATH: &'static [Symbol] = &[sym::rustc_const_stable_indirect];
121121

122122
// ignore
123123
fn on_duplicate(_cx: &AcceptContext<'_>, _first_span: Span) {}

compiler/rustc_attr_parsing/src/attributes/transparency.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_attr_data_structures::AttributeKind;
22
use rustc_span::hygiene::Transparency;
3-
use rustc_span::sym;
3+
use rustc_span::{Span, Symbol, sym};
44

55
use super::{AcceptContext, SingleAttributeParser};
66
use crate::parser::ArgParser;
@@ -11,9 +11,9 @@ pub(crate) struct TransparencyParser;
1111
#[allow(rustc::untranslatable_diagnostic)]
1212
#[allow(rustc::diagnostic_outside_of_impl)]
1313
impl SingleAttributeParser for TransparencyParser {
14-
const PATH: &'static [rustc_span::Symbol] = &[sym::rustc_macro_transparency];
14+
const PATH: &'static [Symbol] = &[sym::rustc_macro_transparency];
1515

16-
fn on_duplicate(cx: &crate::context::AcceptContext<'_>, first_span: rustc_span::Span) {
16+
fn on_duplicate(cx: &crate::context::AcceptContext<'_>, first_span: Span) {
1717
cx.dcx().span_err(vec![first_span, cx.attr_span], "multiple macro transparency attributes");
1818
}
1919

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,29 @@ macro_rules! attribute_groups {
2626
(
2727
pub(crate) static $name: ident = [$($names: ty),* $(,)?];
2828
) => {
29-
pub(crate) static $name: LazyLock<(
30-
BTreeMap<&'static [Symbol], Vec<Box<dyn Fn(&AcceptContext<'_>, &ArgParser<'_>) + Send + Sync>>>,
31-
Vec<Box<dyn Send + Sync + Fn(&FinalizeContext<'_>) -> Option<AttributeKind>>>
32-
)> = LazyLock::new(|| {
33-
let mut accepts = BTreeMap::<_, Vec<Box<dyn Fn(&AcceptContext<'_>, &ArgParser<'_>) + Send + Sync>>>::new();
34-
let mut finalizes = Vec::<Box<dyn Send + Sync + Fn(&FinalizeContext<'_>) -> Option<AttributeKind>>>::new();
29+
type Accepts = BTreeMap<
30+
&'static [Symbol],
31+
Box<dyn Send + Sync + Fn(&AcceptContext<'_>, &ArgParser<'_>)>
32+
>;
33+
type Finalizes = Vec<
34+
Box<dyn Send + Sync + Fn(&FinalizeContext<'_>) -> Option<AttributeKind>>
35+
>;
36+
pub(crate) static $name: LazyLock<(Accepts, Finalizes)> = LazyLock::new(|| {
37+
let mut accepts = Accepts::new();
38+
let mut finalizes = Finalizes::new();
3539
$(
3640
{
3741
thread_local! {
3842
static STATE_OBJECT: RefCell<$names> = RefCell::new(<$names>::default());
3943
};
4044

4145
for (k, v) in <$names>::ATTRIBUTES {
42-
accepts.entry(*k).or_default().push(Box::new(|cx, args| {
46+
let old = accepts.insert(*k, Box::new(|cx, args| {
4347
STATE_OBJECT.with_borrow_mut(|s| {
4448
v(s, cx, args)
4549
})
4650
}));
51+
assert!(old.is_none());
4752
}
4853

4954
finalizes.push(Box::new(|cx| {
@@ -110,7 +115,8 @@ impl<'a> Deref for AcceptContext<'a> {
110115

111116
/// Context given to every attribute parser during finalization.
112117
///
113-
/// Gives [`AttributeParser`](crate::attributes::AttributeParser)s enough information to create errors, for example.
118+
/// Gives [`AttributeParser`](crate::attributes::AttributeParser)s enough information to create
119+
/// errors, for example.
114120
pub(crate) struct FinalizeContext<'a> {
115121
/// The parse context, gives access to the session and the
116122
/// diagnostics context.
@@ -141,10 +147,9 @@ pub struct AttributeParser<'sess> {
141147
sess: &'sess Session,
142148
features: Option<&'sess Features>,
143149

144-
/// *only* parse attributes with this symbol.
150+
/// *Only* parse attributes with this symbol.
145151
///
146-
/// Used in cases where we want the lowering infrastructure for
147-
/// parse just a single attribute.
152+
/// Used in cases where we want the lowering infrastructure for parse just a single attribute.
148153
parse_only: Option<Symbol>,
149154

150155
/// Can be used to instruct parsers to reduce the number of diagnostics it emits.
@@ -157,9 +162,9 @@ impl<'sess> AttributeParser<'sess> {
157162
/// One example where this is necessary, is to parse `feature` attributes themselves for
158163
/// example.
159164
///
160-
/// Try to use this as little as possible. Attributes *should* be lowered during `rustc_ast_lowering`.
161-
/// Some attributes require access to features to parse, which would crash if you tried to do so
162-
/// through [`parse_limited`](Self::parse_limited).
165+
/// Try to use this as little as possible. Attributes *should* be lowered during
166+
/// `rustc_ast_lowering`. Some attributes require access to features to parse, which would
167+
/// crash if you tried to do so through [`parse_limited`](Self::parse_limited).
163168
///
164169
/// To make sure use is limited, supply a `Symbol` you'd like to parse. Only attributes with
165170
/// that symbol are picked out of the list of instructions and parsed. Those are returned.
@@ -217,19 +222,18 @@ impl<'sess> AttributeParser<'sess> {
217222
let group_cx = FinalizeContext { cx: self, target_span };
218223

219224
for attr in attrs {
220-
// if we're only looking for a single attribute,
221-
// skip all the ones we don't care about
225+
// If we're only looking for a single attribute, skip all the ones we don't care about.
222226
if let Some(expected) = self.parse_only {
223227
if !attr.has_name(expected) {
224228
continue;
225229
}
226230
}
227231

228-
// sometimes, for example for `#![doc = include_str!("readme.md")]`,
232+
// Sometimes, for example for `#![doc = include_str!("readme.md")]`,
229233
// doc still contains a non-literal. You might say, when we're lowering attributes
230234
// that's expanded right? But no, sometimes, when parsing attributes on macros,
231235
// we already use the lowering logic and these are still there. So, when `omit_doc`
232-
// is set we *also* want to ignore these
236+
// is set we *also* want to ignore these.
233237
if omit_doc == OmitDoc::Skip && attr.has_name(sym::doc) {
234238
continue;
235239
}
@@ -263,21 +267,17 @@ impl<'sess> AttributeParser<'sess> {
263267
let (path, args) = parser.deconstruct();
264268
let parts = path.segments().map(|i| i.name).collect::<Vec<_>>();
265269

266-
if let Some(accepts) = ATTRIBUTE_MAPPING.0.get(parts.as_slice()) {
267-
for f in accepts {
268-
let cx = AcceptContext {
269-
group_cx: &group_cx,
270-
attr_span: lower_span(attr.span),
271-
};
270+
if let Some(accept) = ATTRIBUTE_MAPPING.0.get(parts.as_slice()) {
271+
let cx =
272+
AcceptContext { group_cx: &group_cx, attr_span: lower_span(attr.span) };
272273

273-
f(&cx, &args)
274-
}
274+
accept(&cx, &args)
275275
} else {
276-
// if we're here, we must be compiling a tool attribute... Or someone forgot to
277-
// parse their fancy new attribute. Let's warn them in any case. If you are that
278-
// person, and you really your attribute should remain unparsed, carefully read the
279-
// documentation in this module and if you still think so you can add an exception
280-
// to this assertion.
276+
// If we're here, we must be compiling a tool attribute... Or someone
277+
// forgot to parse their fancy new attribute. Let's warn them in any case.
278+
// If you are that person, and you really think your attribute should
279+
// remain unparsed, carefully read the documentation in this module and if
280+
// you still think so you can add an exception to this assertion.
281281

282282
// FIXME(jdonszelmann): convert other attributes, and check with this that
283283
// we caught em all

compiler/rustc_attr_parsing/src/parser.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ use rustc_ast::{AttrArgs, DelimArgs, Expr, ExprKind, LitKind, MetaItemLit, Norma
1212
use rustc_ast_pretty::pprust;
1313
use rustc_errors::DiagCtxtHandle;
1414
use rustc_hir::{self as hir, AttrPath};
15-
use rustc_span::symbol::{Ident, kw, sym};
16-
use rustc_span::{ErrorGuaranteed, Span, Symbol};
15+
use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol, kw, sym};
1716

1817
pub struct SegmentIterator<'a> {
1918
offset: usize,

compiler/rustc_const_eval/messages.ftl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,7 @@ const_eval_unstable_in_stable_exposed =
424424
.unstable_sugg = if the {$is_function_call2 ->
425425
[true] caller
426426
*[false] function
427-
} is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do)
428-
.bypass_sugg = otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
427+
} is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]`
429428
430429
const_eval_unstable_intrinsic = `{$name}` is not yet stable as a const intrinsic
431430
const_eval_unstable_intrinsic_suggestion = add `#![feature({$feature})]` to the crate attributes to enable

compiler/rustc_const_eval/src/errors.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ pub(crate) struct UnstableInStableExposed {
5858
code = "#[rustc_const_unstable(feature = \"...\", issue = \"...\")]\n",
5959
applicability = "has-placeholders"
6060
)]
61-
#[suggestion(
62-
const_eval_bypass_sugg,
63-
code = "#[rustc_allow_const_fn_unstable({gate})]\n",
64-
applicability = "has-placeholders"
65-
)]
6661
pub attr_span: Span,
6762
}
6863

library/core/src/str/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,7 @@ impl str {
11731173
/// The iterator returned will return string slices that are sub-slices of
11741174
/// the original string slice, separated by any amount of ASCII whitespace.
11751175
///
1176+
/// This uses the same definition as [`char::is_ascii_whitespace`].
11761177
/// To split by Unicode `Whitespace` instead, use [`split_whitespace`].
11771178
///
11781179
/// [`split_whitespace`]: str::split_whitespace
@@ -1191,7 +1192,8 @@ impl str {
11911192
/// assert_eq!(None, iter.next());
11921193
/// ```
11931194
///
1194-
/// All kinds of ASCII whitespace are considered:
1195+
/// Various kinds of ASCII whitespace are considered
1196+
/// (see [`char::is_ascii_whitespace`]):
11951197
///
11961198
/// ```
11971199
/// let mut iter = " Mary had\ta little \n\t lamb".split_ascii_whitespace();

library/std/src/ffi/os_str.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,9 @@ impl OsString {
594594
/// The slice must be valid for the platform encoding (as described in
595595
/// [`OsStr::from_encoded_bytes_unchecked`]).
596596
///
597-
/// This bypasses the encoding-dependent surrogate joining, so `self` must
598-
/// not end with a leading surrogate half and `other` must not start with
599-
/// with a trailing surrogate half.
597+
/// This bypasses the encoding-dependent surrogate joining, so either
598+
/// `self` must not end with a leading surrogate half, or `other` must not
599+
/// start with a trailing surrogate half.
600600
#[inline]
601601
pub(crate) unsafe fn extend_from_slice_unchecked(&mut self, other: &[u8]) {
602602
// SAFETY: Guaranteed by caller.

library/std/src/fs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,8 +2803,8 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
28032803
/// Recursively create a directory and all of its parent components if they
28042804
/// are missing.
28052805
///
2806-
/// If this function returns an error, some of the parent components might have
2807-
/// been created already.
2806+
/// This function is not atomic. If it returns an error, any parent components it was able to create
2807+
/// will remain.
28082808
///
28092809
/// If the empty path is passed to this function, it always succeeds without
28102810
/// creating any directories.

library/std/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@
352352
#![feature(hashmap_internals)]
353353
#![feature(hint_must_use)]
354354
#![feature(ip)]
355+
#![feature(ipv6_hop_limit)]
355356
#![feature(lazy_get)]
356357
#![feature(maybe_uninit_slice)]
357358
#![feature(maybe_uninit_write_slice)]

0 commit comments

Comments
 (0)