Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
63c15e4
test: cover current if let closure capture behavior
Embers-of-the-Fire Mar 22, 2026
923ef1f
fix: drop eager if let scrutinee borrow during capture analysis
Embers-of-the-Fire Mar 22, 2026
665416d
test(ui): add regression for if-let closure capture size
Embers-of-the-Fire Mar 22, 2026
2aadcee
feat: remove callback param for walk_local method
Embers-of-the-Fire Mar 22, 2026
1f81a55
test: add if let test for partial capture
Embers-of-the-Fire Apr 18, 2026
f491a6c
test(miri): add if-let closure capture UB smoke tests
Embers-of-the-Fire May 21, 2026
0e87c76
Adding diagnostic markers for multiple fs functions
asder8215 Aug 4, 2026
e6b20c8
diagnostics: unify foreign-trait label for ADT and primitive types in…
Omar1H1 Aug 8, 2026
f3381d2
Allow `Subcommand::Fix` to have fields
Zalathar Aug 17, 2026
e9963a8
Allow `./x fix --allow-dirty`
Zalathar Aug 17, 2026
5898a39
Initial implementation of `FnPtr` trait
carbotaniuman Aug 18, 2026
6064370
rename `ProjectionPredicate` to `ProjectionClause`
ada4a Aug 18, 2026
169bd22
rename `TraitPredicate` to `TraitClause`
ada4a Aug 12, 2026
951f07a
Rename test so it matches the issue
aerooneqq Aug 18, 2026
8408993
Enable overflow checks in `rustc_thread_pool`
aerooneqq Aug 18, 2026
f662772
Rollup merge of #154210 - Embers-of-the-Fire:feat/if-let-no-full-capt…
JonathanBrouwer Aug 18, 2026
d538404
Rollup merge of #156176 - carbotaniuman:fn-ptr-trait-impl, r=jackh726
JonathanBrouwer Aug 18, 2026
550bb30
Rollup merge of #160767 - Omar1H1:diagnostics/e0117-label-fix, r=petr…
JonathanBrouwer Aug 18, 2026
a60ccc5
Rollup merge of #160489 - asder8215:fs_diagnostic_items, r=mejrs
JonathanBrouwer Aug 18, 2026
34e5322
Rollup merge of #161220 - Zalathar:allow-dirty, r=Kobzol
JonathanBrouwer Aug 18, 2026
35ff04c
Rollup merge of #161291 - ada4a:push-xqqtloltnvwu, r=oli-obk
JonathanBrouwer Aug 18, 2026
5d558b6
Rollup merge of #161296 - aerooneqq:try-enable-overflow-checks, r=pet…
JonathanBrouwer Aug 18, 2026
44e28d9
Rollup merge of #161304 - aerooneqq:rename-test, r=lqd
JonathanBrouwer Aug 18, 2026
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
7 changes: 0 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ exclude = [
"obj",
]

[profile.release.package.rustc_thread_pool]
# The rustc fork of Rayon has deadlock detection code which intermittently
# causes overflows in the CI (see https://github.com/rust-lang/rust/issues/90227)
# so we turn overflow checks off for now.
# FIXME: This workaround should be removed once #90227 is fixed.
overflow-checks = false

# These are very thin wrappers around executing lld with the right binary name.
# Basically nothing within them can go wrong without having been explicitly logged anyway.
# We ship these in every rustc tarball and even after compression they add up
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_attr_ir/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,15 @@ language_item_table! {
Metadata, sym::metadata_type, metadata_type, Target::AssocTy, GenericRequirement::None;
DynMetadata, sym::dyn_metadata, dyn_metadata, Target::Struct, GenericRequirement::None;

NonNull, sym::non_null, non_null_trait, Target::Struct, GenericRequirement::Exact(1);

Freeze, sym::freeze, freeze_trait, Target::Trait, GenericRequirement::Exact(0);
UnsafeUnpin, sym::unsafe_unpin, unsafe_unpin_trait, Target::Trait, GenericRequirement::Exact(0);

FnPtrTrait, sym::fn_ptr_trait, fn_ptr_trait, Target::Trait, GenericRequirement::Exact(0);
FnPtrAddr, sym::fn_ptr_addr, fn_ptr_addr, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
FnPtrAsPtr, sym::fn_ptr_as_ptr, fn_ptr_as_ptr, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
FnPtrFromPtr, sym::fn_ptr_from_ptr, fn_ptr_from_ptr, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
Code, sym::code, code, Target::ForeignTy, GenericRequirement::None;

Drop, sym::drop, drop_trait, Target::Trait, GenericRequirement::None;
Destruct, sym::destruct, destruct_trait, Target::Trait, GenericRequirement::None;
Expand Down Expand Up @@ -245,6 +249,7 @@ language_item_table! {
Fn, kw::Fn, fn_trait, Target::Trait, GenericRequirement::Exact(1);
FnMut, sym::fn_mut, fn_mut_trait, Target::Trait, GenericRequirement::Exact(1);
FnOnce, sym::fn_once, fn_once_trait, Target::Trait, GenericRequirement::Exact(1);
FnStatic, sym::fn_static, fn_static_trait, Target::Trait, GenericRequirement::Exact(1);

AsyncFn, sym::async_fn, async_fn_trait, Target::Trait, GenericRequirement::Exact(1);
AsyncFnMut, sym::async_fn_mut, async_fn_mut_trait, Target::Trait, GenericRequirement::Exact(1);
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,9 @@ impl SingleAttributeParser for LangParser {
return None;
};

// Only weak lang items may be applied to foreign items
if [Target::ForeignFn, Target::ForeignStatic, Target::ForeignTy, Target::ForeignMod]
.contains(&cx.target)
// Only weak lang items may be applied to foreign items,
// except for `ForeignTy` which can be a normal lang item.
if [Target::ForeignFn, Target::ForeignStatic, Target::ForeignMod].contains(&cx.target)
&& !lang_item.is_weak()
{
cx.emit_err(UnknownExternLangItem { span: cx.attr_span, lang_item: lang_item.name() });
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
if !clauses.instantiate_identity(tcx).clauses.iter().any(|clause| {
clause.as_trait_clause().is_some_and(|tc| {
tc.self_ty().skip_binder().is_param(param.index)
&& tc.polarity() == ty::PredicatePolarity::Positive
&& tc.polarity() == ty::ClausePolarity::Positive
&& supertrait_def_ids(tcx, tc.def_id())
.flat_map(|trait_did| tcx.associated_items(trait_did).in_definition_order())
.any(|item| item.is_method())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
tcx.clauses_of(callee_def_id).instantiate(tcx, generic_args).clauses.iter().any(
|clause| {
clause.as_trait_clause().is_some_and(|trait_pred| {
trait_pred.polarity() == ty::PredicatePolarity::Positive
trait_pred.polarity() == ty::ClausePolarity::Positive
&& tcx.fn_trait_kind_from_def_id(trait_pred.def_id())
== Some(ty::ClosureKind::Fn)
&& trait_pred.self_ty().skip_binder().peel_refs()
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/type_check/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
category: ConstraintCategory<'tcx>,
) {
self.prove_clause(
ty::ClauseKind::Trait(ty::TraitPredicate {
ty::ClauseKind::Trait(ty::TraitClause {
trait_ref,
polarity: ty::PredicatePolarity::Positive,
polarity: ty::ClausePolarity::Positive,
}),
locations,
category,
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_const_eval/src/interpret/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
| ty::InstanceKind::Shim(ty::ShimKind::FnPtr(..))
| ty::InstanceKind::Shim(ty::ShimKind::DropGlue(..))
| ty::InstanceKind::Shim(ty::ShimKind::Clone(..))
| ty::InstanceKind::Shim(ty::ShimKind::FnPtrAddr(..))
| ty::InstanceKind::Shim(ty::ShimKind::FnPtrAsPtr(..))
| ty::InstanceKind::Shim(ty::ShimKind::FnPtrFromPtr(..))
| ty::InstanceKind::Shim(ty::ShimKind::ThreadLocal(..))
| ty::InstanceKind::Shim(ty::ShimKind::AsyncDropGlueCtor(..))
| ty::InstanceKind::Shim(ty::ShimKind::AsyncDropGlue(..))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ impl<O: ForestObligation> ObligationForest<O> {
/// A few post-processing that you might want to do make the forest easier to visualize:
///
/// * `sed 's,std::[a-z]*::,,g'` — Deletes the `std::<package>::` prefix of paths.
/// * `sed 's,"Binder(TraitPredicate(<\(.*\)>)) (\([^)]*\))","\1 (\2)",'` — Transforms
/// `Binder(TraitPredicate(<predicate>))` into just `<predicate>`.
/// * `sed 's,"Binder(TraitClause(<\(.*\)>)) (\([^)]*\))","\1 (\2)",'` — Transforms
/// `Binder(TraitClause(<predicate>))` into just `<predicate>`.
#[allow(dead_code)]
pub fn dump_graphviz<P: AsRef<Path>>(&self, dir: P, description: &str) {
static COUNTER: AtomicUsize = AtomicUsize::new(0);
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ declare_features! (
(unstable, fn_align, "1.53.0", Some(82232)),
/// Support delegating implementation of functions to other already implemented functions.
(incomplete, fn_delegation, "1.76.0", Some(118212)),
/// Traits for function pointers and items
(unstable, fn_static, "CURRENT_RUSTC_VERSION", Some(148768)),
/// Allows impls for the Freeze trait.
(internal, freeze_impls, "1.78.0", Some(121675)),
/// Frontmatter `---` blocks for use by external tools.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2726,7 +2726,7 @@ fn param_env_with_gat_bounds<'tcx>(
}
_ => clauses.push(
ty::Binder::bind_with_vars(
ty::ProjectionPredicate {
ty::ProjectionClause {
projection_term: ty::AliasTerm::new_from_def_id(
tcx,
trait_ty.def_id,
Expand Down
26 changes: 17 additions & 9 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ fn check_impl<'tcx>(
trait_ref,
);
let trait_pred =
ty::TraitPredicate { trait_ref, polarity: ty::PredicatePolarity::Positive };
ty::TraitClause { trait_ref, polarity: ty::ClausePolarity::Positive };
let mut obligations = traits::wf::trait_obligations(
wfcx.infcx,
wfcx.param_env,
Expand Down Expand Up @@ -1800,14 +1800,22 @@ fn check_method_receiver<'tcx>(
{
match receiver_validity_err {
ReceiverValidityError::DoesNotDeref if arbitrary_self_types_level.is_some() => {
let hint = match receiver_ty
.builtin_deref(false)
.unwrap_or(receiver_ty)
.ty_adt_def()
.and_then(|adt_def| tcx.get_diagnostic_name(adt_def.did()))
{
Some(sym::RcWeak | sym::ArcWeak) => Some(InvalidReceiverTyHint::Weak),
Some(sym::NonNull) => Some(InvalidReceiverTyHint::NonNull),
let adt_def =
receiver_ty.builtin_deref(false).unwrap_or(receiver_ty).ty_adt_def();

let hint = match adt_def {
Some(adt) => {
if tcx.is_lang_item(adt.did(), LangItem::NonNull) {
Some(InvalidReceiverTyHint::NonNull)
} else {
match tcx.get_diagnostic_name(adt.did()) {
Some(sym::RcWeak | sym::ArcWeak) => {
Some(InvalidReceiverTyHint::Weak)
}
_ => None,
}
}
}
_ => None,
};

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/coherence/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -924,9 +924,9 @@ fn infringing_fields_error<'tcx>(
.or_default()
.push(error.obligation.cause.span);
}
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitPredicate {
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitClause {
trait_ref,
polarity: ty::PredicatePolarity::Positive,
polarity: ty::ClausePolarity::Positive,
..
})) = error_predicate.kind().skip_binder()
{
Expand Down
18 changes: 13 additions & 5 deletions compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,21 @@ fn emit_orphan_check_error<'tcx>(
});
}
ty::Adt(adt_def, _) => {
diag.subdiagnostic(diagnostics::OnlyCurrentTraitsAdt {
span,
name: tcx.def_path_str(adt_def.did()),
});
if is_foreign {
diag.subdiagnostic(diagnostics::OnlyCurrentTraitsForeign { span });
} else {
diag.subdiagnostic(diagnostics::OnlyCurrentTraitsAdt {
span,
name: tcx.def_path_str(adt_def.did()),
});
}
}
_ => {
diag.subdiagnostic(diagnostics::OnlyCurrentTraitsTy { span, ty });
if is_foreign {
diag.subdiagnostic(diagnostics::OnlyCurrentTraitsForeign { span });
} else {
diag.subdiagnostic(diagnostics::OnlyCurrentTraitsTy { span, ty });
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/collect/clauses_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ pub(super) fn implied_clauses_with_filter<'tcx>(
for &(clause, span) in implied_bounds {
debug!("superbound: {:?}", clause);
if let ty::ClauseKind::Trait(bound) = clause.kind().skip_binder()
&& bound.polarity == ty::PredicatePolarity::Positive
&& bound.polarity == ty::ClausePolarity::Positive
{
tcx.at(span).explicit_super_clauses_of(bound.def_id());
}
Expand All @@ -730,7 +730,7 @@ pub(super) fn implied_clauses_with_filter<'tcx>(
for &(clause, span) in implied_bounds {
debug!("superbound: {:?}", clause);
if let ty::ClauseKind::Trait(bound) = clause.kind().skip_binder()
&& bound.polarity == ty::PredicatePolarity::Positive
&& bound.polarity == ty::ClausePolarity::Positive
{
tcx.at(span).explicit_implied_clauses_of(bound.def_id());
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
| PredicateFilter::SelfOnly
| PredicateFilter::SelfAndAssociatedTypeBounds => {
let bound = projection_term.map_bound(|projection_term| {
ty::ClauseKind::Projection(ty::ProjectionPredicate {
ty::ClauseKind::Projection(ty::ProjectionClause {
projection_term,
term,
})
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {

if let Some((principal_trait, ref spans)) = principal_trait {
let principal_trait = principal_trait.map_bound(|trait_pred| {
assert_eq!(trait_pred.polarity, ty::PredicatePolarity::Positive);
assert_eq!(trait_pred.polarity, ty::ClausePolarity::Positive);
trait_pred.trait_ref
});

Expand Down Expand Up @@ -350,7 +350,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let principal_trait_ref = principal_trait.map(|(trait_pred, spans)| {
trait_pred.map_bound(|trait_pred| {
let trait_ref = trait_pred.trait_ref;
assert_eq!(trait_pred.polarity, ty::PredicatePolarity::Positive);
assert_eq!(trait_pred.polarity, ty::ClausePolarity::Positive);
assert_eq!(trait_ref.self_ty(), dummy_self);

let span = *spans.first().unwrap();
Expand Down Expand Up @@ -423,7 +423,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let mut auto_trait_predicates: Vec<_> = auto_traits
.into_iter()
.map(|(trait_pred, _)| {
assert_eq!(trait_pred.polarity(), ty::PredicatePolarity::Positive);
assert_eq!(trait_pred.polarity(), ty::ClausePolarity::Positive);
assert_eq!(trait_pred.self_ty().skip_binder(), dummy_self);

ty::Binder::dummy(ty::ExistentialPredicate::AutoTrait(trait_pred.def_id()))
Expand Down Expand Up @@ -476,7 +476,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
/// `elaborated-predicates-unconstrained-late-bound.rs` for a test.
fn check_elaborated_projection_mentions_input_lifetimes(
&self,
pred: ty::PolyProjectionPredicate<'tcx>,
pred: ty::PolyProjectionClause<'tcx>,
span: Span,
supertrait_span: Span,
) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {

pub fn report_trait_object_addition_traits(
&self,
regular_traits: &Vec<(ty::PolyTraitPredicate<'tcx>, SmallVec<[Span; 1]>)>,
regular_traits: &Vec<(ty::PolyTraitClause<'tcx>, SmallVec<[Span; 1]>)>,
) -> ErrorGuaranteed {
// we use the last span to point at the traits themselves,
// and all other preceding spans are trait alias expansions.
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,9 +996,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {

let polarity = match polarity {
hir::BoundPolarity::Positive | hir::BoundPolarity::Maybe(_) => {
ty::PredicatePolarity::Positive
ty::ClausePolarity::Positive
}
hir::BoundPolarity::Negative(_) => ty::PredicatePolarity::Negative,
hir::BoundPolarity::Negative(_) => ty::ClausePolarity::Negative,
};

let [leading_segments @ .., segment] = trait_ref.path.segments else { bug!() };
Expand Down Expand Up @@ -1047,7 +1047,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
| PredicateFilter::SelfTraitThatDefines(..)
| PredicateFilter::SelfAndAssociatedTypeBounds => {
let bound = poly_trait_ref.map_bound(|trait_ref| {
ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref, polarity })
ty::ClauseKind::Trait(ty::TraitClause { trait_ref, polarity })
});
let bound = (bound.upcast(tcx), span);
// FIXME(-Znext-solver): We can likely remove this hack once the
Expand Down Expand Up @@ -1102,7 +1102,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
| PredicateFilter::SelfAndAssociatedTypeBounds => {
match constness {
hir::BoundConstness::Always(_) => {
if polarity == ty::PredicatePolarity::Positive {
if polarity == ty::ClausePolarity::Positive {
bounds.push((
poly_trait_ref
.to_host_effect_clause(tcx, ty::BoundConstness::Const),
Expand All @@ -1128,7 +1128,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {
match constness {
hir::BoundConstness::Maybe(_) => {
if polarity == ty::PredicatePolarity::Positive {
if polarity == ty::ClausePolarity::Positive {
bounds.push((
poly_trait_ref
.to_host_effect_clause(tcx, ty::BoundConstness::Maybe),
Expand All @@ -1150,7 +1150,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// Don't register any associated item constraints for negative bounds,
// since we should have emitted an error for them earlier, and they
// would not be well-formed!
if polarity == ty::PredicatePolarity::Negative {
if polarity == ty::ClausePolarity::Negative {
self.dcx().span_delayed_bug(
constraint.span,
"negative trait bounds should not have assoc item constraints",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ fn check_specialization_on<'tcx>(
_ if clause.is_global() => Ok(()),
// We allow specializing on explicitly marked traits with no associated
// items.
ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref, polarity: _ }) => {
ty::ClauseKind::Trait(ty::TraitClause { trait_ref, polarity: _ }) => {
if matches!(
trait_specialization_kind(tcx, clause),
Some(TraitSpecializationKind::Marker)
Expand All @@ -433,7 +433,7 @@ fn check_specialization_on<'tcx>(
.emit())
}
}
ty::ClauseKind::Projection(ty::ProjectionPredicate { projection_term, term }) => Err(tcx
ty::ClauseKind::Projection(ty::ProjectionClause { projection_term, term }) => Err(tcx
.dcx()
.struct_span_err(
span,
Expand Down Expand Up @@ -463,7 +463,7 @@ fn trait_specialization_kind<'tcx>(
clause: ty::Clause<'tcx>,
) -> Option<TraitSpecializationKind> {
match clause.kind().skip_binder() {
ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref, polarity: _ }) => {
ty::ClauseKind::Trait(ty::TraitClause { trait_ref, polarity: _ }) => {
Some(tcx.trait_def(trait_ref.def_id).specialization_kind)
}
ty::ClauseKind::RegionOutlives(_)
Expand Down
Loading
Loading