Repository navigation
Conversation
This comment has been minimized.
This comment has been minimized.
df4d0a0 to
74a9623
Compare
This comment has been minimized.
This comment has been minimized.
74a9623 to
f01b054
Compare
| let unresolved_dyn_assoc = tcx.next_trait_solver_globally() | ||
| && in_codegen | ||
| && key.value.promoted.is_none() | ||
| && matches!(tcx.def_kind(key.value.instance.def_id()), DefKind::AssocConst) | ||
| && key.value.instance.args.iter().any(|arg| { | ||
| matches!(arg.kind(), ty::GenericArgKind::Type(ty) if matches!(ty.kind(), ty::Dynamic(..))) | ||
| }); |
There was a problem hiding this comment.
This looks extremely fragile. This function here should not have any special interactions with the trait solver, let alone a random arbitrary error message from the other end of the compiler. Such special cases are not maintainable in the long term.
There was a problem hiding this comment.
It looks like there is a bug somewhere else, where TooGeneric is emitted for code that's not actually generic? That should be fixed at the source, not with work-arounds far downstream.
There was a problem hiding this comment.
I removed the workaround and moved the error handling closer to where normalization fails
there is just one thing I'm not sure about!
codegen can still have a generic ParamEnv and could a normalization failure here still mean TooGeneric or is it always safe to treat it as an actual error? @RalfJung
There was a problem hiding this comment.
codegen is never in a generic ParamEnv I think?
|
Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri
cc @rust-lang/miri |
| if match self.typing_env.typing_mode() { | ||
| ty::TypingMode::Codegen => true, | ||
| ty::TypingMode::Coherence | ||
| | ty::TypingMode::Typeck { .. } | ||
| | ty::TypingMode::PostTypeckThroughBorrowck { .. } | ||
| | ty::TypingMode::PostBorrowck { .. } | ||
| | ty::TypingMode::Reflection | ||
| | ty::TypingMode::PostAnalysis | ||
| | ty::TypingMode::ErasedNotCoherence(_) => false, |
There was a problem hiding this comment.
That still looks very fragile and hard-to-maintain. At the very least there needs to be an extensive comment explaining exactly why this logic is the way ot is. But really, ad-hoc matching on error enums from other subsystems is a big red flag.
There was a problem hiding this comment.
one thing I'm still wondering about is if normalization fails in PostAnalysis could it succeed when retried in Codegen? with this change we'd report the error right away instead of retrying
just wanted to check if that's something we need to worry about :)
| InvalidProgramInfo::AlreadyReported(_) | InvalidProgramInfo::Layout(..), | ||
| InvalidProgramInfo::AlreadyReported(_) | ||
| | InvalidProgramInfo::Layout(..) | ||
| | InvalidProgramInfo::NormalizationFailure(..), |
There was a problem hiding this comment.
Please also add a Miri test that triggers this new error.
|
@bors squash msg="Report normalization failures during CTFE" |
This comment has been minimized.
This comment has been minimized.
|
🔨 3 commits were squashed into dbcc385. |
a7c1d12 to
dbcc385
Compare
|
…, r=oli-obk report unresolved dyn associated const evaluation during CTFE with the next solver an associated const can stay unresolved when a trait-object impl overlaps a blanket impl and can let conflicting const assertions compile or cause an ICE when the value is used this change reports a regular error during CTFE related to rust-lang/trait-system-refactor-initiative#311 r? oli-obk maybe
|
💔 I suspect this PR failed tests as part of a rollup After fixing the problem, consider running a try job for the failed job before re-approving. Link to failure: #166615 (comment) |
|
This pull request was unapproved. This PR was contained in a rollup (#166615), which was unapproved. |
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
fac9bf9 to
b153029
Compare
|
@bors try jobs=test-armhf-gnu |
|
@amirHdev: 🔑 Insufficient privileges: not in try users |
|
Could you please take another look ? @oli-obk |
|
@bors try jobs=test-armhf-gnu |
This comment has been minimized.
This comment has been minimized.
report unresolved dyn associated const evaluation during CTFE try-job: test-armhf-gnu
|
@rustbot ready |
|
Yes this looks very nice now, thanks :) |
There was a problem hiding this comment.
Is it worth a comment explaining why we need this?
To me that's not clear at all.^^ I'm not even fully sure what this does...
There was a problem hiding this comment.
actually this avoids the dylib loading failure we hit during the rollup
I added a inline comment
View all comments
with the next solver an associated const can stay unresolved when a trait-object impl overlaps a blanket impl and can let conflicting const assertions compile or cause an ICE when the value is used
this change reports a regular error during CTFE
related to rust-lang/trait-system-refactor-initiative#311
r? oli-obk maybe