Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6cfdd53
Stabilize `slice_as_chunks` library feature
scottmcm Apr 11, 2025
c49ddc0
Improve rustdocs on slice_as_chunks methods
scottmcm Apr 19, 2025
64c8d5d
move existing tests away from using boxes
dianne Mar 17, 2025
0eb3b11
lower deref patterns on boxes using built-in derefs
dianne Apr 17, 2025
4313318
update unstable book to mention moving out of boxes
dianne Apr 18, 2025
f319dd9
add llvm wrappers and corresponding methods in attribute
Shourya742 Apr 20, 2025
9bc0401
add custom enzyme markers to target methods
Shourya742 Apr 20, 2025
4e555fa
Test partial moves via deref pats
Nadrieril Apr 27, 2025
6ceeb08
Implement the internal feature `cfg_target_has_reliable_f16_f128`
tgross35 Apr 24, 2025
dfa972e
Use `feature(target_has_reliable_f16_f128)` in library tests
tgross35 Apr 26, 2025
3ab6051
Move inline_asm to typeck, properly handle aliases
compiler-errors Apr 25, 2025
f07cc40
Rename sub_ptr to offset_from_unsigned in docs
DaniPopes Apr 28, 2025
8fa5e3a
Make bootstrap git tests more self-contained
Kobzol Apr 28, 2025
7018392
remove noinline attribute and add alwaysinline after AD pass
Shourya742 Apr 20, 2025
fa90fea
only return nested goals for `Certainty::Yes`
lcnr Apr 28, 2025
016105c
review
lcnr Apr 28, 2025
105d1dc
Do not compute type_of for impl item if impl where clauses are unsati…
compiler-errors Apr 25, 2025
3c42dc2
Workaround for windows-gnu rust-lld test failure
ChrisDenton Apr 28, 2025
d4845e1
Rollup merge of #139308 - Shourya742:2025-03-29-add-autodiff-inline, …
ChrisDenton Apr 28, 2025
17495e0
Rollup merge of #139656 - scottmcm:stabilize-slice-as-chunks, r=dtolnay
ChrisDenton Apr 28, 2025
8dd26cb
Rollup merge of #140022 - dianne:box-deref-pats, r=Nadrieril
ChrisDenton Apr 28, 2025
0bd531a
Rollup merge of #140276 - compiler-errors:typeof-less-eagerly, r=lcnr
ChrisDenton Apr 28, 2025
3f5406f
Rollup merge of #140302 - compiler-errors:inline_asm-bug, r=lcnr
ChrisDenton Apr 28, 2025
e082bf3
Rollup merge of #140323 - tgross35:cfg-unstable-float, r=Urgau
ChrisDenton Apr 28, 2025
fd95953
Rollup merge of #140391 - DaniPopes:sub-ptr-rename, r=RalfJung
ChrisDenton Apr 28, 2025
ec2dad7
Rollup merge of #140394 - Kobzol:git-test-self-contained, r=jieyouxu
ChrisDenton Apr 28, 2025
469f03d
Rollup merge of #140396 - ChrisDenton:gnu-threads, r=jieyouxu
ChrisDenton Apr 28, 2025
bf37847
Rollup merge of #140402 - lcnr:normalizes-to-certainty-yes, r=compile…
ChrisDenton Apr 28, 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
Prev Previous commit
Next Next commit
only return nested goals for Certainty::Yes
  • Loading branch information
lcnr committed Apr 28, 2025
commit fa90feaeef28925eee53b296af11f06d0b29ab6e
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,19 @@ where
//
// As we return all ambiguous nested goals, we can ignore the certainty returned
// by `try_evaluate_added_goals()`.
let (certainty, normalization_nested_goals) = match self.current_goal_kind {
CurrentGoalKind::NormalizesTo => {
let (certainty, normalization_nested_goals) =
if matches!(self.current_goal_kind, CurrentGoalKind::NormalizesTo)
&& matches!(certainty, Certainty::Yes)
{
let goals = std::mem::take(&mut self.nested_goals);
if goals.is_empty() {
assert!(matches!(goals_certainty, Certainty::Yes));
}
(certainty, NestedNormalizationGoals(goals))
}
CurrentGoalKind::Misc | CurrentGoalKind::CoinductiveTrait => {
(Certainty::Yes, NestedNormalizationGoals(goals))
} else {
let certainty = certainty.unify_with(goals_certainty);
(certainty, NestedNormalizationGoals::empty())
}
};
};

if let Certainty::Maybe(cause @ MaybeCause::Overflow { .. }) = certainty {
// If we have overflow, it's probable that we're substituting a type
Expand Down
38 changes: 28 additions & 10 deletions compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod weak_types;
use rustc_type_ir::fast_reject::DeepRejectCtxt;
use rustc_type_ir::inherent::*;
use rustc_type_ir::lang_items::TraitSolverLangItem;
use rustc_type_ir::{self as ty, Interner, NormalizesTo, Upcast as _};
use rustc_type_ir::{self as ty, Interner, NormalizesTo, PredicateKind, Upcast as _};
use tracing::instrument;

use crate::delegate::SolverDelegate;
Expand Down Expand Up @@ -221,13 +221,21 @@ where
Ok(Some(target_item_def_id)) => target_item_def_id,
Ok(None) => {
match ecx.typing_mode() {
// In case the associated item is hidden due to specialization, we have to
// return ambiguity this would otherwise be incomplete, resulting in
// unsoundness during coherence (#105782).
// In case the associated item is hidden due to specialization,
// normalizing this associated item is always ambiguous. Treating
// the associated item as rigid would be incomplete and allow for
// overlapping impls, see #105782.
//
// As this ambiguity is unavoidable we emit a nested ambiguous
// goal instead of using `Certainty::AMBIGUOUS`. This allows us to
// return the nested goals to the parent `AliasRelate` goal. This
// would be relevant if any of the nested goals refer to the `term`.
// This is not the case here and we only prefer adding an ambiguous
// nested goal for consistency.
ty::TypingMode::Coherence => {
return ecx.evaluate_added_goals_and_make_canonical_response(
Certainty::AMBIGUOUS,
);
ecx.add_goal(GoalSource::Misc, goal.with(cx, PredicateKind::Ambiguous));
return ecx
.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
}
// Outside of coherence, we treat the associated item as rigid instead.
ty::TypingMode::Analysis { .. }
Expand All @@ -254,10 +262,20 @@ where
// treat it as rigid.
if cx.impl_self_is_guaranteed_unsized(impl_def_id) {
match ecx.typing_mode() {
// Trying to normalize such associated items is always ambiguous
// during coherence to avoid cyclic reasoning. See the example in
// tests/ui/traits/trivial-unsized-projection-in-coherence.rs.
//
// As this ambiguity is unavoidable we emit a nested ambiguous
// goal instead of using `Certainty::AMBIGUOUS`. This allows us to
// return the nested goals to the parent `AliasRelate` goal. This
// would be relevant if any of the nested goals refer to the `term`.
// This is not the case here and we only prefer adding an ambiguous
// nested goal for consistency.
ty::TypingMode::Coherence => {
return ecx.evaluate_added_goals_and_make_canonical_response(
Certainty::AMBIGUOUS,
);
ecx.add_goal(GoalSource::Misc, goal.with(cx, PredicateKind::Ambiguous));
return ecx
.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
}
ty::TypingMode::Analysis { .. }
| ty::TypingMode::Borrowck { .. }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use rustc_index::bit_set::GrowableBitSet;
use rustc_type_ir::inherent::*;
use rustc_type_ir::solve::GoalSource;
use rustc_type_ir::{self as ty, Interner, TypingMode, fold_regions};

use crate::delegate::SolverDelegate;
Expand Down Expand Up @@ -31,7 +32,12 @@ where
goal.param_env,
expected,
);
self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
// Trying to normalize an opaque type during coherence is always ambiguous.
// We add a nested ambiguous goal here instead of using `Certainty::AMBIGUOUS`.
// This allows us to return the nested goals to the parent `AliasRelate` goal.
// This can then allow nested goals to fail after we've constrained the `term`.
self.add_goal(GoalSource::Misc, goal.with(cx, ty::PredicateKind::Ambiguous));
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}
TypingMode::Analysis { defining_opaque_types_and_generators } => {
let Some(def_id) = opaque_ty
Expand Down
Loading