Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3440,7 +3440,6 @@ name = "replace-version-placeholder"
version = "0.1.0"
dependencies = [
"tidy",
"walkdir",
]

[[package]]
Expand Down
31 changes: 22 additions & 9 deletions compiler/rustc_codegen_llvm/src/va_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,15 +1061,28 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
let stability = target.supports_c_variadic_definitions();

match target.arch {
Arch::X86 => emit_ptr_va_arg(
bx,
addr,
layout,
PassMode::Direct,
SlotSize::Bytes4,
if target.is_like_windows { AllowHigherAlign::No } else { AllowHigherAlign::Yes },
ForceRightAdjust::No,
),
Arch::X86 => {
// A small deviation from clang to get the right behavior for f128.
//
// Note that i64 and f64 have an alignment of only 4 on this architecture.
// We need to be careful when adding future types with an alignment bigger
// than 4 (e.g. i128), clang has a bunch of custom logic for them.
let allow_higher_align = if layout.ty == bx.tcx().types.f128 {
AllowHigherAlign::Yes
} else {
AllowHigherAlign::No
};

emit_ptr_va_arg(
bx,
addr,
layout,
PassMode::Direct,
SlotSize::Bytes4,
allow_higher_align,
ForceRightAdjust::No,
)
}
Arch::Arm64EC => emit_ptr_va_arg(
bx,
addr,
Expand Down
130 changes: 113 additions & 17 deletions compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,12 +638,119 @@ where
source: GoalSource,
goal: Goal<I, I::Predicate>,
) -> Result<GoalEvaluation<I>, NoSolutionOrRerunNonErased> {
let (normalization_nested_goals, goal_evaluation) =
self.evaluate_goal_raw(source, goal, LowerAvailableDepth::Yes)?;
let (normalization_nested_goals, goal_evaluation) = self.evaluate_goal_raw(source, goal)?;
assert!(normalization_nested_goals.is_empty());
Ok(goal_evaluation)
}

fn evaluate_in_search_graph(
&mut self,
canonical_goal: I::CanonicalInput,
step_kind: PathKind,
) -> (Result<CanonicalResponse<I>, NoSolution>, AccessedOpaques<I>) {
let increase_depth_for_nested =
match canonical_goal.canonical.value.goal.predicate.kind().skip_binder() {
// We don't lower the available depth for the `NormalizesTo` goal, as evaluating
// it is an extra step only exists in the new solver that behaves like a function
// call rather than an independent nested goal evaluation. So, decreasing the
// available depth may end up regressions which hit the recursion limits for crates
// compiled well with the old solver.
ty::PredicateKind::NormalizesTo(_) => LowerAvailableDepth::No,
// We also don't lower depth for witness and rigid opaque when proving auto traits.
// This is to mitigate the overflow FCW warnings in deeply nested async calls.
// See #159228.
//
// We're eventually going to remove the witness type so it's okay to ignore the
// depth.
// For rigid opaques, revealing hidden types can be viewed as normalization so it's
// consistent with the `NormalizesTo` reasoning above.
ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => {
if self.cx().trait_is_auto(pred.trait_ref.def_id) {
match pred.self_ty().kind() {
ty::CoroutineWitness(..) => LowerAvailableDepth::No,
ty::Alias(
ty::IsRigid::Yes,
ty::AliasTy { kind: ty::Opaque { def_id, .. }, .. },
) => {
// We only want to skip lowering depth when the proving is done via
// auto trait leakage. If the goal can be proved via item bounds,
// we should lower depth faithfully.
//
// FIXME: We can have param env candidates via TAIT or RTN.
// Ideally we'd instead lower the depth for the nested goal instead.
// Implementing this is a bit harder.
if self
.cx()
.item_self_bounds(def_id.into())
.skip_binder()
.into_iter()
.any(|bound| {
bound
.as_trait_clause()
.is_some_and(|b| b.def_id() == pred.def_id())
})
{
LowerAvailableDepth::Yes
} else {
LowerAvailableDepth::No
}
}
ty::Bool
| ty::Char
| ty::Int(..)
| ty::Uint(..)
| ty::Float(..)
| ty::Str
| ty::Pat(..)
| ty::FnPtr(..)
| ty::Array(..)
| ty::Slice(..)
| ty::RawPtr(..)
| ty::Never
| ty::Tuple(..)
| ty::UnsafeBinder(_)
| ty::Param(..)
| ty::Placeholder(..)
| ty::Bound(..)
| ty::Infer(..)
| ty::Alias(_, _)
| ty::Ref(_, _, _)
| ty::Adt(_, _)
| ty::Foreign(_)
| ty::Dynamic(..)
| ty::Error(_)
| ty::FnDef(..)
| ty::Closure(..)
| ty::CoroutineClosure(..)
| ty::Coroutine(..) => LowerAvailableDepth::Yes,
}
} else {
LowerAvailableDepth::Yes
}
}
ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(_))
| ty::PredicateKind::Clause(ty::ClauseKind::Projection(_))
| ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(_))
| ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(_))
| ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(_, _))
| ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(_))
| ty::PredicateKind::Subtype(_)
| ty::PredicateKind::Coerce(_)
| ty::PredicateKind::DynCompatible(_)
| ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_))
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(_))
| ty::PredicateKind::ConstEquate(_, _)
| ty::PredicateKind::Ambiguous => LowerAvailableDepth::Yes,
};
self.search_graph.evaluate_goal(
self.cx(),
canonical_goal,
step_kind,
increase_depth_for_nested,
&mut inspect::ProofTreeBuilder::new_noop(),
)
}

/// Recursively evaluates `goal`, returning the nested goals in case
/// the nested goal is a `NormalizesTo` goal.
///
Expand All @@ -655,7 +762,6 @@ where
&mut self,
source: GoalSource,
goal: Goal<I, I::Predicate>,
increase_depth_for_nested: LowerAvailableDepth,
) -> Result<(NestedNormalizationGoals<I>, GoalEvaluation<I>), NoSolutionOrRerunNonErased> {
// We only care about one entry per `OpaqueTypeKey` here,
// so we only canonicalize the lookup table and ignore
Expand Down Expand Up @@ -723,13 +829,8 @@ where
TypingMode::ErasedNotCoherence(MayBeErased),
);

let (canonical_result, accessed_opaques) = self.search_graph.evaluate_goal(
self.cx(),
canonical_goal,
step_kind,
increase_depth_for_nested,
&mut inspect::ProofTreeBuilder::new_noop(),
);
let (canonical_result, accessed_opaques) =
self.evaluate_in_search_graph(canonical_goal, step_kind);

let should_rerun = should_rerun_after_erased_canonicalization(
accessed_opaques,
Expand Down Expand Up @@ -763,13 +864,8 @@ where
let (orig_values, canonical_goal) =
canonicalize_goal(self.delegate, goal, &opaque_types, typing_mode);

let (canonical_result, accessed_opaques) = self.search_graph.evaluate_goal(
self.cx(),
canonical_goal,
step_kind,
increase_depth_for_nested,
&mut inspect::ProofTreeBuilder::new_noop(),
);
let (canonical_result, accessed_opaques) =
self.evaluate_in_search_graph(canonical_goal, step_kind);
assert!(
!accessed_opaques.might_rerun(),
"we run without TypingMode::ErasedNotCoherence, so opaques are available, and we don't retry if the outer typing mode is ErasedNotCoherence: {accessed_opaques:?} after {goal:?}"
Expand Down
12 changes: 1 addition & 11 deletions compiler/rustc_next_trait_solver/src/solve/project_goals/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ mod free_alias;
mod inherent;
mod opaque_types;

use rustc_type_ir::search_graph::LowerAvailableDepth;
use rustc_type_ir::solve::QueryResultOrRerunNonErased;
use rustc_type_ir::{self as ty, Interner, ProjectionClause};
use tracing::{instrument, trace};
Expand Down Expand Up @@ -70,16 +69,7 @@ where
let (
NestedNormalizationGoals(nested_goals),
GoalEvaluation { goal: _, certainty, stalled_on: _, has_changed: _ },
) = self.evaluate_goal_raw(
GoalSource::TypeRelating,
normalizes_to,
// We don't lower thr available depth for this `NormalizesTo` goal, as evaluating
// it is an extra step only exists in the new solver that behaves like a function
// call rather than an independent nested goal evaluation. So, decreasing the
// available depth may end up regressions which hit the recursion limits for crates
// compiled well with the old solver.
LowerAvailableDepth::No,
)?;
) = self.evaluate_goal_raw(GoalSource::TypeRelating, normalizes_to)?;

trace!(?nested_goals);

Expand Down
12 changes: 12 additions & 0 deletions compiler/rustc_ty_utils/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,18 @@ fn layout_of_uncached<'tcx>(
abi::Integer::discr_range_of_repr(tcx, ty, &def.repr(), min.start, max.last)
};

// We shouldn't be computing the layout of discrs that fail typeck
if def.is_enum() {
for v in def.variants() {
if let ty::VariantDiscr::Explicit(def_id) = v.discr
&& let Some(local_did) = def_id.as_local()
&& let Some(guar) = tcx.typeck(local_did).tainted_by_errors
{
return Err(error(cx, LayoutError::ReferencesError(guar)));
}
}
}

let discriminants_iter = || {
def.is_enum()
.then(|| def.discriminants(tcx).map(|(v, d)| (v, d.val)))
Expand Down
1 change: 0 additions & 1 deletion src/tools/build-manifest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ rayon = "1.5.1"
hex = "0.4.2"

[build-dependencies]
serde = "1"
serde_json = "1"
4 changes: 3 additions & 1 deletion src/tools/jsondoclint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ edition = "2024"
anyhow = "1.0.62"
clap = { version = "4.0.15", features = ["derive"] }
fs-err = "2.8.1"
rustc-hash = "2.0.0"
rustdoc-json-types = { version = "0.1.0", path = "../../rustdoc-json-types" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.85"

[dev-dependencies]
rustc-hash = "2.0.0"
2 changes: 1 addition & 1 deletion src/tools/remote-test-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ name = "remote-test-client"
version = "0.1.0"
edition = "2021"

[dependencies]
[dev-dependencies]
assert_cmd = "2"
1 change: 0 additions & 1 deletion src/tools/replace-version-placeholder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ edition = "2021"

[dependencies]
tidy = { path = "../tidy" }
walkdir = "2"
Loading
Loading