Rust 1.73.0 upgrade
Subsystems (3)
Miguel Ojeda
maintainercover Rust 1.73.0 upgrade
This is the next upgrade to the Rust toolchain since the initial Rust merge, from 1.72.1 to 1.73.0 (i.e. the latest, released today).
Please see the main patch message for a long explanation of the upgrade, the policy for future upgrades and some indications on how to easily review this.
The series is based on rust-next.
Miguel Ojeda (3):
rust: task: remove redundant explicit link
rust: print: use explicit link in documentation
rust: upgrade to Rust 1.73.0
Documentation/process/changes.rst | 2 +- rust/alloc/alloc.rs | 22 -------------- rust/alloc/boxed.rs | 48 ++++++++++++++++++++----------- rust/alloc/lib.rs | 5 ++-- rust/alloc/raw_vec.rs | 30 ++++++++++++------- rust/alloc/vec/mod.rs | 4 +-- rust/alloc/vec/spec_extend.rs | 8 +++--- rust/compiler_builtins.rs | 1 + rust/kernel/print.rs | 1 + rust/kernel/task.rs | 2 +- scripts/min-tool-version.sh | 2 +- 11 files changed, 65 insertions(+), 60 deletions(-)
base-commit: b2516f7af9d238ebc391bdbdae01ac9528f1109e --
2.42.0
Miguel Ojeda
maintainerPATCH 1/3 rust: task: remove redundant explicit link
Starting with Rust 1.73.0, rustdoc detects redundant explicit links with its new lint redundant_explicit_links [1]:
error: redundant explicit link target
--> rust/kernel/task.rs:85:21
|
85 | /// [current](crate::current) macro because it is safe.
| --------- ^^^^^^^^^^^^^^ explicit target is redundant
| |
| because label contains path that resolves to same destination
|
= note: when a link's destination is not specified,
the label is used to resolve intra-doc links
= note: -D rustdoc::redundant-explicit-links implied by -D warnings
help: remove explicit link target
|
85 | /// [current] macro because it is safe.
In order to avoid the warning in the compiler upgrade commit, make it an intra-doc link as the tool suggests.
--- rust/kernel/task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rust/kernel/task.rs +1 -1
@@ -82,7 +82,7 @@ impl Task {/// Returns a task reference for the currently executing task/thread. /// /// The recommended way to get the current task/thread is to use the -/// [`current`](crate::current) macro because it is safe. +/// [`current`] macro because it is safe. /// /// # Safety ///
Signature · 1 line
2.42.0
Miguel Ojeda
maintainerPATCH 2/3 rust: print: use explicit link in documentation
In reply to Miguel OjedaThe future rustdoc in the Rust 1.73.0 upgrade requires an explicit link for pr_info!:
error: unresolved link to pr_info
--> rust/kernel/print.rs:395:63
|
395 | /// Use only when continuing a previous pr_*! macro (e.g. [pr_info!]).
| ^^^^^^^^ no item named pr_info in scope
|
= note: macro_rules named pr_info exists in this crate, but it is not in scope at this link's location = note: -D rustdoc::broken-intra-doc-links implied by -D warnings
Thus do so to avoid a broken link while upgrading.
--- rust/kernel/print.rs | 1 + 1 file changed, 1 insertion(+)
rust/kernel/print.rs +1 -0
@@ -399,6 +399,7 @@ macro_rules! pr_debug (/// Mimics the interface of [`std::print!`]. See [`core::fmt`] and /// `alloc::format!` for information about the formatting syntax. /// +/// [`pr_info!`]: crate::pr_info! /// [`pr_cont`]: https://www.kernel.org/doc/html/latest/core-api/printk-basics.html#c.pr_cont /// [`std::print!`]: https://doc.rust-lang.org/std/macro.print.html ///
Signature · 1 line
2.42.0
Miguel Ojeda
maintainerPATCH 3/3 rust: upgrade to Rust 1.73.0
In reply to Miguel OjedaThis is the next upgrade to the Rust toolchain, from 1.72.1 to 1.73.0 (i.e. the latest) [1].
See the upgrade policy [2] and the comments on the first upgrade in commit 3ed03f4da06e ("rust: upgrade to Rust 1.68.2").
# Unstable features
No unstable features (that we use) were stabilized.
Therefore, the only unstable feature allowed to be used outside the kernel crate is still new_uninit, though other code to be upstreamed may increase the list.
Please see [3] for details.
# Required changes
For the upgrade, the following changes are required:
- Allow internal_features for feature(compiler_builtins) since now Rust warns about using internal compiler and standard library features (similar to how it also warns about incomplete ones) [4].
- A cleanup for a documentation link thanks to a new rustdoc lint. See previous commits for details.
- A need to make an intra-doc link to a macro explicit, due to a change in behavior in rustdoc. See previous commits for details.
# alloc upgrade and reviewing
The vast majority of changes are due to our alloc fork being upgraded at once.
There are two kinds of changes to be aware of: the ones coming from upstream, which we should follow as closely as possible, and the updates needed in our added fallible APIs to keep them matching the newer infallible APIs coming from upstream.
Instead of taking a look at the diff of this patch, an alternative approach is reviewing a diff of the changes between upstream alloc and the kernel's. This allows to easily inspect the kernel additions only, especially to check if the fallible methods we already have still match the infallible ones in the new version coming from upstream.
Another approach is reviewing the changes introduced in the additions in the kernel fork between the two versions. This is useful to spot potentially unintended changes to our additions.
To apply these approaches, one may follow steps similar to the following to generate a pair of patches that show the differences between upstream Rust and the kernel (for the subset of alloc we use) before and after applying this patch:
# Get the difference with respect to the old version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc) git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
cut -d/ -f3- |
grep -Fv README.md |
xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > old.patch git -C linux restore rust/alloc
# Apply this patch.
git -C linux am rust-upgrade.patch
# Get the difference with respect to the new version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc) git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
cut -d/ -f3- |
grep -Fv README.md |
xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > new.patch git -C linux restore rust/alloc
Now one may check the new.patch to take a look at the additions (first approach) or at the difference between those two patches (second approach). For the latter, a side-by-side tool is recommended.
--- Documentation/process/changes.rst | 2 +- rust/alloc/alloc.rs | 22 -------------- rust/alloc/boxed.rs | 48 ++++++++++++++++++++----------- rust/alloc/lib.rs | 5 ++-- rust/alloc/raw_vec.rs | 30 ++++++++++++------- rust/alloc/vec/mod.rs | 4 +-- rust/alloc/vec/spec_extend.rs | 8 +++--- rust/compiler_builtins.rs | 1 + scripts/min-tool-version.sh | 2 +- 9 files changed, 63 insertions(+), 59 deletions(-)
Documentation/process/changes.rst +1 -1
@@ -31,7 +31,7 @@ you probably needn't concern yourself with pcmciautils. ====================== =============== ======================================== GNU C 5.1 gcc --version Clang/LLVM (optional) 11.0.0 clang --version -Rust (optional) 1.72.1 rustc --version +Rust (optional) 1.73.0 rustc --version bindgen (optional) 0.65.1 bindgen --version GNU make 3.82 make --version bash 4.2 bash --version
rust/alloc/alloc.rs +0 -22
@@ -6,11 +6,7 @@#[cfg(not(test))] use core::intrinsics; -#[cfg(all(bootstrap, not(test)))] -use core::intrinsics::{min_align_of_val, size_of_val}; -#[cfg(all(bootstrap, not(test)))] -use core::ptr::Unique ;#[cfg(not(test))] use core::ptr::{self,NonNull };
@@ -339,23 +335,6 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 { } } -#[cfg(all(bootstrap, not(test)))] -#[lang = "box_free" ] -#[inline] -// This signature has to be the same as `Box`, otherwise an ICE will happen. -// When an additional parameter to `Box` is added (like `A: Allocator`), this has to be added here as -// well. -// For example if `Box` is changed to `struct Box<T: ?Sized, A: Allocator>(Unique<T>, A)`, -// this function has to be changed to `fn box_free<T: ?Sized, A: Allocator>(Unique<T>, A)` as well. -unsafe fn box_free <T : ?Sized ,A :Allocator >(ptr:Unique <T >, alloc:A ) { -unsafe { -let size =size_of_val (ptr.as_ref ()); -let align =min_align_of_val (ptr.as_ref ()); -let layout =Layout ::from_size_align_unchecked (size, align); - alloc.deallocate (From ::from (ptr.cast ()), layout) - } -} -// # Allocation error handler #[cfg(not(no_global_oom_handling))]
@@ -415,7 +394,6 @@ pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {static __rust_alloc_error_handler_should_panic:u8 ; } -#[allow(unused_unsafe)] if unsafe { __rust_alloc_error_handler_should_panic !=0 } {panic! ("memory allocation of {size} bytes failed" ) }else {
rust/alloc/boxed.rs +31 -17
108 lines not on this page · raw message
rust/alloc/lib.rs +3 -2
@@ -60,7 +60,7 @@// To run alloc tests without x.py without ending up with two copies of alloc, Miri needs to be // able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>. -// rustc itself never sets the feature, so this line has no affect there. +// rustc itself never sets the feature, so this line has no effect there. #![cfg(any(not(feature = "miri-test-libstd" ), test, doctest))] // #![allow(unused_attributes)]
@@ -90,6 +90,8 @@#![warn(missing_docs)] #![allow(explicit_outlives_requirements)] #![warn(multiple_supertrait_upcastable)] +#![cfg_attr(not(bootstrap), allow(internal_features))] +#![cfg_attr(not(bootstrap), allow(rustdoc::redundant_explicit_links))] // // Library features: // tidy-alphabetical-start
@@ -139,7 +141,6 @@#![feature(maybe_uninit_uninit_array_transpose)] #![feature(pattern)] #![feature(pointer_byte_offsets)] -#![feature(provide_any)] #![feature(ptr_internals)] #![feature(ptr_metadata)] #![feature(ptr_sub_ptr)]
rust/alloc/raw_vec.rs +20 -10
@@ -471,16 +471,26 @@ fn shrink(&mut self, cap: usize) -> Result<(), TryReserveError> {let (ptr, layout) =if let Some (mem) = self.current_memory () { mem }else {return Ok (()) };// See current_memory() why this assert is here let _: () =const {assert! (mem::size_of ::<T >() % mem::align_of ::<T >() ==0 ) }; -let ptr =unsafe { -// `Layout::array` cannot overflow here because it would have -// overflowed earlier when capacity was larger. -let new_size = mem::size_of ::<T >().unchecked_mul (cap); -let new_layout =Layout ::from_size_align_unchecked (new_size, layout.align ()); - self.alloc - .shrink (ptr, layout, new_layout) - .map_err (|_|AllocError { layout: new_layout, non_exhaustive: () })? - }; - self.set_ptr_and_cap (ptr, cap); + +// If shrinking to 0, deallocate the buffer. We don't reach this point +// for the T::IS_ZST case since current_memory() will have returned +// None. +if cap ==0 { +unsafe { self.alloc.deallocate (ptr, layout) }; + self.ptr =Unique ::dangling (); + self.cap =0 ; + }else { +let ptr =unsafe { +// `Layout::array` cannot overflow here because it would have +// overflowed earlier when capacity was larger. +let new_size = mem::size_of ::<T >().unchecked_mul (cap); +let new_layout =Layout ::from_size_align_unchecked (new_size, layout.align ()); + self.alloc + .shrink (ptr, layout, new_layout) + .map_err (|_|AllocError { layout: new_layout, non_exhaustive: () })? + }; + self.set_ptr_and_cap (ptr, cap); + }Ok (()) } }
rust/alloc/vec/mod.rs +2 -2
@@ -216,7 +216,7 @@/// /// # Indexing /// -/// The `Vec` type allows to access values by index, because it implements the +/// The `Vec` type allows access to values by index, because it implements the /// [`Index`] trait. An example will be more explicit: /// /// ```
@@ -3263,7 +3263,7 @@ pub fn extract_if<F>(&mut self, filter: F) -> ExtractIf<'_, T, F, A>/// [`copy_from_slice`]: slice::copy_from_slice #[cfg(not(no_global_oom_handling))] #[stable(feature = "extend_ref" , since = "1.2.0" )] -impl <'a,T :Copy + 'a,A :Allocator + 'a>Extend <&'aT >for Vec <T ,A > { +impl <'a,T :Copy + 'a,A :Allocator >Extend <&'aT >for Vec <T ,A > {fn extend <I :IntoIterator <Item = &'aT >>(&mut self, iter:I ) { self.spec_extend (iter.into_iter ()) }
rust/alloc/vec/spec_extend.rs +4 -4
@@ -77,7 +77,7 @@ fn try_spec_extend(&mut self, mut iterator: IntoIter<T>) -> Result<(), TryReserv }#[cfg(not(no_global_oom_handling))] -impl <'a,T : 'a,I ,A :Allocator + 'a>SpecExtend <&'aT ,I >for Vec <T ,A > +impl <'a,T : 'a,I ,A :Allocator >SpecExtend <&'aT ,I >for Vec <T ,A >where I :Iterator <Item = &'aT >,T :Clone ,
@@ -87,7 +87,7 @@ impl<'a, T: 'a, I, A: Allocator + 'a> SpecExtend<&'a T, I> for Vec<T, A> } } -impl <'a,T : 'a,I ,A :Allocator + 'a>TrySpecExtend <&'aT ,I >for Vec <T ,A > +impl <'a,T : 'a,I ,A :Allocator >TrySpecExtend <&'aT ,I >for Vec <T ,A >where I :Iterator <Item = &'aT >,T :Clone ,
@@ -98,7 +98,7 @@ impl<'a, T: 'a, I, A: Allocator + 'a> TrySpecExtend<&'a T, I> for Vec<T, A> }#[cfg(not(no_global_oom_handling))] -impl <'a,T : 'a,A :Allocator + 'a>SpecExtend <&'aT , slice::Iter <'a,T >>for Vec <T ,A > +impl <'a,T : 'a,A :Allocator >SpecExtend <&'aT , slice::Iter <'a,T >>for Vec <T ,A >where T :Copy , {
@@ -108,7 +108,7 @@ fn spec_extend(&mut self, iterator: slice::Iter<'a, T>) { } } -impl <'a,T : 'a,A :Allocator + 'a>TrySpecExtend <&'aT , slice::Iter <'a,T >>for Vec <T ,A > +impl <'a,T : 'a,A :Allocator >TrySpecExtend <&'aT , slice::Iter <'a,T >>for Vec <T ,A >where T :Copy , {
rust/compiler_builtins.rs +1 -0
@@ -19,6 +19,7 @@//! [`compiler_builtins`]: https://github.com/rust-lang/compiler-builtins //! [`compiler-rt`]: https://compiler-rt.llvm.org/ +#![allow(internal_features)] #![feature(compiler_builtins)] #![compiler_builtins] #![no_builtins]
scripts/min-tool-version.sh +1 -1
@@ -31,7 +31,7 @@ llvm) fi ;; rustc) - echo 1.72.1 + echo 1.73.0 ;; bindgen) echo 0.65.1
Signature · 1 line
2.42.0
Re: [PATCH 1/3] rust: task: remove redundant explicit link
In reply to Miguel OjedaQuoted 18 lines · Miguel Ojeda
Starting with Rust 1.73.0,
rustdocdetects redundant explicit links with its new lintredundant_explicit_links[1]:error: redundant explicit link target
-->rust/kernel/task.rs:85:21
|
85 | /// [current](crate::current) macro because it is safe.
| --------- ^^^^^^^^^^^^^^ explicit target is redundant
| |
| because label contains path that resolves to same destination
|
= note: when a link's destination is not specified,
the label is used to resolve intra-doc links
= note:-D rustdoc::redundant-explicit-linksimplied by-D warnings
help: remove explicit link target
|
85 | /// [current] macro because it is safe.
Quoted 7 lines
In order to avoid the warning in the compiler upgrade commit, make it an intra-doc link as the tool suggests.
Signed-off-by Miguel Ojeda <[email protected]>---
[...]
Re: [PATCH 2/3] rust: print: use explicit link in documentation
In reply to Miguel OjedaQuoted 12 lines · Miguel Ojeda
The future
rustdocin the Rust 1.73.0 upgrade requires an explicit link forpr_info!:error: unresolved link to
pr_info
-->rust/kernel/print.rs:395:63
|
395 | /// Use only when continuing a previouspr_*!macro (e.g. [pr_info!]).
| ^^^^^^^^ no item namedpr_infoin scope
|
= note:macro_rulesnamedpr_infoexists in this crate, but it is not in scope at this link's location = note:-D rustdoc::broken-intra-doc-linksimplied by-D warnings
Quoted 5 lines
Thus do so to avoid a broken link while upgrading.
Signed-off-by Miguel Ojeda <[email protected]>---
[...]
Re: [PATCH 3/3] rust: upgrade to Rust 1.73.0
In reply to Miguel OjedaQuoted 80 lines · Miguel Ojeda
This is the next upgrade to the Rust toolchain, from 1.72.1 to 1.73.0 (i.e. the latest) [1].
See the upgrade policy [2] and the comments on the first upgrade in commit
3ed03f4da06e("rust: upgrade to Rust 1.68.2").# Unstable features
No unstable features (that we use) were stabilized.
Therefore, the only unstable feature allowed to be used outside the
kernelcrate is stillnew_uninit, though other code to be upstreamed may increase the list.Please see [3] for details.
# Required changes
For the upgrade, the following changes are required:
- Allow
internal_featuresforfeature(compiler_builtins)since now Rust warns about using internal compiler and standard library features (similar to how it also warns about incomplete ones) [4].- A cleanup for a documentation link thanks to a new
rustdoclint. See previous commits for details.- A need to make an intra-doc link to a macro explicit, due to a change in behavior in
rustdoc. See previous commits for details.#
allocupgrade and reviewingThe vast majority of changes are due to our
allocfork being upgraded at once.There are two kinds of changes to be aware of: the ones coming from upstream, which we should follow as closely as possible, and the updates needed in our added fallible APIs to keep them matching the newer infallible APIs coming from upstream.
Instead of taking a look at the diff of this patch, an alternative approach is reviewing a diff of the changes between upstream
allocand the kernel's. This allows to easily inspect the kernel additions only, especially to check if the fallible methods we already have still match the infallible ones in the new version coming from upstream.Another approach is reviewing the changes introduced in the additions in the kernel fork between the two versions. This is useful to spot potentially unintended changes to our additions.
To apply these approaches, one may follow steps similar to the following to generate a pair of patches that show the differences between upstream Rust and the kernel (for the subset of
allocwe use) before and after applying this patch:# Get the difference with respect to the old version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc) git -C linux ls-tree -r --name-only HEAD --rust/alloc|
cut -d/ -f3- |
grep -Fv README.md |
xargs -IPATH cprust/library/alloc/src/PATHlinux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > old.patch git -C linux restorerust/alloc# Apply this patch.
git -C linux am rust-upgrade.patch# Get the difference with respect to the new version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc) git -C linux ls-tree -r --name-only HEAD --rust/alloc|
cut -d/ -f3- |
grep -Fv README.md |
xargs -IPATH cprust/library/alloc/src/PATHlinux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > new.patch git -C linux restorerust/allocNow one may check the
new.patchto take a look at the additions (first approach) or at the difference between those two patches (second approach). For the latter, a side-by-side tool is recommended.
Quoted 7 lines
Signed-off-by Miguel Ojeda <[email protected]>---
[...]
Re: [PATCH 2/3] rust: print: use explicit link in documentation
In reply to Miguel OjedaQuoted 12 lines · Miguel Ojeda
The future
rustdocin the Rust 1.73.0 upgrade requires an explicit link forpr_info!:error: unresolved link to
pr_info
-->rust/kernel/print.rs:395:63
|
395 | /// Use only when continuing a previouspr_*!macro (e.g. [pr_info!]).
| ^^^^^^^^ no item namedpr_infoin scope
|
= note:macro_rulesnamedpr_infoexists in this crate, but it is not in scope at this link's location = note:-D rustdoc::broken-intra-doc-linksimplied by-D warnings
Quoted 4 lines
Thus do so to avoid a broken link while upgrading.
Signed-off-by Miguel Ojeda <[email protected]>---
Re: [PATCH 1/3] rust: task: remove redundant explicit link
In reply to Miguel OjedaQuoted 18 lines · Miguel Ojeda
Starting with Rust 1.73.0,
rustdocdetects redundant explicit links with its new lintredundant_explicit_links[1]:error: redundant explicit link target
-->rust/kernel/task.rs:85:21
|
85 | /// [current](crate::current) macro because it is safe.
| --------- ^^^^^^^^^^^^^^ explicit target is redundant
| |
| because label contains path that resolves to same destination
|
= note: when a link's destination is not specified,
the label is used to resolve intra-doc links
= note:-D rustdoc::redundant-explicit-linksimplied by-D warnings
help: remove explicit link target
|
85 | /// [current] macro because it is safe.
Quoted 6 lines
In order to avoid the warning in the compiler upgrade commit, make it an intra-doc link as the tool suggests.
Signed-off-by Miguel Ojeda <[email protected]>---
Re: [PATCH 1/3] rust: task: remove redundant explicit link
In reply to Miguel OjedaQuoted 18 lines · Miguel Ojeda
Starting with Rust 1.73.0,
rustdocdetects redundant explicit links with its new lintredundant_explicit_links[1]:error: redundant explicit link target
-->rust/kernel/task.rs:85:21
|
85 | /// [current](crate::current) macro because it is safe.
| --------- ^^^^^^^^^^^^^^ explicit target is redundant
| |
| because label contains path that resolves to same destination
|
= note: when a link's destination is not specified,
the label is used to resolve intra-doc links
= note:-D rustdoc::redundant-explicit-linksimplied by-D warnings
help: remove explicit link target
|
85 | /// [current] macro because it is safe.
Quoted 5 lines
In order to avoid the warning in the compiler upgrade commit, make it an intra-doc link as the tool suggests.
Signed-off-by Miguel Ojeda <[email protected]>
Re: [PATCH 2/3] rust: print: use explicit link in documentation
In reply to Miguel OjedaQuoted 12 lines · Miguel Ojeda
The future
rustdocin the Rust 1.73.0 upgrade requires an explicit link forpr_info!:error: unresolved link to
pr_info
-->rust/kernel/print.rs:395:63
|
395 | /// Use only when continuing a previouspr_*!macro (e.g. [pr_info!]).
| ^^^^^^^^ no item namedpr_infoin scope
|
= note:macro_rulesnamedpr_infoexists in this crate, but it is not in scope at this link's location = note:-D rustdoc::broken-intra-doc-linksimplied by-D warnings
Quoted 3 lines
Thus do so to avoid a broken link while upgrading.
Signed-off-by Miguel Ojeda <[email protected]>
Re: [PATCH 3/3] rust: upgrade to Rust 1.73.0
In reply to Miguel OjedaQuoted 76 lines · Miguel Ojeda
This is the next upgrade to the Rust toolchain, from 1.72.1 to 1.73.0 (i.e. the latest) [1].
See the upgrade policy [2] and the comments on the first upgrade in commit
3ed03f4da06e("rust: upgrade to Rust 1.68.2").# Unstable features
No unstable features (that we use) were stabilized.
Therefore, the only unstable feature allowed to be used outside the
kernelcrate is stillnew_uninit, though other code to be upstreamed may increase the list.Please see [3] for details.
# Required changes
For the upgrade, the following changes are required:
- Allow
internal_featuresforfeature(compiler_builtins)since now Rust warns about using internal compiler and standard library features (similar to how it also warns about incomplete ones) [4].- A cleanup for a documentation link thanks to a new
rustdoclint. See previous commits for details.- A need to make an intra-doc link to a macro explicit, due to a change in behavior in
rustdoc. See previous commits for details.#
allocupgrade and reviewingThe vast majority of changes are due to our
allocfork being upgraded at once.There are two kinds of changes to be aware of: the ones coming from upstream, which we should follow as closely as possible, and the updates needed in our added fallible APIs to keep them matching the newer infallible APIs coming from upstream.
Instead of taking a look at the diff of this patch, an alternative approach is reviewing a diff of the changes between upstream
allocand the kernel's. This allows to easily inspect the kernel additions only, especially to check if the fallible methods we already have still match the infallible ones in the new version coming from upstream.Another approach is reviewing the changes introduced in the additions in the kernel fork between the two versions. This is useful to spot potentially unintended changes to our additions.
To apply these approaches, one may follow steps similar to the following to generate a pair of patches that show the differences between upstream Rust and the kernel (for the subset of
allocwe use) before and after applying this patch:# Get the difference with respect to the old version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc) git -C linux ls-tree -r --name-only HEAD --rust/alloc|
cut -d/ -f3- |
grep -Fv README.md |
xargs -IPATH cprust/library/alloc/src/PATHlinux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > old.patch git -C linux restorerust/alloc# Apply this patch.
git -C linux am rust-upgrade.patch# Get the difference with respect to the new version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc) git -C linux ls-tree -r --name-only HEAD --rust/alloc|
cut -d/ -f3- |
grep -Fv README.md |
xargs -IPATH cprust/library/alloc/src/PATHlinux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > new.patch git -C linux restorerust/alloc
Quoted 3 lines
Now one may check the
new.patchto take a look at the additions (first approach) or at the difference between those two patches (second approach). For the latter, a side-by-side tool is recommended.
I followed these instructions, and it looks good to me:
$ diff old.patch new.patch
18c18
< index e24a0fe51bda..51821feb20b1 100644
---Quoted 1 line
index
5205ed9fb50a..8cb4a31cf6e5100644
28c28
< index 8ef2bac9282c..bdab710f7737 100644
---
> index 96b93830f960..9620eba17268 100644
60c60
< index 967ad3a0e690..115fcb053e73 100644
---
> index ffe6d6373875..73b9ffd845d9 100644
69c69
< @@ -107,7 +109,7 @@
---
> @@ -109,7 +111,7 @@
78c78
< @@ -217,6 +219,7 @@
---
> @@ -218,6 +220,7 @@
86c86
< @@ -237,15 +240,19 @@
---
> @@ -238,15 +241,19 @@
107c107
< index dfd30d99cf04..65d5ce15828e 100644
---
> index 01b03de6acb5..a7425582a323 100644
238c238
< index 598ecf05e824..a4e9a5002a6d 100644
---
> index e45ddc7896be..209a88cfe598 100644
679c679
< index 56065ce565bf..a6a735201e59 100644
---
> index e2f865d0f716..ada919537446 100644
756c756
< impl<'a, T: 'a, I, A: Allocator + 'a> SpecExtend<&'a T, I> for Vec<T, A>
---
> impl<'a, T: 'a, I, A: Allocator> SpecExtend<&'a T, I> for Vec<T, A>
759c759
< @@ -46,6 +87,17 @@ impl<'a, T: 'a, I, A: Allocator + 'a> SpecExtend<&'a T, I> for Vec<T, A>
---
> @@ -46,6 +87,17 @@ impl<'a, T: 'a, I, A: Allocator> SpecExtend<&'a T, I> for Vec<T, A>
763c763
< +impl<'a, T: 'a, I, A: Allocator + 'a> TrySpecExtend<&'a T, I> for Vec<T, A>
---
> +impl<'a, T: 'a, I, A: Allocator> TrySpecExtend<&'a T, I> for Vec<T, A>
774c774
< impl<'a, T: 'a, A: Allocator + 'a> SpecExtend<&'a T, slice::Iter<'a, T>> for Vec<T, A>
---
> impl<'a, T: 'a, A: Allocator> SpecExtend<&'a T, slice::Iter<'a, T>> for Vec<T, A>
782c782
< +impl<'a, T: 'a, A: Allocator + 'a> TrySpecExtend<&'a T, slice::Iter<'a, T>> for Vec<T, A>
---
> +impl<'a, T: 'a, A: Allocator> TrySpecExtend<&'a T, slice::Iter<'a, T>> for Vec<T, A>Quoted 5 lines
Signed-off-by Miguel Ojeda <[email protected]>
Re: [PATCH 1/3] rust: task: remove redundant explicit link
In reply to Miguel OjedaQuoted 18 lines
Starting with Rust 1.73.0,
rustdocdetects redundant explicit links with its new lintredundant_explicit_links[1]:error: redundant explicit link target
-->rust/kernel/task.rs:85:21
|
85 | /// [current](crate::current) macro because it is safe.
| --------- ^^^^^^^^^^^^^^ explicit target is redundant
| |
| because label contains path that resolves to same destination
|
= note: when a link's destination is not specified,
the label is used to resolve intra-doc links
= note:-D rustdoc::redundant-explicit-linksimplied by-D warnings
help: remove explicit link target
|
85 | /// [current] macro because it is safe.
Quoted 6 lines
In order to avoid the warning in the compiler upgrade commit, make it an intra-doc link as the tool suggests.
Signed-off-by Miguel Ojeda <[email protected]>---
Re: [PATCH 2/3] rust: print: use explicit link in documentation
In reply to Miguel OjedaQuoted 12 lines
The future
rustdocin the Rust 1.73.0 upgrade requires an explicit link forpr_info!:error: unresolved link to
pr_info
-->rust/kernel/print.rs:395:63
|
395 | /// Use only when continuing a previouspr_*!macro (e.g. [pr_info!]).
| ^^^^^^^^ no item namedpr_infoin scope
|
= note:macro_rulesnamedpr_infoexists in this crate, but it is not in scope at this link's location = note:-D rustdoc::broken-intra-doc-linksimplied by-D warnings
Quoted 4 lines
Thus do so to avoid a broken link while upgrading.
Signed-off-by Miguel Ojeda <[email protected]>---
Re: [PATCH 3/3] rust: upgrade to Rust 1.73.0
In reply to Miguel OjedaQuoted 2 lines
The vast majority of changes are due to our
allocfork being upgraded at once.
Ah this is annoying sometimes :/
Quoted 65 lines
There are two kinds of changes to be aware of: the ones coming from upstream, which we should follow as closely as possible, and the updates needed in our added fallible APIs to keep them matching the newer infallible APIs coming from upstream.
Instead of taking a look at the diff of this patch, an alternative approach is reviewing a diff of the changes between upstream
allocand the kernel's. This allows to easily inspect the kernel additions only, especially to check if the fallible methods we already have still match the infallible ones in the new version coming from upstream.Another approach is reviewing the changes introduced in the additions in the kernel fork between the two versions. This is useful to spot potentially unintended changes to our additions.
To apply these approaches, one may follow steps similar to the following to generate a pair of patches that show the differences between upstream Rust and the kernel (for the subset of
allocwe use) before and after applying this patch:# Get the difference with respect to the old version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc) git -C linux ls-tree -r --name-only HEAD --rust/alloc|
cut -d/ -f3- |
grep -Fv README.md |
xargs -IPATH cprust/library/alloc/src/PATHlinux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > old.patch git -C linux restorerust/alloc# Apply this patch.
git -C linux am rust-upgrade.patch# Get the difference with respect to the new version.
git -C rust checkout $(linux/scripts/min-tool-version.sh rustc) git -C linux ls-tree -r --name-only HEAD --rust/alloc|
cut -d/ -f3- |
grep -Fv README.md |
xargs -IPATH cprust/library/alloc/src/PATHlinux/rust/alloc/PATH
git -C linux diff --patch-with-stat --summary -R > new.patch git -C linux restorerust/allocNow one may check the
new.patchto take a look at the additions (first approach) or at the difference between those two patches (second approach). For the latter, a side-by-side tool is recommended.Signed-off-by Miguel Ojeda <[email protected]>--- Documentation/process/changes.rst | 2 +- rust/alloc/alloc.rs | 22 -------------- rust/alloc/boxed.rs | 48 ++++++++++++++++++++----------- rust/alloc/lib.rs | 5 ++-- rust/alloc/raw_vec.rs | 30 ++++++++++++------- rust/alloc/vec/mod.rs | 4 +-- rust/alloc/vec/spec_extend.rs | 8 +++--- rust/compiler_builtins.rs | 1 + scripts/min-tool-version.sh | 2 +- 9 files changed, 63 insertions(+), 59 deletions(-)Documentation/process/changes.rst +0
-0
Documentation/process/changes.rst
Quoted 1 line
Documentation/process/changes.rst +0
-1--- a/Documentation/process/changes.rst
Miguel Ojeda
AppliedQuoted 9 lines · Miguel Ojeda
This is the next upgrade to the Rust toolchain since the initial Rust merge, from 1.72.1 to 1.73.0 (i.e. the latest, released today).
Please see the main patch message for a long explanation of the upgrade, the policy for future upgrades and some indications on how to easily review this.
The series is based on
rust-next.
Applied to rust-next -- thanks everyone!
Cheers,
Miguel