Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c992245
refactor: Include table sizes in comment at top of `unicode_data.rs`
Kmeakin Aug 9, 2025
69e1974
refactor: Include size of case conversion tables
Kmeakin Aug 9, 2025
5d54ac5
refactor: rewrite `ranges_from_set`
Kmeakin Aug 10, 2025
30d1bc7
refactor: `generate_tests`
Kmeakin Aug 10, 2025
c3ce079
refactor: Add tests for case conversions
Kmeakin Aug 10, 2025
3b627b5
editorconfig: don't use nonexistant syntax
lolbinarycat Aug 24, 2025
aa27cca
Add a sanity check to bootstrap for wasm-component-ld
alexcrichton Aug 26, 2025
5d81f03
std: Start supporting WASIp2 natively
alexcrichton Aug 26, 2025
8930d3a
resolve: Avoid a regression from splitting prelude into two scopes
petrochenkov Aug 28, 2025
0b1bc65
Explicity disable LSX feature for `loongarch64-unknown-none` target
heiher Aug 30, 2025
4524d9d
unstable book: in a sanitizer example, check the code
folkertdev Mar 29, 2025
1c64d3e
Constify conversion traits
clarfonthey Aug 11, 2025
b2962c3
test(lexer): Ensure frontmatter w/ crlf works
epage Aug 28, 2025
159be09
test(lexer): Ensure frontmatter can contain unicode whitespace
epage Aug 29, 2025
9304aa1
test(lexer): Ensure tabs are accepted for horizontal whitespace
epage Aug 29, 2025
428e413
docs(lexer): Organize and document whitespace by Pattern_White_Space
epage Aug 28, 2025
6f0da97
fix(lexer): Only allow horizontal whitespace in frontmatter
epage Aug 28, 2025
2295dd4
Rollup merge of #139113 - folkertdev:sanitizer-unstable-book-check-bl…
tgross35 Sep 3, 2025
a2693eb
Rollup merge of #145279 - clarfonthey:const-convert-initial, r=tgross35
tgross35 Sep 3, 2025
17e2d38
Rollup merge of #145414 - Kmeakin:km/unicode-table-refactors, r=josht…
tgross35 Sep 3, 2025
db2af4b
Rollup merge of #145823 - lolbinarycat:editorconfig-fix, r=GuillaumeG…
tgross35 Sep 3, 2025
66c0e3a
Rollup merge of #145944 - alexcrichton:native-wasip2, r=tgross35
tgross35 Sep 3, 2025
f14758e
Rollup merge of #145961 - petrochenkov:extprelregr, r=nnethercote
tgross35 Sep 3, 2025
24458ac
Rollup merge of #146032 - heiher:loong64-none-no-lsx, r=lqd
tgross35 Sep 3, 2025
ab3eecf
Rollup merge of #146106 - epage:whitespace, r=fee1-dead
tgross35 Sep 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ root = true
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

# some tests need trailing whitespace in output snapshots
[!tests/]
trim_trailing_whitespace = true
[tests/**]
trim_trailing_whitespace = false
# for actual source code files of test, we still don't want trailing whitespace
[tests/**.{rs,js}]
trim_trailing_whitespace = true
# these specific source files need to have trailing whitespace.
[tests/ui/{frontmatter/frontmatter-whitespace-3.rs,parser/shebang/shebang-space.rs}]
trim_trailing_whitespace = false

[!src/llvm-project]
indent_style = space
indent_size = 4
[src/llvm-project]
indent_style = unset
indent_size = unset

[*.rs]
max_line_length = 100
Expand Down
43 changes: 28 additions & 15 deletions compiler/rustc_lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,24 +331,37 @@ pub fn is_whitespace(c: char) -> bool {

matches!(
c,
// Usual ASCII suspects
'\u{0009}' // \t
| '\u{000A}' // \n
// End-of-line characters
| '\u{000A}' // line feed (\n)
| '\u{000B}' // vertical tab
| '\u{000C}' // form feed
| '\u{000D}' // \r
| '\u{0020}' // space

// NEXT LINE from latin1
| '\u{0085}'
| '\u{000D}' // carriage return (\r)
| '\u{0085}' // next line (from latin1)
| '\u{2028}' // LINE SEPARATOR
| '\u{2029}' // PARAGRAPH SEPARATOR

// Bidi markers
// `Default_Ignorable_Code_Point` characters
| '\u{200E}' // LEFT-TO-RIGHT MARK
| '\u{200F}' // RIGHT-TO-LEFT MARK

// Dedicated whitespace characters from Unicode
| '\u{2028}' // LINE SEPARATOR
| '\u{2029}' // PARAGRAPH SEPARATOR
// Horizontal space characters
| '\u{0009}' // tab (\t)
| '\u{0020}' // space
)
}

/// True if `c` is considered horizontal whitespace according to Rust language definition.
pub fn is_horizontal_whitespace(c: char) -> bool {
// This is Pattern_White_Space.
//
// Note that this set is stable (ie, it doesn't change with different
// Unicode versions), so it's ok to just hard-code the values.

matches!(
c,
// Horizontal space characters
'\u{0009}' // tab (\t)
| '\u{0020}' // space
)
}

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

// whitespace between the opening and the infostring.
self.eat_while(|ch| ch != '\n' && is_whitespace(ch));
self.eat_while(|ch| ch != '\n' && is_horizontal_whitespace(ch));

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

self.eat_while(|ch| ch != '\n' && is_whitespace(ch));
self.eat_while(|ch| ch != '\n' && is_horizontal_whitespace(ch));
let invalid_infostring = self.first() != '\n';

let mut found = false;
Expand Down Expand Up @@ -588,7 +601,7 @@ impl Cursor<'_> {
// on a standalone line. Might be wrong.
while let Some(closing) = rest.find("---") {
let preceding_chars_start = rest[..closing].rfind("\n").map_or(0, |i| i + 1);
if rest[preceding_chars_start..closing].chars().all(is_whitespace) {
if rest[preceding_chars_start..closing].chars().all(is_horizontal_whitespace) {
// candidate found
potential_closing = Some(closing);
break;
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_parse/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_ast::util::unicode::{TEXT_FLOW_CONTROL_CHARS, contains_text_flow_contr
use rustc_errors::codes::*;
use rustc_errors::{Applicability, Diag, DiagCtxtHandle, StashKey};
use rustc_lexer::{
Base, Cursor, DocStyle, FrontmatterAllowed, LiteralKind, RawStrError, is_whitespace,
Base, Cursor, DocStyle, FrontmatterAllowed, LiteralKind, RawStrError, is_horizontal_whitespace,
};
use rustc_literal_escaper::{EscapeError, Mode, check_for_errors};
use rustc_session::lint::BuiltinLintDiag;
Expand Down Expand Up @@ -597,7 +597,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> {

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

let frontmatter_span = self.mk_sp(frontmatter_opening_pos, self.pos);
Expand Down Expand Up @@ -640,7 +640,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
});
}

if !rest.trim_matches(is_whitespace).is_empty() {
if !rest.trim_matches(is_horizontal_whitespace).is_empty() {
let span = self.mk_sp(last_line_start_pos, self.pos);
self.dcx().emit_err(errors::FrontmatterExtraCharactersAfterClose { span });
}
Expand Down
23 changes: 20 additions & 3 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// to detect potential ambiguities.
let mut innermost_result: Option<(NameBinding<'_>, Flags)> = None;
let mut determinacy = Determinacy::Determined;
let mut extern_prelude_item_binding = None;
let mut extern_prelude_flag_binding = None;
// Shadowed bindings don't need to be marked as used or non-speculatively loaded.
macro finalize_scope() {
if innermost_result.is_none() { finalize } else { None }
Expand Down Expand Up @@ -558,15 +560,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
Scope::ExternPreludeItems => {
// FIXME: use `finalize_scope` here.
match this.reborrow().extern_prelude_get_item(ident, finalize.is_some()) {
Some(binding) => Ok((binding, Flags::empty())),
Some(binding) => {
extern_prelude_item_binding = Some(binding);
Ok((binding, Flags::empty()))
}
None => Err(Determinacy::determined(
this.graph_root.unexpanded_invocations.borrow().is_empty(),
)),
}
}
Scope::ExternPreludeFlags => {
match this.extern_prelude_get_flag(ident, finalize_scope!().is_some()) {
Some(binding) => Ok((binding, Flags::empty())),
Some(binding) => {
extern_prelude_flag_binding = Some(binding);
Ok((binding, Flags::empty()))
}
None => Err(Determinacy::Determined),
}
}
Expand Down Expand Up @@ -686,7 +694,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
} else {
None
};
if let Some(kind) = ambiguity_error_kind {
// Skip ambiguity errors for extern flag bindings "overridden"
// by extern item bindings.
// FIXME: Remove with lang team approval.
let issue_145575_hack = Some(binding)
== extern_prelude_flag_binding
&& extern_prelude_item_binding.is_some()
&& extern_prelude_item_binding != Some(innermost_binding);
if let Some(kind) = ambiguity_error_kind
&& !issue_145575_hack
{
let misc = |f: Flags| {
if f.contains(Flags::MISC_SUGGEST_CRATE) {
AmbiguityErrorMisc::SuggestCrate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
arch: "loongarch64".into(),
options: TargetOptions {
cpu: "generic".into(),
features: "+f,+d".into(),
features: "+f,+d,-lsx".into(),
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
llvm_abiname: "lp64d".into(),
Expand Down
24 changes: 23 additions & 1 deletion library/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ dependencies = [
"rustc-demangle",
"std_detect",
"unwind",
"wasi",
"wasi 0.11.1+wasi-snapshot-preview1",
"wasi 0.14.3+wasi-0.2.4",
"windows-targets 0.0.0",
]

Expand Down Expand Up @@ -399,6 +400,17 @@ dependencies = [
"rustc-std-workspace-core",
]

[[package]]
name = "wasi"
version = "0.14.3+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a51ae83037bdd272a9e28ce236db8c07016dd0d50c27038b3f407533c030c95"
dependencies = [
"rustc-std-workspace-alloc",
"rustc-std-workspace-core",
"wit-bindgen",
]

[[package]]
name = "windows-sys"
version = "0.59.0"
Expand Down Expand Up @@ -475,3 +487,13 @@ name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"

[[package]]
name = "wit-bindgen"
version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "052283831dbae3d879dc7f51f3d92703a316ca49f91540417d38591826127814"
dependencies = [
"rustc-std-workspace-alloc",
"rustc-std-workspace-core",
]
15 changes: 11 additions & 4 deletions library/alloc/src/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ use crate::fmt;
use crate::string::String;

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B>
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl<'a, B: ?Sized> const Borrow<B> for Cow<'a, B>
where
B: ToOwned,
B::Owned: [const] Borrow<B>,
{
fn borrow(&self) -> &B {
&**self
Expand Down Expand Up @@ -326,9 +328,10 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<B: ?Sized + ToOwned> Deref for Cow<'_, B>
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl<B: ?Sized + ToOwned> const Deref for Cow<'_, B>
where
B::Owned: Borrow<B>,
B::Owned: [const] Borrow<B>,
{
type Target = B;

Expand Down Expand Up @@ -439,7 +442,11 @@ where
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized + ToOwned> AsRef<T> for Cow<'_, T> {
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl<T: ?Sized + ToOwned> const AsRef<T> for Cow<'_, T>
where
T::Owned: [const] Borrow<T>,
{
fn as_ref(&self) -> &T {
self
}
Expand Down
6 changes: 4 additions & 2 deletions library/alloc/src/collections/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,19 @@ pub use realalloc::collections::TryReserveErrorKind;
reason = "Uncertain how much info should be exposed",
issue = "48043"
)]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
#[cfg(not(test))]
impl From<TryReserveErrorKind> for TryReserveError {
impl const From<TryReserveErrorKind> for TryReserveError {
#[inline]
fn from(kind: TryReserveErrorKind) -> Self {
Self { kind }
}
}

#[unstable(feature = "try_reserve_kind", reason = "new API", issue = "48043")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
#[cfg(not(test))]
impl From<LayoutError> for TryReserveErrorKind {
impl const From<LayoutError> for TryReserveErrorKind {
/// Always evaluates to [`TryReserveErrorKind::CapacityOverflow`].
#[inline]
fn from(_: LayoutError) -> Self {
Expand Down
3 changes: 2 additions & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@
#![feature(char_max_len)]
#![feature(clone_to_uninit)]
#![feature(coerce_unsized)]
#![feature(const_convert)]
#![feature(const_default)]
#![feature(const_eval_select)]
#![feature(const_heap)]
#![feature(const_trait_impl)]
#![feature(core_intrinsics)]
#![feature(deprecated_suggestion)]
#![feature(deref_pure_trait)]
Expand Down Expand Up @@ -168,6 +168,7 @@
#![feature(allow_internal_unstable)]
#![feature(cfg_sanitize)]
#![feature(const_precise_live_drops)]
#![feature(const_trait_impl)]
#![feature(coroutine_trait)]
#![feature(decl_macro)]
#![feature(dropck_eyepatch)]
Expand Down
1 change: 1 addition & 0 deletions library/alloctests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
// Language features:
// tidy-alphabetical-start
#![feature(cfg_sanitize)]
#![feature(const_trait_impl)]
#![feature(dropck_eyepatch)]
#![feature(lang_items)]
#![feature(min_specialization)]
Expand Down
Loading
Loading