Skip to content

Commit 2da3cb9

Browse files
committed
Auto merge of rust-lang#131012 - GuillaumeGomez:rollup-e9ovh3a, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - rust-lang#130383 (check if it's rust-lang/rust CI job in `llvm::is_ci_llvm_modified`) - rust-lang#130416 (resolve rust-lang#130122: reword 'sort-by' edge-conditions documentation) - rust-lang#130537 (rustdoc: add doc comment to DocVisitor) - rust-lang#130743 (Clarifications for set_nonblocking methods) - rust-lang#131010 (extend comment in global_llvm_features regarding target-cpu=native) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 329e7b4 + e9c9307 commit 2da3cb9

File tree

9 files changed

+104
-37
lines changed

9 files changed

+104
-37
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+5
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,11 @@ pub(crate) fn global_llvm_features(
536536
// -Ctarget-cpu=native
537537
match sess.opts.cg.target_cpu {
538538
Some(ref s) if s == "native" => {
539+
// We have already figured out the actual CPU name with `LLVMRustGetHostCPUName` and set
540+
// that for LLVM, so the features implied by that CPU name will be available everywhere.
541+
// However, that is not sufficient: e.g. `skylake` alone is not sufficient to tell if
542+
// some of the instructions are available or not. So we have to also explicitly ask for
543+
// the exact set of features available on the host, and enable all of them.
539544
let features_string = unsafe {
540545
let ptr = llvm::LLVMGetHostCPUFeatures();
541546
let features_string = if !ptr.is_null() {

library/alloc/src/slice.rs

+47-20
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,9 @@ impl<T> [T] {
180180
/// This sort is stable (i.e., does not reorder equal elements) and *O*(*n* \* log(*n*))
181181
/// worst-case.
182182
///
183-
/// If the implementation of [`Ord`] for `T` does not implement a [total order] the resulting
184-
/// order of elements in the slice is unspecified. All original elements will remain in the
185-
/// slice and any possible modifications via interior mutability are observed in the input. Same
186-
/// is true if the implementation of [`Ord`] for `T` panics.
183+
/// If the implementation of [`Ord`] for `T` does not implement a [total order], the function
184+
/// may panic; even if the function exits normally, the resulting order of elements in the slice
185+
/// is unspecified. See also the note on panicking below.
187186
///
188187
/// When applicable, unstable sorting is preferred because it is generally faster than stable
189188
/// sorting and it doesn't allocate auxiliary memory. See
@@ -212,7 +211,15 @@ impl<T> [T] {
212211
///
213212
/// # Panics
214213
///
215-
/// May panic if the implementation of [`Ord`] for `T` does not implement a [total order].
214+
/// May panic if the implementation of [`Ord`] for `T` does not implement a [total order], or if
215+
/// the [`Ord`] implementation itself panics.
216+
///
217+
/// All safe functions on slices preserve the invariant that even if the function panics, all
218+
/// original elements will remain in the slice and any possible modifications via interior
219+
/// mutability are observed in the input. This ensures that recovery code (for instance inside
220+
/// of a `Drop` or following a `catch_unwind`) will still have access to all the original
221+
/// elements. For instance, if the slice belongs to a `Vec`, the `Vec::drop` method will be able
222+
/// to dispose of all contained elements.
216223
///
217224
/// # Examples
218225
///
@@ -241,10 +248,9 @@ impl<T> [T] {
241248
/// This sort is stable (i.e., does not reorder equal elements) and *O*(*n* \* log(*n*))
242249
/// worst-case.
243250
///
244-
/// If the comparison function `compare` does not implement a [total order] the resulting order
245-
/// of elements in the slice is unspecified. All original elements will remain in the slice and
246-
/// any possible modifications via interior mutability are observed in the input. Same is true
247-
/// if `compare` panics.
251+
/// If the comparison function `compare` does not implement a [total order], the function may
252+
/// panic; even if the function exits normally, the resulting order of elements in the slice is
253+
/// unspecified. See also the note on panicking below.
248254
///
249255
/// For example `|a, b| (a - b).cmp(a)` is a comparison function that is neither transitive nor
250256
/// reflexive nor total, `a < b < c < a` with `a = 1, b = 2, c = 3`. For more information and
@@ -263,7 +269,14 @@ impl<T> [T] {
263269
///
264270
/// # Panics
265271
///
266-
/// May panic if `compare` does not implement a [total order].
272+
/// May panic if `compare` does not implement a [total order], or if `compare` itself panics.
273+
///
274+
/// All safe functions on slices preserve the invariant that even if the function panics, all
275+
/// original elements will remain in the slice and any possible modifications via interior
276+
/// mutability are observed in the input. This ensures that recovery code (for instance inside
277+
/// of a `Drop` or following a `catch_unwind`) will still have access to all the original
278+
/// elements. For instance, if the slice belongs to a `Vec`, the `Vec::drop` method will be able
279+
/// to dispose of all contained elements.
267280
///
268281
/// # Examples
269282
///
@@ -295,10 +308,9 @@ impl<T> [T] {
295308
/// This sort is stable (i.e., does not reorder equal elements) and *O*(*m* \* *n* \* log(*n*))
296309
/// worst-case, where the key function is *O*(*m*).
297310
///
298-
/// If the implementation of [`Ord`] for `K` does not implement a [total order] the resulting
299-
/// order of elements in the slice is unspecified. All original elements will remain in the
300-
/// slice and any possible modifications via interior mutability are observed in the input. Same
301-
/// is true if the implementation of [`Ord`] for `K` panics.
311+
/// If the implementation of [`Ord`] for `K` does not implement a [total order], the function
312+
/// may panic; even if the function exits normally, the resulting order of elements in the slice
313+
/// is unspecified. See also the note on panicking below.
302314
///
303315
/// # Current implementation
304316
///
@@ -313,7 +325,15 @@ impl<T> [T] {
313325
///
314326
/// # Panics
315327
///
316-
/// May panic if the implementation of [`Ord`] for `K` does not implement a [total order].
328+
/// May panic if the implementation of [`Ord`] for `K` does not implement a [total order], or if
329+
/// the [`Ord`] implementation or the key-function `f` panics.
330+
///
331+
/// All safe functions on slices preserve the invariant that even if the function panics, all
332+
/// original elements will remain in the slice and any possible modifications via interior
333+
/// mutability are observed in the input. This ensures that recovery code (for instance inside
334+
/// of a `Drop` or following a `catch_unwind`) will still have access to all the original
335+
/// elements. For instance, if the slice belongs to a `Vec`, the `Vec::drop` method will be able
336+
/// to dispose of all contained elements.
317337
///
318338
/// # Examples
319339
///
@@ -347,10 +367,9 @@ impl<T> [T] {
347367
/// storage to remember the results of key evaluation. The order of calls to the key function is
348368
/// unspecified and may change in future versions of the standard library.
349369
///
350-
/// If the implementation of [`Ord`] for `K` does not implement a [total order] the resulting
351-
/// order of elements in the slice is unspecified. All original elements will remain in the
352-
/// slice and any possible modifications via interior mutability are observed in the input. Same
353-
/// is true if the implementation of [`Ord`] for `K` panics.
370+
/// If the implementation of [`Ord`] for `K` does not implement a [total order], the function
371+
/// may panic; even if the function exits normally, the resulting order of elements in the slice
372+
/// is unspecified. See also the note on panicking below.
354373
///
355374
/// For simple key functions (e.g., functions that are property accesses or basic operations),
356375
/// [`sort_by_key`](slice::sort_by_key) is likely to be faster.
@@ -369,7 +388,15 @@ impl<T> [T] {
369388
///
370389
/// # Panics
371390
///
372-
/// May panic if the implementation of [`Ord`] for `K` does not implement a [total order].
391+
/// May panic if the implementation of [`Ord`] for `K` does not implement a [total order], or if
392+
/// the [`Ord`] implementation panics.
393+
///
394+
/// All safe functions on slices preserve the invariant that even if the function panics, all
395+
/// original elements will remain in the slice and any possible modifications via interior
396+
/// mutability are observed in the input. This ensures that recovery code (for instance inside
397+
/// of a `Drop` or following a `catch_unwind`) will still have access to all the original
398+
/// elements. For instance, if the slice belongs to a `Vec`, the `Vec::drop` method will be able
399+
/// to dispose of all contained elements.
373400
///
374401
/// # Examples
375402
///

library/std/src/net/tcp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ impl TcpStream {
561561

562562
/// Moves this TCP stream into or out of nonblocking mode.
563563
///
564-
/// This will result in `read`, `write`, `recv` and `send` operations
564+
/// This will result in `read`, `write`, `recv` and `send` system operations
565565
/// becoming nonblocking, i.e., immediately returning from their calls.
566566
/// If the IO operation is successful, `Ok` is returned and no further
567567
/// action is required. If the IO operation could not be completed and needs

library/std/src/net/udp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ impl UdpSocket {
764764

765765
/// Moves this UDP socket into or out of nonblocking mode.
766766
///
767-
/// This will result in `recv`, `recv_from`, `send`, and `send_to`
767+
/// This will result in `recv`, `recv_from`, `send`, and `send_to` system
768768
/// operations becoming nonblocking, i.e., immediately returning from their
769769
/// calls. If the IO operation is successful, `Ok` is returned and no
770770
/// further action is required. If the IO operation could not be completed

src/bootstrap/src/core/build_steps/llvm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {
242242

243243
/// Returns true if we're running in CI with modified LLVM (and thus can't download it)
244244
pub(crate) fn is_ci_llvm_modified(config: &Config) -> bool {
245-
CiEnv::is_ci() && config.rust_info.is_managed_git_subrepository() && {
245+
CiEnv::is_rust_lang_managed_ci_job() && config.rust_info.is_managed_git_subrepository() && {
246246
// We assume we have access to git, so it's okay to unconditionally pass
247247
// `true` here.
248248
let llvm_sha = detect_llvm_sha(config, true);

src/bootstrap/src/core/config/config.rs

+22
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,15 @@ pub struct Config {
343343
pub out: PathBuf,
344344
pub rust_info: channel::GitInfo,
345345

346+
pub cargo_info: channel::GitInfo,
347+
pub rust_analyzer_info: channel::GitInfo,
348+
pub clippy_info: channel::GitInfo,
349+
pub miri_info: channel::GitInfo,
350+
pub rustfmt_info: channel::GitInfo,
351+
pub enzyme_info: channel::GitInfo,
352+
pub in_tree_llvm_info: channel::GitInfo,
353+
pub in_tree_gcc_info: channel::GitInfo,
354+
346355
// These are either the stage0 downloaded binaries or the locally installed ones.
347356
pub initial_cargo: PathBuf,
348357
pub initial_rustc: PathBuf,
@@ -1796,6 +1805,19 @@ impl Config {
17961805
config.omit_git_hash = omit_git_hash.unwrap_or(default);
17971806
config.rust_info = GitInfo::new(config.omit_git_hash, &config.src);
17981807

1808+
config.cargo_info = GitInfo::new(config.omit_git_hash, &config.src.join("src/tools/cargo"));
1809+
config.rust_analyzer_info =
1810+
GitInfo::new(config.omit_git_hash, &config.src.join("src/tools/rust-analyzer"));
1811+
config.clippy_info =
1812+
GitInfo::new(config.omit_git_hash, &config.src.join("src/tools/clippy"));
1813+
config.miri_info = GitInfo::new(config.omit_git_hash, &config.src.join("src/tools/miri"));
1814+
config.rustfmt_info =
1815+
GitInfo::new(config.omit_git_hash, &config.src.join("src/tools/rustfmt"));
1816+
config.enzyme_info =
1817+
GitInfo::new(config.omit_git_hash, &config.src.join("src/tools/enzyme"));
1818+
config.in_tree_llvm_info = GitInfo::new(false, &config.src.join("src/llvm-project"));
1819+
config.in_tree_gcc_info = GitInfo::new(false, &config.src.join("src/gcc"));
1820+
17991821
// We need to override `rust.channel` if it's manually specified when using the CI rustc.
18001822
// This is because if the compiler uses a different channel than the one specified in config.toml,
18011823
// tests may fail due to using a different channel than the one used by the compiler during tests.

src/bootstrap/src/lib.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -305,18 +305,15 @@ impl Build {
305305
#[cfg(not(unix))]
306306
let is_sudo = false;
307307

308-
let omit_git_hash = config.omit_git_hash;
309-
let rust_info = GitInfo::new(omit_git_hash, &src);
310-
let cargo_info = GitInfo::new(omit_git_hash, &src.join("src/tools/cargo"));
311-
let rust_analyzer_info = GitInfo::new(omit_git_hash, &src.join("src/tools/rust-analyzer"));
312-
let clippy_info = GitInfo::new(omit_git_hash, &src.join("src/tools/clippy"));
313-
let miri_info = GitInfo::new(omit_git_hash, &src.join("src/tools/miri"));
314-
let rustfmt_info = GitInfo::new(omit_git_hash, &src.join("src/tools/rustfmt"));
315-
let enzyme_info = GitInfo::new(omit_git_hash, &src.join("src/tools/enzyme"));
316-
317-
// we always try to use git for LLVM builds
318-
let in_tree_llvm_info = GitInfo::new(false, &src.join("src/llvm-project"));
319-
let in_tree_gcc_info = GitInfo::new(false, &src.join("src/gcc"));
308+
let rust_info = config.rust_info.clone();
309+
let cargo_info = config.cargo_info.clone();
310+
let rust_analyzer_info = config.rust_analyzer_info.clone();
311+
let clippy_info = config.clippy_info.clone();
312+
let miri_info = config.miri_info.clone();
313+
let rustfmt_info = config.rustfmt_info.clone();
314+
let enzyme_info = config.enzyme_info.clone();
315+
let in_tree_llvm_info = config.in_tree_llvm_info.clone();
316+
let in_tree_gcc_info = config.in_tree_gcc_info.clone();
320317

321318
let initial_target_libdir_str = if config.dry_run() {
322319
"/dummy/lib/path/to/lib/".to_string()

src/librustdoc/visit.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
use crate::clean::*;
22

3+
/// Allows a type to traverse the cleaned ast of a crate.
4+
///
5+
/// Note that like [`rustc_ast::visit::Visitor`], but
6+
/// unlike [`rustc_lint::EarlyLintPass`], if you override a
7+
/// `visit_*` method, you will need to manually recurse into
8+
/// its contents.
39
pub(crate) trait DocVisitor<'a>: Sized {
410
fn visit_item(&mut self, item: &'a Item) {
511
self.visit_item_recur(item)
612
}
713

8-
/// don't override!
14+
/// Don't override!
915
fn visit_inner_recur(&mut self, kind: &'a ItemKind) {
1016
match kind {
1117
StrippedItem(..) => unreachable!(),
@@ -46,7 +52,7 @@ pub(crate) trait DocVisitor<'a>: Sized {
4652
}
4753
}
4854

49-
/// don't override!
55+
/// Don't override!
5056
fn visit_item_recur(&mut self, item: &'a Item) {
5157
match &item.kind {
5258
StrippedItem(i) => self.visit_inner_recur(&*i),
@@ -58,6 +64,7 @@ pub(crate) trait DocVisitor<'a>: Sized {
5864
m.items.iter().for_each(|i| self.visit_item(i))
5965
}
6066

67+
/// This is the main entrypoint of [`DocVisitor`].
6168
fn visit_crate(&mut self, c: &'a Crate) {
6269
self.visit_item(&c.module);
6370

src/tools/build_helper/src/ci.rs

+9
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ impl CiEnv {
1919
pub fn is_ci() -> bool {
2020
Self::current() != CiEnv::None
2121
}
22+
23+
/// Checks if running in rust-lang/rust managed CI job.
24+
pub fn is_rust_lang_managed_ci_job() -> bool {
25+
Self::is_ci()
26+
// If both are present, we can assume it's an upstream CI job
27+
// as they are always set unconditionally.
28+
&& std::env::var_os("CI_JOB_NAME").is_some()
29+
&& std::env::var_os("TOOLSTATE_REPO").is_some()
30+
}
2231
}
2332

2433
pub mod gha {

0 commit comments

Comments
 (0)