Skip to content

Rollup of 13 pull requests #145644

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 38 commits into from
Aug 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1ddb4d0
Fix parameter order for `_by()` variants of `min` / `max`/ `minmax` i…
miried Apr 4, 2025
d78e762
scrape-examples.js: give each function a signature
lolbinarycat Apr 25, 2025
b4c77e1
rustdoc js: add ScrapedLoc type
lolbinarycat Apr 25, 2025
35ba7dd
rustdoc js: add rustdoc.ScrapedLoc type
lolbinarycat Apr 25, 2025
8799d3d
fix typo
lolbinarycat Apr 28, 2025
b06113d
scrape-examples.js: add another nonnull() invokation
lolbinarycat May 22, 2025
c021e7a
scrape-examples.js: fix typos
lolbinarycat May 27, 2025
a7e8fe7
Clarify EOF handling for `BufRead::skip_until`
ginnyTheCat Aug 6, 2025
bec399e
std_detect: RISC-V platform guide documentation
a4lg Aug 15, 2025
36a3820
Use aarch64-apple-darwin as the fallback doc source for `-apple-`
shepmaster Aug 11, 2025
c574c91
Demote x86_64-apple-darwin to Tier 2 with host tools
shepmaster Aug 11, 2025
40fc7df
Add runtime detection for APX-F and AVX10
sayantn Aug 17, 2025
73d3d28
Implement feature `int_lowest_highest_one` for integer and NonZero types
Gnurou Aug 10, 2025
41d8d85
Remove hs_abs_cmp examples
miried Aug 19, 2025
36d309e
Merge remote-tracking branch 'upstream/master'
miried Aug 19, 2025
77d6ee0
Fix bug where `rustdoc-js` tester would not pick the right `search.js…
GuillaumeGomez Aug 13, 2025
2ebe679
Strenghten rustdoc js tester file macthing regex
GuillaumeGomez Aug 16, 2025
a971238
`std_detect`: Use `rustc-std-workspace-*` to pull in `compiler-builtins`
joshtriplett Aug 19, 2025
4c948bc
Update lockfile for changes to `std_detect`
joshtriplett Aug 19, 2025
988092e
Remove the std workspace patch for `compiler-builtins`
tgross35 Aug 19, 2025
51df7aa
add a fallback implementation for the `prefetch_*` intrinsics
folkertdev Aug 19, 2025
ab6f4d6
Pretty print the name of an future from calling async closure
compiler-errors Aug 19, 2025
9a29e16
mention lint group in default level lint note
karolzwolak Apr 28, 2025
d14b83e
bless tests with new lint messages
karolzwolak Apr 28, 2025
d25910e
make `prefetch` intrinsics safe
folkertdev Aug 19, 2025
a6d648f
Rollup merge of #139357 - miried:master, r=Amanieu
jhpratt Aug 20, 2025
9a1ab5e
Rollup merge of #140314 - lolbinarycat:rustdoc-js-scrape-examples-typ…
jhpratt Aug 20, 2025
1e6df58
Rollup merge of #140794 - karolzwolak:allow-unused-doc-65464, r=david…
jhpratt Aug 20, 2025
5fa3304
Rollup merge of #145006 - ginnyTheCat:docs-skip-until, r=ibraheemdev
jhpratt Aug 20, 2025
7b7ad4d
Rollup merge of #145252 - shepmaster:demote-x86_64-apple-darwin-to-ti…
jhpratt Aug 20, 2025
a8feea8
Rollup merge of #145359 - GuillaumeGomez:correctly-pick-search.js, r=…
jhpratt Aug 20, 2025
5a0c938
Rollup merge of #145381 - Gnurou:int_lowest_highest_one, r=jhpratt
jhpratt Aug 20, 2025
9261fcf
Rollup merge of #145417 - a4lg:riscv-arch-platform-guide-ch2, r=Amanieu
jhpratt Aug 20, 2025
b0600b2
Rollup merge of #145531 - sayantn:detect-apxf-avx10, r=Amanieu
jhpratt Aug 20, 2025
84c5d20
Rollup merge of #145619 - joshtriplett:use-the-right-core, r=tgross35
jhpratt Aug 20, 2025
6e65229
Rollup merge of #145622 - tgross35:remove-builtins-patch, r=Mark-Simu…
jhpratt Aug 20, 2025
ef22202
Rollup merge of #145623 - compiler-errors:pretty-async-name, r=wesley…
jhpratt Aug 20, 2025
816f098
Rollup merge of #145626 - folkertdev:prefetch-fallback, r=Amanieu
jhpratt Aug 20, 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
8 changes: 7 additions & 1 deletion compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,16 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
_ => bug!(),
};
let ptr = args[0].immediate();
let locality = fn_args.const_at(1).to_value().valtree.unwrap_leaf().to_u32() as i32;
self.call_intrinsic(
"llvm.prefetch",
&[self.val_ty(ptr)],
&[ptr, self.const_i32(rw), args[1].immediate(), self.const_i32(cache_type)],
&[
ptr,
self.const_i32(rw),
self.const_i32(locality),
self.const_i32(cache_type),
],
)
}
sym::carrying_mul_add => {
Expand Down
31 changes: 30 additions & 1 deletion compiler/rustc_const_eval/src/util/type_name.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt::Write;

use rustc_data_structures::intern::Interned;
use rustc_hir::def_id::CrateNum;
use rustc_hir::def_id::{CrateNum, DefId};
use rustc_hir::definitions::DisambiguatedDefPathData;
use rustc_middle::bug;
use rustc_middle::ty::print::{PrettyPrinter, PrintError, Printer};
Expand Down Expand Up @@ -132,6 +132,35 @@ impl<'tcx> Printer<'tcx> for TypeNamePrinter<'tcx> {
Ok(())
}
}

fn print_coroutine_with_kind(
&mut self,
def_id: DefId,
parent_args: &'tcx [GenericArg<'tcx>],
kind: Ty<'tcx>,
) -> Result<(), PrintError> {
self.print_def_path(def_id, parent_args)?;

let ty::Coroutine(_, args) = self.tcx.type_of(def_id).instantiate_identity().kind() else {
// Could be `ty::Error`.
return Ok(());
};

let default_kind = args.as_coroutine().kind_ty();

match kind.to_opt_closure_kind() {
_ if kind == default_kind => {
// No need to mark the closure if it's the deduced coroutine kind.
}
Some(ty::ClosureKind::Fn) | None => {
// Should never happen. Just don't mark anything rather than panicking.
}
Some(ty::ClosureKind::FnMut) => self.path.push_str("::{{call_mut}}"),
Some(ty::ClosureKind::FnOnce) => self.path.push_str("::{{call_once}}"),
}

Ok(())
}
}

impl<'tcx> PrettyPrinter<'tcx> for TypeNamePrinter<'tcx> {
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_hir_analysis/src/check/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hi
| sym::round_ties_even_f64
| sym::round_ties_even_f128
| sym::autodiff
| sym::prefetch_read_data
| sym::prefetch_write_data
| sym::prefetch_read_instruction
| sym::prefetch_write_instruction
| sym::const_eval_select => hir::Safety::Safe,
_ => hir::Safety::Unsafe,
};
Expand Down Expand Up @@ -218,7 +222,7 @@ pub(crate) fn check_intrinsic_type(
| sym::prefetch_write_data
| sym::prefetch_read_instruction
| sym::prefetch_write_instruction => {
(1, 0, vec![Ty::new_imm_ptr(tcx, param(0)), tcx.types.i32], tcx.types.unit)
(1, 1, vec![Ty::new_imm_ptr(tcx, param(0))], tcx.types.unit)
}
sym::needs_drop => (1, 0, vec![], tcx.types.bool),

Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use rustc_middle::ty::layout::{LayoutError, LayoutOfHelpers, TyAndLayout};
use rustc_middle::ty::print::{PrintError, PrintTraitRefExt as _, Printer, with_no_trimmed_paths};
use rustc_middle::ty::{self, GenericArg, RegisteredTools, Ty, TyCtxt, TypingEnv, TypingMode};
use rustc_session::lint::{FutureIncompatibleInfo, Lint, LintBuffer, LintExpectationId, LintId};
use rustc_session::{LintStoreMarker, Session};
use rustc_session::{DynLintStore, Session};
use rustc_span::edit_distance::find_best_match_for_names;
use rustc_span::{Ident, Span, Symbol, sym};
use tracing::debug;
Expand Down Expand Up @@ -62,7 +62,13 @@ pub struct LintStore {
lint_groups: FxIndexMap<&'static str, LintGroup>,
}

impl LintStoreMarker for LintStore {}
impl DynLintStore for LintStore {
fn lint_groups_iter(&self) -> Box<dyn Iterator<Item = rustc_session::LintGroup> + '_> {
Box::new(self.get_lint_groups().map(|(name, lints, is_externally_loaded)| {
rustc_session::LintGroup { name, lints, is_externally_loaded }
}))
}
}

/// The target of the `by_name` map, which accounts for renaming/deprecation.
#[derive(Debug)]
Expand Down
29 changes: 27 additions & 2 deletions compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,28 @@ impl LintExpectation {
}

fn explain_lint_level_source(
sess: &Session,
lint: &'static Lint,
level: Level,
src: LintLevelSource,
err: &mut Diag<'_, ()>,
) {
// Find the name of the lint group that contains the given lint.
// Assumes the lint only belongs to one group.
let lint_group_name = |lint| {
let lint_groups_iter = sess.lint_groups_iter();
let lint_id = LintId::of(lint);
lint_groups_iter
.filter(|lint_group| !lint_group.is_externally_loaded)
.find(|lint_group| {
lint_group
.lints
.iter()
.find(|lint_group_lint| **lint_group_lint == lint_id)
.is_some()
})
.map(|lint_group| lint_group.name)
};
let name = lint.name_lower();
if let Level::Allow = level {
// Do not point at `#[allow(compat_lint)]` as the reason for a compatibility lint
Expand All @@ -224,7 +241,15 @@ fn explain_lint_level_source(
}
match src {
LintLevelSource::Default => {
err.note_once(format!("`#[{}({})]` on by default", level.as_str(), name));
let level_str = level.as_str();
match lint_group_name(lint) {
Some(group_name) => {
err.note_once(format!("`#[{level_str}({name})]` (part of `#[{level_str}({group_name})]`) on by default"));
}
None => {
err.note_once(format!("`#[{level_str}({name})]` on by default"));
}
}
}
LintLevelSource::CommandLine(lint_flag_val, orig_level) => {
let flag = orig_level.to_cmd_flag();
Expand Down Expand Up @@ -427,7 +452,7 @@ pub fn lint_level(
decorate(&mut err);
}

explain_lint_level_source(lint, level, src, &mut err);
explain_lint_level_source(sess, lint, level, src, &mut err);
err.emit()
}
lint_level_impl(sess, lint, level, span, Box::new(decorate))
Expand Down
16 changes: 13 additions & 3 deletions compiler/rustc_middle/src/ty/print/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ pub trait Printer<'tcx>: Sized {
trait_ref: Option<ty::TraitRef<'tcx>>,
) -> Result<(), PrintError>;

fn print_coroutine_with_kind(
&mut self,
def_id: DefId,
parent_args: &'tcx [GenericArg<'tcx>],
kind: Ty<'tcx>,
) -> Result<(), PrintError> {
self.print_path_with_generic_args(|p| p.print_def_path(def_id, parent_args), &[kind.into()])
}

// Defaults (should not be overridden):

#[instrument(skip(self), level = "debug")]
Expand Down Expand Up @@ -162,9 +171,10 @@ pub trait Printer<'tcx>: Sized {
)) = self.tcx().coroutine_kind(def_id)
&& args.len() > parent_args.len()
{
return self.print_path_with_generic_args(
|p| p.print_def_path(def_id, parent_args),
&args[..parent_args.len() + 1][..1],
return self.print_coroutine_with_kind(
def_id,
parent_args,
args[parent_args.len()].expect_ty(),
);
} else {
// Closures' own generics are only captures, don't print them.
Expand Down
21 changes: 19 additions & 2 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use crate::config::{
SwitchWithOptPath,
};
use crate::filesearch::FileSearch;
use crate::lint::LintId;
use crate::parse::{ParseSess, add_feature_diagnostics};
use crate::search_paths::SearchPath;
use crate::{errors, filesearch, lint};
Expand Down Expand Up @@ -139,7 +140,10 @@ pub struct CompilerIO {
pub temps_dir: Option<PathBuf>,
}

pub trait LintStoreMarker: Any + DynSync + DynSend {}
pub trait DynLintStore: Any + DynSync + DynSend {
/// Provides a way to access lint groups without depending on `rustc_lint`
fn lint_groups_iter(&self) -> Box<dyn Iterator<Item = LintGroup> + '_>;
}

/// Represents the data associated with a compilation
/// session for a single crate.
Expand All @@ -164,7 +168,7 @@ pub struct Session {
pub code_stats: CodeStats,

/// This only ever stores a `LintStore` but we don't want a dependency on that type here.
pub lint_store: Option<Arc<dyn LintStoreMarker>>,
pub lint_store: Option<Arc<dyn DynLintStore>>,

/// Cap lint level specified by a driver specifically.
pub driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
Expand Down Expand Up @@ -240,6 +244,12 @@ impl CodegenUnits {
}
}

pub struct LintGroup {
pub name: &'static str,
pub lints: Vec<LintId>,
pub is_externally_loaded: bool,
}

impl Session {
pub fn miri_unleashed_feature(&self, span: Span, feature_gate: Option<Symbol>) {
self.miri_unleashed_features.lock().push((span, feature_gate));
Expand Down Expand Up @@ -596,6 +606,13 @@ impl Session {
(&*self.target.staticlib_prefix, &*self.target.staticlib_suffix)
}
}

pub fn lint_groups_iter(&self) -> Box<dyn Iterator<Item = LintGroup> + '_> {
match self.lint_store {
Some(ref lint_store) => lint_store.lint_groups_iter(),
None => Box::new(std::iter::empty()),
}
}
}

// JUSTIFICATION: defn of the suggested wrapper fns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub(crate) fn target() -> Target {
llvm_target,
metadata: TargetMetadata {
description: Some("x86_64 Apple macOS (10.12+, Sierra+)".into()),
tier: Some(1),
tier: Some(2),
host_tools: Some(true),
std: Some(true),
},
Expand Down
4 changes: 2 additions & 2 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ dependencies = [
name = "std_detect"
version = "0.1.5"
dependencies = [
"alloc",
"core",
"libc",
"rustc-std-workspace-alloc",
"rustc-std-workspace-core",
]

[[package]]
Expand Down
1 change: 0 additions & 1 deletion library/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,3 @@ rustflags = ["-Cpanic=abort"]
rustc-std-workspace-core = { path = 'rustc-std-workspace-core' }
rustc-std-workspace-alloc = { path = 'rustc-std-workspace-alloc' }
rustc-std-workspace-std = { path = 'rustc-std-workspace-std' }
compiler_builtins = { path = "compiler-builtins/compiler-builtins" }
15 changes: 12 additions & 3 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,9 @@ pub fn min<T: Ord>(v1: T, v2: T) -> T {
///
/// Returns the first argument if the comparison determines them to be equal.
///
/// The parameter order is preserved when calling the `compare` function, i.e. `v1` is
/// always passed as the first argument and `v2` as the second.
///
/// # Examples
///
/// ```
Expand All @@ -1574,7 +1577,7 @@ pub fn min<T: Ord>(v1: T, v2: T) -> T {
#[must_use]
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
pub fn min_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
if compare(&v2, &v1).is_lt() { v2 } else { v1 }
if compare(&v1, &v2).is_le() { v1 } else { v2 }
}

/// Returns the element that gives the minimum value from the specified function.
Expand Down Expand Up @@ -1646,6 +1649,9 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
///
/// Returns the second argument if the comparison determines them to be equal.
///
/// The parameter order is preserved when calling the `compare` function, i.e. `v1` is
/// always passed as the first argument and `v2` as the second.
///
/// # Examples
///
/// ```
Expand All @@ -1666,7 +1672,7 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
#[must_use]
#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
if compare(&v2, &v1).is_lt() { v1 } else { v2 }
if compare(&v1, &v2).is_gt() { v1 } else { v2 }
}

/// Returns the element that gives the maximum value from the specified function.
Expand Down Expand Up @@ -1745,6 +1751,9 @@ where
///
/// Returns `[v1, v2]` if the comparison determines them to be equal.
///
/// The parameter order is preserved when calling the `compare` function, i.e. `v1` is
/// always passed as the first argument and `v2` as the second.
///
/// # Examples
///
/// ```
Expand All @@ -1769,7 +1778,7 @@ pub fn minmax_by<T, F>(v1: T, v2: T, compare: F) -> [T; 2]
where
F: FnOnce(&T, &T) -> Ordering,
{
if compare(&v2, &v1).is_lt() { [v2, v1] } else { [v1, v2] }
if compare(&v1, &v2).is_le() { [v1, v2] } else { [v2, v1] }
}

/// Returns minimum and maximum values with respect to the specified key function.
Expand Down
Loading
Loading