Skip to content

Commit fd75a9c

Browse files
committed
Auto merge of #146160 - Zalathar:rollup-qxphx7g, r=Zalathar
Rollup of 8 pull requests Successful merges: - #145279 (Constify conversion traits (part 1)) - #145414 (unicode-table-generator refactors) - #145823 (editorconfig: don't use nonexistent syntax) - #145944 (std: Start supporting WASIp2 natively ) - #145961 (resolve: Avoid a regression from splitting prelude into two scopes) - #146032 (Explicity disable LSX feature for `loongarch64-unknown-none` target) - #146106 (fix(lexer): Only allow horizontal whitespace in frontmatter ) - #146154 (CI: rfl: move job forward to Linux v6.17-rc3 plus 2 commits) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 51ff895 + 263048d commit fd75a9c

Some content is hidden

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

79 files changed

+776
-371
lines changed

.editorconfig

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,23 @@ root = true
88
end_of_line = lf
99
charset = utf-8
1010
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
indent_style = space
13+
indent_size = 4
1114

1215
# some tests need trailing whitespace in output snapshots
13-
[!tests/]
14-
trim_trailing_whitespace = true
16+
[tests/**]
17+
trim_trailing_whitespace = false
1518
# for actual source code files of test, we still don't want trailing whitespace
1619
[tests/**.{rs,js}]
1720
trim_trailing_whitespace = true
1821
# these specific source files need to have trailing whitespace.
1922
[tests/ui/{frontmatter/frontmatter-whitespace-3.rs,parser/shebang/shebang-space.rs}]
2023
trim_trailing_whitespace = false
2124

22-
[!src/llvm-project]
23-
indent_style = space
24-
indent_size = 4
25+
[src/llvm-project]
26+
indent_style = unset
27+
indent_size = unset
2528

2629
[*.rs]
2730
max_line_length = 100

compiler/rustc_lexer/src/lib.rs

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -331,24 +331,37 @@ pub fn is_whitespace(c: char) -> bool {
331331

332332
matches!(
333333
c,
334-
// Usual ASCII suspects
335-
'\u{0009}' // \t
336-
| '\u{000A}' // \n
334+
// End-of-line characters
335+
| '\u{000A}' // line feed (\n)
337336
| '\u{000B}' // vertical tab
338337
| '\u{000C}' // form feed
339-
| '\u{000D}' // \r
340-
| '\u{0020}' // space
341-
342-
// NEXT LINE from latin1
343-
| '\u{0085}'
338+
| '\u{000D}' // carriage return (\r)
339+
| '\u{0085}' // next line (from latin1)
340+
| '\u{2028}' // LINE SEPARATOR
341+
| '\u{2029}' // PARAGRAPH SEPARATOR
344342

345-
// Bidi markers
343+
// `Default_Ignorable_Code_Point` characters
346344
| '\u{200E}' // LEFT-TO-RIGHT MARK
347345
| '\u{200F}' // RIGHT-TO-LEFT MARK
348346

349-
// Dedicated whitespace characters from Unicode
350-
| '\u{2028}' // LINE SEPARATOR
351-
| '\u{2029}' // PARAGRAPH SEPARATOR
347+
// Horizontal space characters
348+
| '\u{0009}' // tab (\t)
349+
| '\u{0020}' // space
350+
)
351+
}
352+
353+
/// True if `c` is considered horizontal whitespace according to Rust language definition.
354+
pub fn is_horizontal_whitespace(c: char) -> bool {
355+
// This is Pattern_White_Space.
356+
//
357+
// Note that this set is stable (ie, it doesn't change with different
358+
// Unicode versions), so it's ok to just hard-code the values.
359+
360+
matches!(
361+
c,
362+
// Horizontal space characters
363+
'\u{0009}' // tab (\t)
364+
| '\u{0020}' // space
352365
)
353366
}
354367

@@ -538,7 +551,7 @@ impl Cursor<'_> {
538551
debug_assert!(length_opening >= 3);
539552

540553
// whitespace between the opening and the infostring.
541-
self.eat_while(|ch| ch != '\n' && is_whitespace(ch));
554+
self.eat_while(|ch| ch != '\n' && is_horizontal_whitespace(ch));
542555

543556
// copied from `eat_identifier`, but allows `-` and `.` in infostring to allow something like
544557
// `---Cargo.toml` as a valid opener
@@ -547,7 +560,7 @@ impl Cursor<'_> {
547560
self.eat_while(|c| is_id_continue(c) || c == '-' || c == '.');
548561
}
549562

550-
self.eat_while(|ch| ch != '\n' && is_whitespace(ch));
563+
self.eat_while(|ch| ch != '\n' && is_horizontal_whitespace(ch));
551564
let invalid_infostring = self.first() != '\n';
552565

553566
let mut found = false;
@@ -588,7 +601,7 @@ impl Cursor<'_> {
588601
// on a standalone line. Might be wrong.
589602
while let Some(closing) = rest.find("---") {
590603
let preceding_chars_start = rest[..closing].rfind("\n").map_or(0, |i| i + 1);
591-
if rest[preceding_chars_start..closing].chars().all(is_whitespace) {
604+
if rest[preceding_chars_start..closing].chars().all(is_horizontal_whitespace) {
592605
// candidate found
593606
potential_closing = Some(closing);
594607
break;

compiler/rustc_parse/src/lexer/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_ast::util::unicode::{TEXT_FLOW_CONTROL_CHARS, contains_text_flow_contr
66
use rustc_errors::codes::*;
77
use rustc_errors::{Applicability, Diag, DiagCtxtHandle, StashKey};
88
use rustc_lexer::{
9-
Base, Cursor, DocStyle, FrontmatterAllowed, LiteralKind, RawStrError, is_whitespace,
9+
Base, Cursor, DocStyle, FrontmatterAllowed, LiteralKind, RawStrError, is_horizontal_whitespace,
1010
};
1111
use rustc_literal_escaper::{EscapeError, Mode, check_for_errors};
1212
use rustc_session::lint::BuiltinLintDiag;
@@ -597,7 +597,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
597597

598598
let last_line_start = within.rfind('\n').map_or(0, |i| i + 1);
599599
let last_line = &within[last_line_start..];
600-
let last_line_trimmed = last_line.trim_start_matches(is_whitespace);
600+
let last_line_trimmed = last_line.trim_start_matches(is_horizontal_whitespace);
601601
let last_line_start_pos = frontmatter_opening_end_pos + BytePos(last_line_start as u32);
602602

603603
let frontmatter_span = self.mk_sp(frontmatter_opening_pos, self.pos);
@@ -640,7 +640,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
640640
});
641641
}
642642

643-
if !rest.trim_matches(is_whitespace).is_empty() {
643+
if !rest.trim_matches(is_horizontal_whitespace).is_empty() {
644644
let span = self.mk_sp(last_line_start_pos, self.pos);
645645
self.dcx().emit_err(errors::FrontmatterExtraCharactersAfterClose { span });
646646
}

compiler/rustc_resolve/src/ident.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
422422
// to detect potential ambiguities.
423423
let mut innermost_result: Option<(NameBinding<'_>, Flags)> = None;
424424
let mut determinacy = Determinacy::Determined;
425+
let mut extern_prelude_item_binding = None;
426+
let mut extern_prelude_flag_binding = None;
425427
// Shadowed bindings don't need to be marked as used or non-speculatively loaded.
426428
macro finalize_scope() {
427429
if innermost_result.is_none() { finalize } else { None }
@@ -558,15 +560,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
558560
Scope::ExternPreludeItems => {
559561
// FIXME: use `finalize_scope` here.
560562
match this.reborrow().extern_prelude_get_item(ident, finalize.is_some()) {
561-
Some(binding) => Ok((binding, Flags::empty())),
563+
Some(binding) => {
564+
extern_prelude_item_binding = Some(binding);
565+
Ok((binding, Flags::empty()))
566+
}
562567
None => Err(Determinacy::determined(
563568
this.graph_root.unexpanded_invocations.borrow().is_empty(),
564569
)),
565570
}
566571
}
567572
Scope::ExternPreludeFlags => {
568573
match this.extern_prelude_get_flag(ident, finalize_scope!().is_some()) {
569-
Some(binding) => Ok((binding, Flags::empty())),
574+
Some(binding) => {
575+
extern_prelude_flag_binding = Some(binding);
576+
Ok((binding, Flags::empty()))
577+
}
570578
None => Err(Determinacy::Determined),
571579
}
572580
}
@@ -686,7 +694,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
686694
} else {
687695
None
688696
};
689-
if let Some(kind) = ambiguity_error_kind {
697+
// Skip ambiguity errors for extern flag bindings "overridden"
698+
// by extern item bindings.
699+
// FIXME: Remove with lang team approval.
700+
let issue_145575_hack = Some(binding)
701+
== extern_prelude_flag_binding
702+
&& extern_prelude_item_binding.is_some()
703+
&& extern_prelude_item_binding != Some(innermost_binding);
704+
if let Some(kind) = ambiguity_error_kind
705+
&& !issue_145575_hack
706+
{
690707
let misc = |f: Flags| {
691708
if f.contains(Flags::MISC_SUGGEST_CRATE) {
692709
AmbiguityErrorMisc::SuggestCrate

compiler/rustc_target/src/spec/targets/loongarch64_unknown_none.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
1717
arch: "loongarch64".into(),
1818
options: TargetOptions {
1919
cpu: "generic".into(),
20-
features: "+f,+d".into(),
20+
features: "+f,+d,-lsx".into(),
2121
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
2222
linker: Some("rust-lld".into()),
2323
llvm_abiname: "lp64d".into(),

library/Cargo.lock

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ dependencies = [
327327
"rustc-demangle",
328328
"std_detect",
329329
"unwind",
330-
"wasi",
330+
"wasi 0.11.1+wasi-snapshot-preview1",
331+
"wasi 0.14.3+wasi-0.2.4",
331332
"windows-targets 0.0.0",
332333
]
333334

@@ -399,6 +400,17 @@ dependencies = [
399400
"rustc-std-workspace-core",
400401
]
401402

403+
[[package]]
404+
name = "wasi"
405+
version = "0.14.3+wasi-0.2.4"
406+
source = "registry+https://github.com/rust-lang/crates.io-index"
407+
checksum = "6a51ae83037bdd272a9e28ce236db8c07016dd0d50c27038b3f407533c030c95"
408+
dependencies = [
409+
"rustc-std-workspace-alloc",
410+
"rustc-std-workspace-core",
411+
"wit-bindgen",
412+
]
413+
402414
[[package]]
403415
name = "windows-sys"
404416
version = "0.59.0"
@@ -475,3 +487,13 @@ name = "windows_x86_64_msvc"
475487
version = "0.52.6"
476488
source = "registry+https://github.com/rust-lang/crates.io-index"
477489
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
490+
491+
[[package]]
492+
name = "wit-bindgen"
493+
version = "0.45.0"
494+
source = "registry+https://github.com/rust-lang/crates.io-index"
495+
checksum = "052283831dbae3d879dc7f51f3d92703a316ca49f91540417d38591826127814"
496+
dependencies = [
497+
"rustc-std-workspace-alloc",
498+
"rustc-std-workspace-core",
499+
]

library/alloc/src/borrow.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ use crate::fmt;
1717
use crate::string::String;
1818

1919
#[stable(feature = "rust1", since = "1.0.0")]
20-
impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B>
20+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
21+
impl<'a, B: ?Sized> const Borrow<B> for Cow<'a, B>
2122
where
2223
B: ToOwned,
24+
B::Owned: [const] Borrow<B>,
2325
{
2426
fn borrow(&self) -> &B {
2527
&**self
@@ -326,9 +328,10 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
326328
}
327329

328330
#[stable(feature = "rust1", since = "1.0.0")]
329-
impl<B: ?Sized + ToOwned> Deref for Cow<'_, B>
331+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
332+
impl<B: ?Sized + ToOwned> const Deref for Cow<'_, B>
330333
where
331-
B::Owned: Borrow<B>,
334+
B::Owned: [const] Borrow<B>,
332335
{
333336
type Target = B;
334337

@@ -439,7 +442,11 @@ where
439442
}
440443

441444
#[stable(feature = "rust1", since = "1.0.0")]
442-
impl<T: ?Sized + ToOwned> AsRef<T> for Cow<'_, T> {
445+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
446+
impl<T: ?Sized + ToOwned> const AsRef<T> for Cow<'_, T>
447+
where
448+
T::Owned: [const] Borrow<T>,
449+
{
443450
fn as_ref(&self) -> &T {
444451
self
445452
}

library/alloc/src/collections/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,19 @@ pub use realalloc::collections::TryReserveErrorKind;
128128
reason = "Uncertain how much info should be exposed",
129129
issue = "48043"
130130
)]
131+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
131132
#[cfg(not(test))]
132-
impl From<TryReserveErrorKind> for TryReserveError {
133+
impl const From<TryReserveErrorKind> for TryReserveError {
133134
#[inline]
134135
fn from(kind: TryReserveErrorKind) -> Self {
135136
Self { kind }
136137
}
137138
}
138139

139140
#[unstable(feature = "try_reserve_kind", reason = "new API", issue = "48043")]
141+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
140142
#[cfg(not(test))]
141-
impl From<LayoutError> for TryReserveErrorKind {
143+
impl const From<LayoutError> for TryReserveErrorKind {
142144
/// Always evaluates to [`TryReserveErrorKind::CapacityOverflow`].
143145
#[inline]
144146
fn from(_: LayoutError) -> Self {

library/alloc/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@
107107
#![feature(char_max_len)]
108108
#![feature(clone_to_uninit)]
109109
#![feature(coerce_unsized)]
110+
#![feature(const_convert)]
110111
#![feature(const_default)]
111112
#![feature(const_eval_select)]
112113
#![feature(const_heap)]
113-
#![feature(const_trait_impl)]
114114
#![feature(core_intrinsics)]
115115
#![feature(deprecated_suggestion)]
116116
#![feature(deref_pure_trait)]
@@ -168,6 +168,7 @@
168168
#![feature(allow_internal_unstable)]
169169
#![feature(cfg_sanitize)]
170170
#![feature(const_precise_live_drops)]
171+
#![feature(const_trait_impl)]
171172
#![feature(coroutine_trait)]
172173
#![feature(decl_macro)]
173174
#![feature(dropck_eyepatch)]

library/alloctests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
// Language features:
5050
// tidy-alphabetical-start
5151
#![feature(cfg_sanitize)]
52+
#![feature(const_trait_impl)]
5253
#![feature(dropck_eyepatch)]
5354
#![feature(lang_items)]
5455
#![feature(min_specialization)]

0 commit comments

Comments
 (0)