Skip to content

Commit e3892a4

Browse files
committed
Auto merge of rust-lang#141397 - matthiaskrgr:rollup-l9uu6g6, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#141355 (ci: improve citool job db errors) - rust-lang#141359 (Fix `FnOnce` impl for `AsyncFn`/`AsyncFnMut` self-borrowing closures in new solver) - rust-lang#141362 (Normalize aliases to correct kind of error term) - rust-lang#141377 (Remove unnecessary `is_empty` checks) - rust-lang#141381 (try_cast_aligned: avoid bare int-to-ptr casts) - rust-lang#141382 (ci: convert distcheck to free runner) - rust-lang#141389 (ci: prepare aws access keys for migration) - rust-lang#141390 (Don't allow `poly_select` in new solver) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d423c81 + 580bd6e commit e3892a4

File tree

20 files changed

+203
-67
lines changed

20 files changed

+203
-67
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ jobs:
234234
fi
235235
exit ${STATUS}
236236
env:
237-
AWS_ACCESS_KEY_ID: ${{ env.CACHES_AWS_ACCESS_KEY_ID }}
238-
AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}
237+
AWS_ACCESS_KEY_ID: ${{ (github.repository == 'rust-lang/rust' && secrets.CACHES_AWS_ACCESS_KEY_ID) || env.CACHES_AWS_ACCESS_KEY_ID }}
238+
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)] }}
239239

240240
- name: create github artifacts
241241
run: src/ci/scripts/create-doc-artifacts.sh
@@ -257,8 +257,8 @@ jobs:
257257
- name: upload artifacts to S3
258258
run: src/ci/scripts/upload-artifacts.sh
259259
env:
260-
AWS_ACCESS_KEY_ID: ${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}
261-
AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}
260+
AWS_ACCESS_KEY_ID: ${{ (github.repository == 'rust-lang/rust' && secrets.ARTIFACTS_AWS_ACCESS_KEY_ID) || env.ARTIFACTS_AWS_ACCESS_KEY_ID }}
261+
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)] }}
262262
# Adding a condition on DEPLOY=1 or DEPLOY_ALT=1 is not needed as all deploy
263263
# builders *should* have the AWS credentials available. Still, explicitly
264264
# adding the condition is helpful as this way CI will not silently skip

compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<I: Intern
327327
// always be called once. It additionally implements `Fn`/`FnMut`
328328
// only if it has no upvars referencing the closure-env lifetime,
329329
// and if the closure kind permits it.
330-
if closure_kind != ty::ClosureKind::FnOnce && args.has_self_borrows() {
330+
if goal_kind != ty::ClosureKind::FnOnce && args.has_self_borrows() {
331331
return Err(NoSolution);
332332
}
333333

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2823,7 +2823,7 @@ impl Ident {
28232823
/// Whether this would be the identifier for a tuple field like `self.0`, as
28242824
/// opposed to a named field like `self.thing`.
28252825
pub fn is_numeric(self) -> bool {
2826-
!self.name.is_empty() && self.as_str().bytes().all(|b| b.is_ascii_digit())
2826+
self.as_str().bytes().all(|b| b.is_ascii_digit())
28272827
}
28282828
}
28292829

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -841,16 +841,17 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
841841
return None;
842842
};
843843

844-
let (closure_def_id, found_args, by_ref_captures) = match *self_ty.kind() {
844+
let (closure_def_id, found_args, has_self_borrows) = match *self_ty.kind() {
845845
ty::Closure(def_id, args) => {
846-
(def_id, args.as_closure().sig().map_bound(|sig| sig.inputs()[0]), None)
846+
(def_id, args.as_closure().sig().map_bound(|sig| sig.inputs()[0]), false)
847847
}
848848
ty::CoroutineClosure(def_id, args) => (
849849
def_id,
850850
args.as_coroutine_closure()
851851
.coroutine_closure_sig()
852852
.map_bound(|sig| sig.tupled_inputs_ty),
853-
Some(args.as_coroutine_closure().coroutine_captures_by_ref_ty()),
853+
!args.as_coroutine_closure().tupled_upvars_ty().is_ty_var()
854+
&& args.as_coroutine_closure().has_self_borrows(),
854855
),
855856
_ => return None,
856857
};
@@ -884,10 +885,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
884885
// If the closure has captures, then perhaps the reason that the trait
885886
// is unimplemented is because async closures don't implement `Fn`/`FnMut`
886887
// if they have captures.
887-
if let Some(by_ref_captures) = by_ref_captures
888-
&& let ty::FnPtr(sig_tys, _) = by_ref_captures.kind()
889-
&& !sig_tys.skip_binder().output().is_unit()
890-
{
888+
if has_self_borrows && expected_kind != ty::ClosureKind::FnOnce {
891889
let mut err = self.dcx().create_err(AsyncClosureNotFn {
892890
span: self.tcx.def_span(closure_def_id),
893891
kind: expected_kind.as_str(),
@@ -1503,11 +1501,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
15031501
return None;
15041502
};
15051503

1506-
let Ok(Some(ImplSource::UserDefined(impl_data))) = SelectionContext::new(self)
1507-
.poly_select(&obligation.with(
1508-
self.tcx,
1509-
predicate.kind().rebind(proj.projection_term.trait_ref(self.tcx)),
1510-
))
1504+
let trait_ref = self.enter_forall_and_leak_universe(
1505+
predicate.kind().rebind(proj.projection_term.trait_ref(self.tcx)),
1506+
);
1507+
let Ok(Some(ImplSource::UserDefined(impl_data))) =
1508+
SelectionContext::new(self).select(&obligation.with(self.tcx, trait_ref))
15111509
else {
15121510
return None;
15131511
};

compiler/rustc_trait_selection/src/solve/select.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_infer::traits::solve::inspect::ProbeKind;
55
use rustc_infer::traits::solve::{CandidateSource, Certainty, Goal};
66
use rustc_infer::traits::{
77
BuiltinImplSource, ImplSource, ImplSourceUserDefinedData, Obligation, ObligationCause,
8-
PolyTraitObligation, Selection, SelectionError, SelectionResult,
8+
Selection, SelectionError, SelectionResult, TraitObligation,
99
};
1010
use rustc_macros::extension;
1111
use rustc_middle::{bug, span_bug};
@@ -17,7 +17,7 @@ use crate::solve::inspect::{self, ProofTreeInferCtxtExt};
1717
impl<'tcx> InferCtxt<'tcx> {
1818
fn select_in_new_trait_solver(
1919
&self,
20-
obligation: &PolyTraitObligation<'tcx>,
20+
obligation: &TraitObligation<'tcx>,
2121
) -> SelectionResult<'tcx, Selection<'tcx>> {
2222
assert!(self.next_trait_solver());
2323

compiler/rustc_trait_selection/src/traits/project.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>(
378378
term: projected_term,
379379
obligations: mut projected_obligations,
380380
})) => {
381+
debug!("opt_normalize_projection_type: progress");
381382
// if projection succeeded, then what we get out of this
382383
// is also non-normalized (consider: it was derived from
383384
// an impl, where-clause etc) and hence we must
@@ -408,6 +409,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>(
408409
Ok(Some(result.value))
409410
}
410411
Ok(Projected::NoProgress(projected_ty)) => {
412+
debug!("opt_normalize_projection_type: no progress");
411413
let result =
412414
Normalized { value: projected_ty, obligations: PredicateObligations::new() };
413415
infcx.inner.borrow_mut().projection_cache().insert_term(cache_key, result.clone());
@@ -621,8 +623,17 @@ struct Progress<'tcx> {
621623
}
622624

623625
impl<'tcx> Progress<'tcx> {
624-
fn error(tcx: TyCtxt<'tcx>, guar: ErrorGuaranteed) -> Self {
625-
Progress { term: Ty::new_error(tcx, guar).into(), obligations: PredicateObligations::new() }
626+
fn error_for_term(
627+
tcx: TyCtxt<'tcx>,
628+
alias_term: ty::AliasTerm<'tcx>,
629+
guar: ErrorGuaranteed,
630+
) -> Self {
631+
let err_term = if alias_term.kind(tcx).is_type() {
632+
Ty::new_error(tcx, guar).into()
633+
} else {
634+
ty::Const::new_error(tcx, guar).into()
635+
};
636+
Progress { term: err_term, obligations: PredicateObligations::new() }
626637
}
627638

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

652663
if let Err(guar) = obligation.predicate.error_reported() {
653-
return Ok(Projected::Progress(Progress::error(selcx.tcx(), guar)));
664+
return Ok(Projected::Progress(Progress::error_for_term(
665+
selcx.tcx(),
666+
obligation.predicate,
667+
guar,
668+
)));
654669
}
655670

656671
let mut candidates = ProjectionCandidateSet::None;
@@ -1965,7 +1980,13 @@ fn confirm_impl_candidate<'cx, 'tcx>(
19651980
let param_env = obligation.param_env;
19661981
let assoc_term = match specialization_graph::assoc_def(tcx, impl_def_id, assoc_item_id) {
19671982
Ok(assoc_term) => assoc_term,
1968-
Err(guar) => return Ok(Projected::Progress(Progress::error(tcx, guar))),
1983+
Err(guar) => {
1984+
return Ok(Projected::Progress(Progress::error_for_term(
1985+
tcx,
1986+
obligation.predicate,
1987+
guar,
1988+
)));
1989+
}
19691990
};
19701991

19711992
// This means that the impl is missing a definition for the

compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
265265
&mut self,
266266
obligation: &PolyTraitObligation<'tcx>,
267267
) -> SelectionResult<'tcx, Selection<'tcx>> {
268-
if self.infcx.next_trait_solver() {
269-
return self.infcx.select_in_new_trait_solver(obligation);
270-
}
268+
assert!(!self.infcx.next_trait_solver());
271269

272270
let candidate = match self.select_from_obligation(obligation) {
273271
Err(SelectionError::Overflow(OverflowError::Canonical)) => {
@@ -299,6 +297,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
299297
&mut self,
300298
obligation: &TraitObligation<'tcx>,
301299
) -> SelectionResult<'tcx, Selection<'tcx>> {
300+
if self.infcx.next_trait_solver() {
301+
return self.infcx.select_in_new_trait_solver(obligation);
302+
}
303+
302304
self.poly_select(&Obligation {
303305
cause: obligation.cause.clone(),
304306
param_env: obligation.param_env,

library/core/src/ptr/const_ptr.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,13 @@ impl<T: ?Sized> *const T {
7676
/// ```rust
7777
/// #![feature(pointer_try_cast_aligned)]
7878
///
79-
/// let aligned: *const u8 = 0x1000 as _;
79+
/// let x = 0u64;
8080
///
81-
/// // i32 has at most 4-byte alignment, so this will succeed
82-
/// assert!(aligned.try_cast_aligned::<i32>().is_some());
81+
/// let aligned: *const u64 = &x;
82+
/// let unaligned = unsafe { aligned.byte_add(1) };
8383
///
84-
/// let unaligned: *const u8 = 0x1001 as _;
85-
///
86-
/// // i32 has at least 2-byte alignment, so this will fail
87-
/// assert!(unaligned.try_cast_aligned::<i32>().is_none());
84+
/// assert!(aligned.try_cast_aligned::<u32>().is_some());
85+
/// assert!(unaligned.try_cast_aligned::<u32>().is_none());
8886
/// ```
8987
#[unstable(feature = "pointer_try_cast_aligned", issue = "141221")]
9088
#[must_use = "this returns the result of the operation, \

library/core/src/ptr/mut_ptr.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,13 @@ impl<T: ?Sized> *mut T {
5858
/// ```rust
5959
/// #![feature(pointer_try_cast_aligned)]
6060
///
61-
/// let aligned: *mut u8 = 0x1000 as _;
61+
/// let mut x = 0u64;
6262
///
63-
/// // i32 has at most 4-byte alignment, so this will succeed
64-
/// assert!(aligned.try_cast_aligned::<i32>().is_some());
63+
/// let aligned: *mut u64 = &mut x;
64+
/// let unaligned = unsafe { aligned.byte_add(1) };
6565
///
66-
/// let unaligned: *mut u8 = 0x1001 as _;
67-
///
68-
/// // i32 has at least 2-byte alignment, so this will fail
69-
/// assert!(unaligned.try_cast_aligned::<i32>().is_none());
66+
/// assert!(aligned.try_cast_aligned::<u32>().is_some());
67+
/// assert!(unaligned.try_cast_aligned::<u32>().is_none());
7068
/// ```
7169
#[unstable(feature = "pointer_try_cast_aligned", issue = "141221")]
7270
#[must_use = "this returns the result of the operation, \

library/core/src/ptr/non_null.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -501,15 +501,13 @@ impl<T: ?Sized> NonNull<T> {
501501
/// #![feature(pointer_try_cast_aligned)]
502502
/// use std::ptr::NonNull;
503503
///
504-
/// let aligned: NonNull<u8> = NonNull::new(0x1000 as _).unwrap();
504+
/// let mut x = 0u64;
505505
///
506-
/// // i32 has at most 4-byte alignment, so this will succeed
507-
/// assert!(aligned.try_cast_aligned::<i32>().is_some());
506+
/// let aligned = NonNull::from_mut(&mut x);
507+
/// let unaligned = unsafe { aligned.byte_add(1) };
508508
///
509-
/// let unaligned: NonNull<u8> = NonNull::new(0x1001 as _).unwrap();
510-
///
511-
/// // i32 has at least 2-byte alignment, so this will fail
512-
/// assert!(unaligned.try_cast_aligned::<i32>().is_none());
509+
/// assert!(aligned.try_cast_aligned::<u32>().is_some());
510+
/// assert!(unaligned.try_cast_aligned::<u32>().is_none());
513511
/// ```
514512
#[unstable(feature = "pointer_try_cast_aligned", issue = "141221")]
515513
#[must_use = "this returns the result of the operation, \

0 commit comments

Comments
 (0)