Skip to content

Rollup of 8 pull requests #141397

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 18 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f57a64a
ci: improve citool job db errors
marcoieni May 21, 2025
ca912d7
Make captures state error more precise
compiler-errors May 21, 2025
e0f8055
Fix FnOnce impl for AsyncFn/AsyncFnMut closures in new solver
compiler-errors May 21, 2025
85d2d84
Remove `is_empty` check in `filter_assoc_items_by_name_and_namespace`.
nnethercote May 22, 2025
c309065
Remove `is_empty` check in `Ident::is_numeric`.
nnethercote May 22, 2025
27677ef
ci: convert distcheck to free runner
marcoieni May 22, 2025
806cd12
ci: prepare aws access keys for migration
marcoieni May 22, 2025
bc9cdc9
Return correct error term kind on projection errors
BoxyUwU May 21, 2025
16b6ffe
Don't allow poly_select in new solver
compiler-errors May 22, 2025
09ae053
try_cast_aligned: avoid bare int-to-ptr casts
RalfJung May 22, 2025
8757915
Rollup merge of #141355 - marcoieni:citool-errors, r=Kobzol
matthiaskrgr May 22, 2025
654b2f3
Rollup merge of #141359 - compiler-errors:async-fn-once, r=lcnr
matthiaskrgr May 22, 2025
5cab70e
Rollup merge of #141362 - BoxyUwU:correct_error_term_kind, r=lcnr
matthiaskrgr May 22, 2025
74b980d
Rollup merge of #141377 - nnethercote:rm-unnecessary-is_empty-checks,…
matthiaskrgr May 22, 2025
db95253
Rollup merge of #141381 - RalfJung:try_cast_aligned-strict-provenance…
matthiaskrgr May 22, 2025
9507b10
Rollup merge of #141382 - marcoieni:distcheck-free-x86, r=Kobzol
matthiaskrgr May 22, 2025
abba164
Rollup merge of #141389 - marcoieni:aws-secrets-ci-migration, r=Kobzol
matthiaskrgr May 22, 2025
580bd6e
Rollup merge of #141390 - compiler-errors:poly-select-new-solver, r=lcnr
matthiaskrgr May 22, 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: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ jobs:
fi
exit ${STATUS}
env:
AWS_ACCESS_KEY_ID: ${{ env.CACHES_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}
AWS_ACCESS_KEY_ID: ${{ (github.repository == 'rust-lang/rust' && secrets.CACHES_AWS_ACCESS_KEY_ID) || env.CACHES_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ (github.repository == 'rust-lang/rust' && secrets.CACHES_AWS_SECRET_ACCESS_KEY) || secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}

- name: create github artifacts
run: src/ci/scripts/create-doc-artifacts.sh
Expand All @@ -257,8 +257,8 @@ jobs:
- name: upload artifacts to S3
run: src/ci/scripts/upload-artifacts.sh
env:
AWS_ACCESS_KEY_ID: ${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}
AWS_ACCESS_KEY_ID: ${{ (github.repository == 'rust-lang/rust' && secrets.ARTIFACTS_AWS_ACCESS_KEY_ID) || env.ARTIFACTS_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ (github.repository == 'rust-lang/rust' && secrets.ARTIFACTS_AWS_SECRET_ACCESS_KEY) || secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}
# Adding a condition on DEPLOY=1 or DEPLOY_ALT=1 is not needed as all deploy
# builders *should* have the AWS credentials available. Still, explicitly
# adding the condition is helpful as this way CI will not silently skip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<I: Intern
// always be called once. It additionally implements `Fn`/`FnMut`
// only if it has no upvars referencing the closure-env lifetime,
// and if the closure kind permits it.
if closure_kind != ty::ClosureKind::FnOnce && args.has_self_borrows() {
if goal_kind != ty::ClosureKind::FnOnce && args.has_self_borrows() {
return Err(NoSolution);
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2823,7 +2823,7 @@ impl Ident {
/// Whether this would be the identifier for a tuple field like `self.0`, as
/// opposed to a named field like `self.thing`.
pub fn is_numeric(self) -> bool {
!self.name.is_empty() && self.as_str().bytes().all(|b| b.is_ascii_digit())
self.as_str().bytes().all(|b| b.is_ascii_digit())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -841,16 +841,17 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
return None;
};

let (closure_def_id, found_args, by_ref_captures) = match *self_ty.kind() {
let (closure_def_id, found_args, has_self_borrows) = match *self_ty.kind() {
ty::Closure(def_id, args) => {
(def_id, args.as_closure().sig().map_bound(|sig| sig.inputs()[0]), None)
(def_id, args.as_closure().sig().map_bound(|sig| sig.inputs()[0]), false)
}
ty::CoroutineClosure(def_id, args) => (
def_id,
args.as_coroutine_closure()
.coroutine_closure_sig()
.map_bound(|sig| sig.tupled_inputs_ty),
Some(args.as_coroutine_closure().coroutine_captures_by_ref_ty()),
!args.as_coroutine_closure().tupled_upvars_ty().is_ty_var()
&& args.as_coroutine_closure().has_self_borrows(),
),
_ => return None,
};
Expand Down Expand Up @@ -884,10 +885,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
// If the closure has captures, then perhaps the reason that the trait
// is unimplemented is because async closures don't implement `Fn`/`FnMut`
// if they have captures.
if let Some(by_ref_captures) = by_ref_captures
&& let ty::FnPtr(sig_tys, _) = by_ref_captures.kind()
&& !sig_tys.skip_binder().output().is_unit()
{
if has_self_borrows && expected_kind != ty::ClosureKind::FnOnce {
let mut err = self.dcx().create_err(AsyncClosureNotFn {
span: self.tcx.def_span(closure_def_id),
kind: expected_kind.as_str(),
Expand Down Expand Up @@ -1503,11 +1501,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
return None;
};

let Ok(Some(ImplSource::UserDefined(impl_data))) = SelectionContext::new(self)
.poly_select(&obligation.with(
self.tcx,
predicate.kind().rebind(proj.projection_term.trait_ref(self.tcx)),
))
let trait_ref = self.enter_forall_and_leak_universe(
predicate.kind().rebind(proj.projection_term.trait_ref(self.tcx)),
);
let Ok(Some(ImplSource::UserDefined(impl_data))) =
SelectionContext::new(self).select(&obligation.with(self.tcx, trait_ref))
else {
return None;
};
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_trait_selection/src/solve/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_infer::traits::solve::inspect::ProbeKind;
use rustc_infer::traits::solve::{CandidateSource, Certainty, Goal};
use rustc_infer::traits::{
BuiltinImplSource, ImplSource, ImplSourceUserDefinedData, Obligation, ObligationCause,
PolyTraitObligation, Selection, SelectionError, SelectionResult,
Selection, SelectionError, SelectionResult, TraitObligation,
};
use rustc_macros::extension;
use rustc_middle::{bug, span_bug};
Expand All @@ -17,7 +17,7 @@ use crate::solve::inspect::{self, ProofTreeInferCtxtExt};
impl<'tcx> InferCtxt<'tcx> {
fn select_in_new_trait_solver(
&self,
obligation: &PolyTraitObligation<'tcx>,
obligation: &TraitObligation<'tcx>,
) -> SelectionResult<'tcx, Selection<'tcx>> {
assert!(self.next_trait_solver());

Expand Down
29 changes: 25 additions & 4 deletions compiler/rustc_trait_selection/src/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>(
term: projected_term,
obligations: mut projected_obligations,
})) => {
debug!("opt_normalize_projection_type: progress");
// if projection succeeded, then what we get out of this
// is also non-normalized (consider: it was derived from
// an impl, where-clause etc) and hence we must
Expand Down Expand Up @@ -408,6 +409,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>(
Ok(Some(result.value))
}
Ok(Projected::NoProgress(projected_ty)) => {
debug!("opt_normalize_projection_type: no progress");
let result =
Normalized { value: projected_ty, obligations: PredicateObligations::new() };
infcx.inner.borrow_mut().projection_cache().insert_term(cache_key, result.clone());
Expand Down Expand Up @@ -621,8 +623,17 @@ struct Progress<'tcx> {
}

impl<'tcx> Progress<'tcx> {
fn error(tcx: TyCtxt<'tcx>, guar: ErrorGuaranteed) -> Self {
Progress { term: Ty::new_error(tcx, guar).into(), obligations: PredicateObligations::new() }
fn error_for_term(
tcx: TyCtxt<'tcx>,
alias_term: ty::AliasTerm<'tcx>,
guar: ErrorGuaranteed,
) -> Self {
let err_term = if alias_term.kind(tcx).is_type() {
Ty::new_error(tcx, guar).into()
} else {
ty::Const::new_error(tcx, guar).into()
};
Progress { term: err_term, obligations: PredicateObligations::new() }
}

fn with_addl_obligations(mut self, mut obligations: PredicateObligations<'tcx>) -> Self {
Expand Down Expand Up @@ -650,7 +661,11 @@ fn project<'cx, 'tcx>(
}

if let Err(guar) = obligation.predicate.error_reported() {
return Ok(Projected::Progress(Progress::error(selcx.tcx(), guar)));
return Ok(Projected::Progress(Progress::error_for_term(
selcx.tcx(),
obligation.predicate,
guar,
)));
}

let mut candidates = ProjectionCandidateSet::None;
Expand Down Expand Up @@ -1965,7 +1980,13 @@ fn confirm_impl_candidate<'cx, 'tcx>(
let param_env = obligation.param_env;
let assoc_term = match specialization_graph::assoc_def(tcx, impl_def_id, assoc_item_id) {
Ok(assoc_term) => assoc_term,
Err(guar) => return Ok(Projected::Progress(Progress::error(tcx, guar))),
Err(guar) => {
return Ok(Projected::Progress(Progress::error_for_term(
tcx,
obligation.predicate,
guar,
)));
}
};

// This means that the impl is missing a definition for the
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
&mut self,
obligation: &PolyTraitObligation<'tcx>,
) -> SelectionResult<'tcx, Selection<'tcx>> {
if self.infcx.next_trait_solver() {
return self.infcx.select_in_new_trait_solver(obligation);
}
assert!(!self.infcx.next_trait_solver());

let candidate = match self.select_from_obligation(obligation) {
Err(SelectionError::Overflow(OverflowError::Canonical)) => {
Expand Down Expand Up @@ -299,6 +297,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
&mut self,
obligation: &TraitObligation<'tcx>,
) -> SelectionResult<'tcx, Selection<'tcx>> {
if self.infcx.next_trait_solver() {
return self.infcx.select_in_new_trait_solver(obligation);
}

self.poly_select(&Obligation {
cause: obligation.cause.clone(),
param_env: obligation.param_env,
Expand Down
12 changes: 5 additions & 7 deletions library/core/src/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,13 @@ impl<T: ?Sized> *const T {
/// ```rust
/// #![feature(pointer_try_cast_aligned)]
///
/// let aligned: *const u8 = 0x1000 as _;
/// let x = 0u64;
///
/// // i32 has at most 4-byte alignment, so this will succeed
/// assert!(aligned.try_cast_aligned::<i32>().is_some());
/// let aligned: *const u64 = &x;
/// let unaligned = unsafe { aligned.byte_add(1) };
///
/// let unaligned: *const u8 = 0x1001 as _;
///
/// // i32 has at least 2-byte alignment, so this will fail
/// assert!(unaligned.try_cast_aligned::<i32>().is_none());
/// assert!(aligned.try_cast_aligned::<u32>().is_some());
/// assert!(unaligned.try_cast_aligned::<u32>().is_none());
/// ```
#[unstable(feature = "pointer_try_cast_aligned", issue = "141221")]
#[must_use = "this returns the result of the operation, \
Expand Down
12 changes: 5 additions & 7 deletions library/core/src/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,13 @@ impl<T: ?Sized> *mut T {
/// ```rust
/// #![feature(pointer_try_cast_aligned)]
///
/// let aligned: *mut u8 = 0x1000 as _;
/// let mut x = 0u64;
///
/// // i32 has at most 4-byte alignment, so this will succeed
/// assert!(aligned.try_cast_aligned::<i32>().is_some());
/// let aligned: *mut u64 = &mut x;
/// let unaligned = unsafe { aligned.byte_add(1) };
///
/// let unaligned: *mut u8 = 0x1001 as _;
///
/// // i32 has at least 2-byte alignment, so this will fail
/// assert!(unaligned.try_cast_aligned::<i32>().is_none());
/// assert!(aligned.try_cast_aligned::<u32>().is_some());
/// assert!(unaligned.try_cast_aligned::<u32>().is_none());
/// ```
#[unstable(feature = "pointer_try_cast_aligned", issue = "141221")]
#[must_use = "this returns the result of the operation, \
Expand Down
12 changes: 5 additions & 7 deletions library/core/src/ptr/non_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,15 +501,13 @@ impl<T: ?Sized> NonNull<T> {
/// #![feature(pointer_try_cast_aligned)]
/// use std::ptr::NonNull;
///
/// let aligned: NonNull<u8> = NonNull::new(0x1000 as _).unwrap();
/// let mut x = 0u64;
///
/// // i32 has at most 4-byte alignment, so this will succeed
/// assert!(aligned.try_cast_aligned::<i32>().is_some());
/// let aligned = NonNull::from_mut(&mut x);
/// let unaligned = unsafe { aligned.byte_add(1) };
///
/// let unaligned: NonNull<u8> = NonNull::new(0x1001 as _).unwrap();
///
/// // i32 has at least 2-byte alignment, so this will fail
/// assert!(unaligned.try_cast_aligned::<i32>().is_none());
/// assert!(aligned.try_cast_aligned::<u32>().is_some());
/// assert!(unaligned.try_cast_aligned::<u32>().is_none());
/// ```
#[unstable(feature = "pointer_try_cast_aligned", issue = "141221")]
#[must_use = "this returns the result of the operation, \
Expand Down
14 changes: 10 additions & 4 deletions src/ci/citool/src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,20 @@ impl JobDatabase {
}

pub fn load_job_db(db: &str) -> anyhow::Result<JobDatabase> {
let mut db: Value = serde_yaml::from_str(db)?;
let mut db: Value = serde_yaml::from_str(db).context("failed to parse YAML content")?;

// We need to expand merge keys (<<), because serde_yaml can't deal with them
// `apply_merge` only applies the merge once, so do it a few times to unwrap nested merges.
db.apply_merge()?;
db.apply_merge()?;

let db: JobDatabase = serde_yaml::from_value(db)?;
let apply_merge = |db: &mut Value| -> anyhow::Result<()> {
db.apply_merge().context("failed to apply merge keys")
};

// Apply merge twice to handle nested merges
apply_merge(&mut db)?;
apply_merge(&mut db)?;

let db: JobDatabase = serde_yaml::from_value(db).context("failed to parse job database")?;
Ok(db)
}

Expand Down
2 changes: 1 addition & 1 deletion src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ auto:
<<: *job-linux-4c

- name: x86_64-gnu-distcheck
<<: *job-linux-8c
<<: *job-linux-4c

# The x86_64-gnu-llvm-20 job is split into multiple jobs to run tests in parallel.
# x86_64-gnu-llvm-20-1 skips tests that run in x86_64-gnu-llvm-20-{2,3}.
Expand Down
7 changes: 1 addition & 6 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ fn filter_assoc_items_by_name_and_namespace(
ident: Ident,
ns: Namespace,
) -> impl Iterator<Item = &ty::AssocItem> {
let iter: Box<dyn Iterator<Item = &ty::AssocItem>> = if !ident.name.is_empty() {
Box::new(tcx.associated_items(assoc_items_of).filter_by_name_unhygienic(ident.name))
} else {
Box::new([].iter())
};
iter.filter(move |item| {
tcx.associated_items(assoc_items_of).filter_by_name_unhygienic(ident.name).filter(move |item| {
item.namespace() == ns && tcx.hygienic_eq(ident, item.ident(tcx), assoc_items_of)
})
}
Expand Down
8 changes: 0 additions & 8 deletions tests/crashes/140642.rs

This file was deleted.

15 changes: 15 additions & 0 deletions tests/ui/async-await/async-closures/async-fn-mut-impl-fn-once.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ edition:2021
//@ check-pass
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver

fn call_once<F>(_: impl FnOnce() -> F) {}

fn main() {
let mut i = 0;
let c = async || {
i += 1;
};
call_once(c);
}
17 changes: 17 additions & 0 deletions tests/ui/const-generics/mgca/projection-error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![feature(min_generic_const_args)]
#![expect(incomplete_features)]

// Regression test for #140642. Test that normalizing const aliases
// containing erroneous types normalizes to a const error instead of
// a type error.


pub trait Tr<A> {
const SIZE: usize;
}

fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
//~^ ERROR: cannot find type `T` in this scope
//~| ERROR: cannot find type `T` in this scope

fn main() {}
39 changes: 39 additions & 0 deletions tests/ui/const-generics/mgca/projection-error.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
error[E0412]: cannot find type `T` in this scope
--> $DIR/projection-error.rs:13:17
|
LL | pub trait Tr<A> {
| --------------- similarly named trait `Tr` defined here
...
LL | fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
| ^
|
help: a trait with a similar name exists
|
LL | fn mk_array(_x: Tr) -> [(); <T as Tr<bool>>::SIZE] {}
| +
help: you might be missing a type parameter
|
LL | fn mk_array<T>(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
| +++

error[E0412]: cannot find type `T` in this scope
--> $DIR/projection-error.rs:13:29
|
LL | pub trait Tr<A> {
| --------------- similarly named trait `Tr` defined here
...
LL | fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
| ^
|
help: a trait with a similar name exists
|
LL | fn mk_array(_x: T) -> [(); <Tr as Tr<bool>>::SIZE] {}
| +
help: you might be missing a type parameter
|
LL | fn mk_array<T>(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
| +++

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0412`.
Loading
Loading