Skip to content

Rollup of 7 pull requests #139301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 68 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
249e5b5
Fix rib example
sagudev Jan 7, 2025
a4b76e3
Adapt to rust-lang/rust#136466:
y1lan Mar 16, 2025
9a2d1fd
Following commit 401dd84 in the Rust project
y1lan Mar 16, 2025
3e448fd
Add chapter Remarks on perma-unstable features
xizheyin Mar 5, 2025
7faf2a5
Merge pull request #2268 from xizheyin/issue-137421
jieyouxu Mar 18, 2025
74698d7
Add Fuchsia ping group notice
Kobzol Mar 18, 2025
9ff4936
Reorder RfL tests page to move the "what if it breaks" section to the…
Kobzol Mar 18, 2025
c987d34
Add Fuchsia ping group page
Kobzol Mar 18, 2025
a9f46f1
Merge pull request #2294 from Kobzol/ping-group
Kobzol Mar 18, 2025
4f053a9
add new section on the `rustdoc` test suite
lolbinarycat Mar 18, 2025
3668c36
add htmldocck.md to SUMMARY.md
lolbinarycat Mar 18, 2025
a172f23
htmldocck: expand limitations and mention compiletest directives
lolbinarycat Mar 18, 2025
6893f0a
rustdoc test suite: clean up wording and intro
lolbinarycat Mar 18, 2025
1081d98
rename htmldocck.md -> rustdoc-test-suite.md
lolbinarycat Mar 18, 2025
40b9be0
clean up wording/grammar and mention double quotes
lolbinarycat Mar 18, 2025
7f29b47
normalize link titles
lolbinarycat Mar 18, 2025
eeda54f
update filename in link
lolbinarycat Mar 18, 2025
88478ac
Set linkcheck in `ci.yml`
Kobzol Mar 19, 2025
beb1c00
Merge pull request #2296 from jieyouxu/no-external-linkcheck
jieyouxu Mar 19, 2025
2daaf49
use correct code block markers
tshepang Mar 19, 2025
a9d3ed5
Merge pull request #2297 from rust-lang/tshepang-patch-1
tshepang Mar 19, 2025
594eed9
Merge pull request #2295 from lolbinarycat/rustdoc-htmldocck
jieyouxu Mar 20, 2025
904ec4d
Merge pull request #2199 from sagudev/patch-1
petrochenkov Mar 20, 2025
2de68a1
Update `ParamEnv` section for `TypingEnv` changes
BoxyUwU Mar 20, 2025
957aacd
Move Fuchsia and RfL under `ecosystem-test-jobs/` folder
jieyouxu Mar 21, 2025
d58ccd8
Stub out codegen backend test pages
jieyouxu Mar 21, 2025
cbcd286
Merge pull request #2265 from BoxyUwU/typing_env
lcnr Mar 21, 2025
ee6a159
doc: fix reference to #create-a-configtoml
chiichen Mar 23, 2025
dd91e28
Merge pull request #2300 from chiichen/dev/master/correct-config-to-b…
jieyouxu Mar 24, 2025
b34181a
Merge pull request #2299 from jieyouxu/test-jobs-reorg
jieyouxu Mar 24, 2025
de8b6be
add needed break
tshepang Mar 24, 2025
b08943a
Merge pull request #2302 from rust-lang/tshepang-patch-1
tshepang Mar 24, 2025
62ec34b
typo
tshepang Mar 24, 2025
8e0de0b
Merge pull request #2303 from rust-lang/tshepang-patch-2
tshepang Mar 24, 2025
a9a21bd
Delete from_method from rustc_on_unimplemented documentation
mejrs Mar 27, 2025
524d020
Merge pull request #2305 from mejrs/delete_from_method
tshepang Mar 27, 2025
cdbb219
Fix code generation link
spastorino Mar 28, 2025
8ab4141
Merge pull request #2306 from spastorino/fix-codegen-link
GuillaumeGomez Mar 28, 2025
40b1f48
Add the feature gate for the `super let` experiment.
m-ou-se Mar 28, 2025
5952f01
Fix trivial typo of `BoundVariableKind`
samueltardieu Mar 28, 2025
1be4bb4
Merge pull request #2307 from samueltardieu/push-xvxvkunupkmp
BoxyUwU Mar 28, 2025
865a5a7
mention that know-bug test directive takes arguments
tshepang Mar 29, 2025
70cbe19
Merge pull request #2288 from rust-lang/tshepang-known-bug-takes-args
jieyouxu Mar 29, 2025
9448b79
Merge pull request #2289 from y1lan/fix_compiler_err_of_examples
tshepang Mar 29, 2025
1faf7ff
update rustc-{driver,interface} examples
tshepang Mar 29, 2025
904fedf
Merge pull request #2308 from rust-lang/update-examples
tshepang Mar 29, 2025
471a2a8
example assumes a static exists
tshepang Mar 29, 2025
69f51ea
Merge pull request #2309 from rust-lang/restore-static
tshepang Mar 29, 2025
9302f4d
add rustfmt settings file
tshepang Mar 29, 2025
a27ec85
Merge pull request #2310 from rust-lang/add-rustfmt-file
jieyouxu Mar 30, 2025
ebae4c6
Fix partial clone link
clubby789 Mar 30, 2025
9f8e25f
Merge pull request #2311 from clubby789/partial-clone-link
jieyouxu Mar 30, 2025
59ca767
slice: Remove some uses of unsafe in first/last chunk methods
okaneco Mar 29, 2025
39a491a
unstable book: document import_trait_associated_functions
mejrs Mar 30, 2025
05d5fda
Preparing for merge from rustc
jieyouxu Apr 2, 2025
cae5d8a
Merge from rustc
jieyouxu Apr 2, 2025
ead4d4c
Merge pull request #2313 from jieyouxu/rustc-pull
jieyouxu Apr 2, 2025
072aa9e
Apply requested API changes to `cell_update`
tgross35 Apr 2, 2025
33c1ff0
rustdoc: make settings checkboxes always square
lolbinarycat Apr 2, 2025
14e6a96
Mark super_let feature as incomplete.
m-ou-se Apr 2, 2025
62fcb9d
Fix the `f16`/`f128` feature gate on integer literals
beetrees Apr 3, 2025
dbd7f52
Rollup merge of #139080 - m-ou-se:super-let-gate, r=traviscross
matthiaskrgr Apr 3, 2025
e332aa8
Rollup merge of #139145 - okaneco:safe_splits, r=Amanieu
matthiaskrgr Apr 3, 2025
ee56188
Rollup merge of #139149 - mejrs:itaf, r=ehuss
matthiaskrgr Apr 3, 2025
184e4ba
Rollup merge of #139273 - tgross35:cell-update-changes, r=jhpratt
matthiaskrgr Apr 3, 2025
b5d5b6c
Rollup merge of #139282 - lolbinarycat:rustdoc-settings-checkbox-nosh…
matthiaskrgr Apr 3, 2025
85c557e
Rollup merge of #139283 - BoxyUwU:rdg-push, r=jieyouxu
matthiaskrgr Apr 3, 2025
29c0fe7
Rollup merge of #139294 - beetrees:fix-f16-f128-literal-feature-gate,…
matthiaskrgr Apr 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
23 changes: 13 additions & 10 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,17 +332,19 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
ast::ExprKind::TryBlock(_) => {
gate!(&self, try_blocks, e.span, "`try` expression is experimental");
}
ast::ExprKind::Lit(token::Lit { kind: token::LitKind::Float, suffix, .. }) => {
match suffix {
Some(sym::f16) => {
gate!(&self, f16, e.span, "the type `f16` is unstable")
}
Some(sym::f128) => {
gate!(&self, f128, e.span, "the type `f128` is unstable")
}
_ => (),
ast::ExprKind::Lit(token::Lit {
kind: token::LitKind::Float | token::LitKind::Integer,
suffix,
..
}) => match suffix {
Some(sym::f16) => {
gate!(&self, f16, e.span, "the type `f16` is unstable")
}
}
Some(sym::f128) => {
gate!(&self, f128, e.span, "the type `f128` is unstable")
}
_ => (),
},
_ => {}
}
visit::walk_expr(self, e)
Expand Down Expand Up @@ -511,6 +513,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
gate_all!(contracts, "contracts are incomplete");
gate_all!(contracts_internals, "contract internal machinery is for internal use only");
gate_all!(where_clause_attrs, "attributes in `where` clause are unstable");
gate_all!(super_let, "`super let` is experimental");

if !visitor.features.never_patterns() {
if let Some(spans) = spans.get(&sym::never_patterns) {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,8 @@ declare_features! (
(unstable, strict_provenance_lints, "1.61.0", Some(130351)),
/// Allows string patterns to dereference values to match them.
(unstable, string_deref_patterns, "1.67.0", Some(87121)),
/// Allows `super let` statements.
(incomplete, super_let, "CURRENT_RUSTC_VERSION", Some(139076)),
/// Allows subtrait items to shadow supertrait items.
(unstable, supertrait_item_shadowing, "1.86.0", Some(89151)),
/// Allows using `#[thread_local]` on `static` items.
Expand Down
15 changes: 14 additions & 1 deletion compiler/rustc_parse/src/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,20 @@ impl<'a> Parser<'a> {
});
}

let stmt = if self.token.is_keyword(kw::Let) {
let stmt = if self.token.is_keyword(kw::Super) && self.is_keyword_ahead(1, &[kw::Let]) {
self.collect_tokens(None, attrs, force_collect, |this, attrs| {
this.expect_keyword(exp!(Super))?;
this.psess.gated_spans.gate(sym::super_let, this.prev_token.span);
this.expect_keyword(exp!(Let))?;
let local = this.parse_local(attrs)?; // FIXME(mara): implement super let
let trailing = Trailing::from(capture_semi && this.token == token::Semi);
Ok((
this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Let(local)),
trailing,
UsePreAttrPos::No,
))
})?
} else if self.token.is_keyword(kw::Let) {
self.collect_tokens(None, attrs, force_collect, |this, attrs| {
this.expect_keyword(exp!(Let))?;
let local = this.parse_local(attrs)?;
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_parse/src/parser/token_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ pub enum TokenType {
KwSelfUpper,
KwStatic,
KwStruct,
KwSuper,
KwTrait,
KwTry,
KwType,
Expand Down Expand Up @@ -250,6 +251,7 @@ impl TokenType {
KwSelfUpper,
KwStatic,
KwStruct,
KwSuper,
KwTrait,
KwTry,
KwType,
Expand Down Expand Up @@ -324,6 +326,7 @@ impl TokenType {
TokenType::KwSelfUpper => Some(kw::SelfUpper),
TokenType::KwStatic => Some(kw::Static),
TokenType::KwStruct => Some(kw::Struct),
TokenType::KwSuper => Some(kw::Super),
TokenType::KwTrait => Some(kw::Trait),
TokenType::KwTry => Some(kw::Try),
TokenType::KwType => Some(kw::Type),
Expand Down Expand Up @@ -549,6 +552,7 @@ macro_rules! exp {
(SelfUpper) => { exp!(@kw, SelfUpper, KwSelfUpper) };
(Static) => { exp!(@kw, Static, KwStatic) };
(Struct) => { exp!(@kw, Struct, KwStruct) };
(Super) => { exp!(@kw, Super, KwSuper) };
(Trait) => { exp!(@kw, Trait, KwTrait) };
(Try) => { exp!(@kw, Try, KwTry) };
(Type) => { exp!(@kw, Type, KwType) };
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2040,6 +2040,7 @@ symbols! {
sub_assign,
sub_with_overflow,
suggestion,
super_let,
supertrait_item_shadowing,
surface_async_drop_in_place,
sym,
Expand Down
15 changes: 4 additions & 11 deletions library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ impl<T: Copy> Cell<T> {
unsafe { *self.value.get() }
}

/// Updates the contained value using a function and returns the new value.
/// Updates the contained value using a function.
///
/// # Examples
///
Expand All @@ -554,21 +554,14 @@ impl<T: Copy> Cell<T> {
/// use std::cell::Cell;
///
/// let c = Cell::new(5);
/// let new = c.update(|x| x + 1);
///
/// assert_eq!(new, 6);
/// c.update(|x| x + 1);
/// assert_eq!(c.get(), 6);
/// ```
#[inline]
#[unstable(feature = "cell_update", issue = "50186")]
pub fn update<F>(&self, f: F) -> T
where
F: FnOnce(T) -> T,
{
pub fn update(&self, f: impl FnOnce(T) -> T) {
let old = self.get();
let new = f(old);
self.set(new);
new
self.set(f(old));
}
}

Expand Down
94 changes: 34 additions & 60 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,11 @@ impl<T> [T] {
#[stable(feature = "slice_first_last_chunk", since = "1.77.0")]
#[rustc_const_stable(feature = "slice_first_last_chunk", since = "1.77.0")]
pub const fn split_first_chunk<const N: usize>(&self) -> Option<(&[T; N], &[T])> {
if self.len() < N {
None
} else {
// SAFETY: We manually verified the bounds of the split.
let (first, tail) = unsafe { self.split_at_unchecked(N) };
let Some((first, tail)) = self.split_at_checked(N) else { return None };

// SAFETY: We explicitly check for the correct number of elements,
// and do not let the references outlive the slice.
Some((unsafe { &*(first.as_ptr().cast::<[T; N]>()) }, tail))
}
// SAFETY: We explicitly check for the correct number of elements,
// and do not let the references outlive the slice.
Some((unsafe { &*(first.as_ptr().cast::<[T; N]>()) }, tail))
}

/// Returns a mutable array reference to the first `N` items in the slice and the remaining
Expand Down Expand Up @@ -419,17 +414,12 @@ impl<T> [T] {
pub const fn split_first_chunk_mut<const N: usize>(
&mut self,
) -> Option<(&mut [T; N], &mut [T])> {
if self.len() < N {
None
} else {
// SAFETY: We manually verified the bounds of the split.
let (first, tail) = unsafe { self.split_at_mut_unchecked(N) };
let Some((first, tail)) = self.split_at_mut_checked(N) else { return None };

// SAFETY: We explicitly check for the correct number of elements,
// do not let the reference outlive the slice,
// and enforce exclusive mutability of the chunk by the split.
Some((unsafe { &mut *(first.as_mut_ptr().cast::<[T; N]>()) }, tail))
}
// SAFETY: We explicitly check for the correct number of elements,
// do not let the reference outlive the slice,
// and enforce exclusive mutability of the chunk by the split.
Some((unsafe { &mut *(first.as_mut_ptr().cast::<[T; N]>()) }, tail))
}

/// Returns an array reference to the last `N` items in the slice and the remaining slice.
Expand All @@ -452,16 +442,12 @@ impl<T> [T] {
#[stable(feature = "slice_first_last_chunk", since = "1.77.0")]
#[rustc_const_stable(feature = "slice_first_last_chunk", since = "1.77.0")]
pub const fn split_last_chunk<const N: usize>(&self) -> Option<(&[T], &[T; N])> {
if self.len() < N {
None
} else {
// SAFETY: We manually verified the bounds of the split.
let (init, last) = unsafe { self.split_at_unchecked(self.len() - N) };
let Some(index) = self.len().checked_sub(N) else { return None };
let (init, last) = self.split_at(index);

// SAFETY: We explicitly check for the correct number of elements,
// and do not let the references outlive the slice.
Some((init, unsafe { &*(last.as_ptr().cast::<[T; N]>()) }))
}
// SAFETY: We explicitly check for the correct number of elements,
// and do not let the references outlive the slice.
Some((init, unsafe { &*(last.as_ptr().cast::<[T; N]>()) }))
}

/// Returns a mutable array reference to the last `N` items in the slice and the remaining
Expand Down Expand Up @@ -489,17 +475,13 @@ impl<T> [T] {
pub const fn split_last_chunk_mut<const N: usize>(
&mut self,
) -> Option<(&mut [T], &mut [T; N])> {
if self.len() < N {
None
} else {
// SAFETY: We manually verified the bounds of the split.
let (init, last) = unsafe { self.split_at_mut_unchecked(self.len() - N) };
let Some(index) = self.len().checked_sub(N) else { return None };
let (init, last) = self.split_at_mut(index);

// SAFETY: We explicitly check for the correct number of elements,
// do not let the reference outlive the slice,
// and enforce exclusive mutability of the chunk by the split.
Some((init, unsafe { &mut *(last.as_mut_ptr().cast::<[T; N]>()) }))
}
// SAFETY: We explicitly check for the correct number of elements,
// do not let the reference outlive the slice,
// and enforce exclusive mutability of the chunk by the split.
Some((init, unsafe { &mut *(last.as_mut_ptr().cast::<[T; N]>()) }))
}

/// Returns an array reference to the last `N` items in the slice.
Expand All @@ -522,17 +504,13 @@ impl<T> [T] {
#[stable(feature = "slice_first_last_chunk", since = "1.77.0")]
#[rustc_const_stable(feature = "const_slice_last_chunk", since = "1.80.0")]
pub const fn last_chunk<const N: usize>(&self) -> Option<&[T; N]> {
if self.len() < N {
None
} else {
// SAFETY: We manually verified the bounds of the slice.
// FIXME(const-hack): Without const traits, we need this instead of `get_unchecked`.
let last = unsafe { self.split_at_unchecked(self.len() - N).1 };
// FIXME(const-hack): Without const traits, we need this instead of `get`.
let Some(index) = self.len().checked_sub(N) else { return None };
let (_, last) = self.split_at(index);

// SAFETY: We explicitly check for the correct number of elements,
// and do not let the references outlive the slice.
Some(unsafe { &*(last.as_ptr().cast::<[T; N]>()) })
}
// SAFETY: We explicitly check for the correct number of elements,
// and do not let the references outlive the slice.
Some(unsafe { &*(last.as_ptr().cast::<[T; N]>()) })
}

/// Returns a mutable array reference to the last `N` items in the slice.
Expand All @@ -556,18 +534,14 @@ impl<T> [T] {
#[stable(feature = "slice_first_last_chunk", since = "1.77.0")]
#[rustc_const_stable(feature = "const_slice_first_last_chunk", since = "1.83.0")]
pub const fn last_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]> {
if self.len() < N {
None
} else {
// SAFETY: We manually verified the bounds of the slice.
// FIXME(const-hack): Without const traits, we need this instead of `get_unchecked`.
let last = unsafe { self.split_at_mut_unchecked(self.len() - N).1 };

// SAFETY: We explicitly check for the correct number of elements,
// do not let the reference outlive the slice,
// and require exclusive access to the entire slice to mutate the chunk.
Some(unsafe { &mut *(last.as_mut_ptr().cast::<[T; N]>()) })
}
// FIXME(const-hack): Without const traits, we need this instead of `get`.
let Some(index) = self.len().checked_sub(N) else { return None };
let (_, last) = self.split_at_mut(index);

// SAFETY: We explicitly check for the correct number of elements,
// do not let the reference outlive the slice,
// and require exclusive access to the entire slice to mutate the chunk.
Some(unsafe { &mut *(last.as_mut_ptr().cast::<[T; N]>()) })
}

/// Returns a reference to an element or subslice depending on the type of
Expand Down
4 changes: 2 additions & 2 deletions library/coretests/tests/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ fn smoketest_cell() {
fn cell_update() {
let x = Cell::new(10);

assert_eq!(x.update(|x| x + 5), 15);
x.update(|x| x + 5);
assert_eq!(x.get(), 15);

assert_eq!(x.update(|x| x / 3), 5);
x.update(|x| x / 3);
assert_eq!(x.get(), 5);
}

Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc-dev-guide/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
MDBOOK_LINKCHECK2_VERSION: 0.9.1
MDBOOK_MERMAID_VERSION: 0.12.6
MDBOOK_TOC_VERSION: 0.11.2
MDBOOK_OUTPUT__LINKCHECK__FOLLOW_WEB_LINKS: ${{ github.event_name != 'pull_request' }}
DEPLOY_DIR: book/html
BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 3 additions & 1 deletion src/doc/rustc-dev-guide/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@ warning-policy = "error"
"/diagnostics/sessiondiagnostic.html" = "diagnostic-structs.html"
"/diagnostics/diagnostic-codes.html" = "error-codes.html"
"/miri.html" = "const-eval/interpret.html"
"/tests/integration.html" = "ecosystem.html"
"/tests/fuchsia.html" = "ecosystem-test-jobs/fuchsia.html"
"/tests/headers.html" = "directives.html"
"/tests/integration.html" = "ecosystem.html"
"/tests/rust-for-linux.html" = "ecosystem-test-jobs/rust-for-linux.html"
Loading
Loading