Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #129082

Closed
wants to merge 146 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
a22aeb2
Determine toolchain RA on age
huntc Jul 26, 2024
786ef83
Checks date for any RA
huntc Jul 30, 2024
6b4c0e0
Further simplifications
huntc Jul 30, 2024
440b8be
Outdated comment removed
huntc Jul 30, 2024
af4a59b
Formatting
huntc Jul 30, 2024
8ca9034
Corrected precedence position
huntc Jul 31, 2024
44f5392
fix: Insert a tail `Ok(())` for expr block instead of wrapping with `Ok`
ShoyuVanilla Aug 1, 2024
cce9da3
feat: support inlay hint for more expr with label
Young-Flash Aug 1, 2024
61ebcf6
Auto merge of #17763 - ShoyuVanilla:wrap-unit, r=Veykril
bors Aug 1, 2024
d646f7b
Auto merge of #17705 - huntc:resolve-ra, r=Veykril
bors Aug 2, 2024
5ac2ad4
internal: Remove AbsPathBuf::TryFrom impl that checks too many things…
Veykril Aug 2, 2024
6da26c1
Auto merge of #17770 - Veykril:path-try-from, r=Veykril
bors Aug 2, 2024
07e6f9d
internal: Load VFS config changes in parallel
Veykril Aug 2, 2024
2d8a494
Wait with change processing until the vfs is done
Veykril Aug 2, 2024
a95ff26
test: add test case for inlay hint support for expr with label
Young-Flash Aug 4, 2024
fbe7233
fix: Insert a generic arg for `impl Trait` when lowering generic args
ShoyuVanilla Aug 4, 2024
77fe1cb
Auto merge of #17789 - ShoyuVanilla:issue-17191, r=Veykril
bors Aug 4, 2024
b6b4e1a
add msvc note to manual
jjoeldaniel Aug 5, 2024
ef7d2c5
feat: Load sysroot library via cargo metadata
Veykril Aug 5, 2024
d84b970
Auto merge of #17795 - Veykril:library-dep-loading, r=Veykril
bors Aug 5, 2024
2e7db9c
Simplify FileDelegate
Veykril Aug 3, 2024
90803b1
Split out syntax-bridge into a separate crate
Veykril Aug 5, 2024
cdee65f
Newtype ErasedFileAstId
Veykril Aug 3, 2024
6825324
Auto merge of #17794 - Veykril:source-db-simplify, r=Veykril
bors Aug 5, 2024
f12aca9
Simplify
Veykril Aug 5, 2024
78dea24
Auto merge of #17784 - Young-Flash:block_with_label, r=Veykril
bors Aug 5, 2024
56fe166
Auto merge of #17793 - jjoeldaniel:msvc-docs, r=Veykril
bors Aug 5, 2024
9d99d39
Auto merge of #17799 - Veykril:syntax-bridge, r=Veykril
bors Aug 5, 2024
3e809f8
feat: Implement diagnostic for `await` outside of `async`
ShoyuVanilla Aug 4, 2024
92a07b8
minor: Fix metrics not running
Veykril Aug 5, 2024
56a7922
Auto merge of #17801 - Veykril:unbrick-metrics, r=Veykril
bors Aug 5, 2024
80c8786
perf: Segregate syntax and semantic diagnostics
ShoyuVanilla Aug 2, 2024
22f7c08
Auto merge of #17775 - ShoyuVanilla:segregate-diags, r=Veykril
bors Aug 5, 2024
81cbc78
Auto merge of #17791 - ShoyuVanilla:await-outside-of-async, r=Veykril
bors Aug 5, 2024
314f301
Slightly optimize watch list in vfs
Veykril Aug 5, 2024
d95a4b8
Reorganize debug.ts
Veykril Aug 2, 2024
7dd258a
Auto merge of #17771 - Veykril:parallel-vfs-config, r=Veykril
bors Aug 5, 2024
3e23c45
Surpress type mismatches in calls with mismatched arg counts
Veykril Aug 5, 2024
64cd3da
Auto merge of #17772 - Veykril:debug.ts, r=Veykril
bors Aug 5, 2024
37f7569
Auto merge of #17802 - Veykril:arg-mismatch-no-ty-mismatch, r=Veykril
bors Aug 5, 2024
ad4e815
fix: Panic in path transform with default type parameters
ShoyuVanilla Aug 5, 2024
88ea306
Replace `"TBD"` with more helpful desciptions in published crates' `[…
regexident Jul 30, 2024
1635341
Add repository URL for published crates' missing `[package.repository…
regexident Jul 30, 2024
a22691a
Fix obsolete repository URL in `[package.repository]` of `rust-analyz…
regexident Jul 30, 2024
cc67602
Fix spelling of "object-oriented"
regexident Jul 30, 2024
54e68e6
Fix spelling of "data structure"
regexident Jul 30, 2024
ccc4177
Replace "`ra_ap_ide`" with "`ide` (aka `ra_ap_ide`)"
regexident Aug 3, 2024
08d3d44
Apply Veykril's change suggestions
regexident Aug 3, 2024
e15ffa5
Unify package descriptions by adding references to "rust-analyzer"
regexident Aug 3, 2024
584f954
Replace `[package.repository] = "…"` of published crates with `[packa…
regexident Aug 5, 2024
54362ca
Auto merge of #17805 - ShoyuVanilla:issue-17578, r=Veykril
bors Aug 6, 2024
e686ffe
Auto merge of #17745 - regexident:improve-crate-manifests, r=Veykril
bors Aug 6, 2024
6c1d83b
Include vendored crates in StaticIndex
nicolas-guichard Aug 2, 2024
ac7c466
fix: tyck for non-ADT types when searching refs for `Self` kw
roife Aug 6, 2024
7af01f7
Allow rust-project.json to be hidden
alibektas Aug 7, 2024
937ef11
Auto merge of #17818 - alibektas:hidden_rust_project_json, r=Veykril
bors Aug 7, 2024
0713a47
Auto merge of #17813 - roife:fix-issue-17803, r=Veykril
bors Aug 7, 2024
34cde83
Auto merge of #17809 - nicolas-guichard:index-vendored, r=Veykril
bors Aug 7, 2024
dbf2c12
Remove unnecessary CfgFlag definition in project-model
Veykril Aug 7, 2024
f1f048c
Fix cargo config get env parsing
Veykril Aug 7, 2024
359d5b9
Auto merge of #17821 - Veykril:project-model-cleanup, r=Veykril
bors Aug 7, 2024
c4809d0
Fix unconfigured diagnostic being attached to the wrong file for modules
Veykril Aug 7, 2024
6fc5d09
Auto merge of #17823 - Veykril:mod-unconfigured-diag, r=Veykril
bors Aug 7, 2024
d366706
Fix native diagnostics not working
ShoyuVanilla Aug 7, 2024
e7086a3
Slightly quieter fatal panics
Veykril Aug 7, 2024
3e4632d
Offload diagnostics serialization to the task pool
Veykril Aug 7, 2024
7614de4
Auto merge of #17824 - ShoyuVanilla:fix-diags, r=Veykril
bors Aug 7, 2024
2a6655a
Auto merge of #17825 - Veykril:server-things, r=Veykril
bors Aug 7, 2024
1555fd9
Make 'syntax-bridge' crate inherit `[package.repository]` from workspace
regexident Aug 7, 2024
d8bb3c8
Add missing `[package.description]` for 'syntax-bridge' crate
regexident Aug 7, 2024
fe4d83c
Auto merge of #17827 - regexident:improve-crate-manifests-continuatio…
bors Aug 8, 2024
1114de0
Move flycheck crate into rust-analyzer main crate
Veykril Aug 8, 2024
8ff6b2f
Split up flycheck module
Veykril Aug 8, 2024
8666a71
Auto merge of #17831 - Veykril:flycheck-move-to-rust-analyzer, r=Veykril
bors Aug 8, 2024
ce846da
fix: Panic while rendering function with impl trait arg
ShoyuVanilla Aug 8, 2024
b086040
Auto merge of #17832 - ShoyuVanilla:issue-17811, r=Veykril
bors Aug 8, 2024
e6d426e
Reuse recursion limit as expansion limit
edevil Aug 8, 2024
077403a
minor: log error when sysroot can't be discovered
winstxnhdw Aug 8, 2024
bee4926
Auto merge of #17836 - winstxnhdw:sysroot, r=Veykril
bors Aug 9, 2024
03a7abc
Use Sender directly instead of a boxed closure
mo8it Aug 9, 2024
f4b1b4b
Use Sender instead of boxed closure in vfs
mo8it Aug 9, 2024
58c614f
Use crossbeam-channel from the workspace
mo8it Aug 9, 2024
7341b88
Remove unneeded `send` method
mo8it Aug 9, 2024
dd90d4e
Simplify `check_command` while avoiding allocations
mo8it Aug 9, 2024
35903a2
Use select_biased
mo8it Aug 10, 2024
204fb5b
Avoid the overhead of select! when possible
mo8it Aug 10, 2024
18b9458
feat: Implement TAIT
ShoyuVanilla Aug 10, 2024
cbd00f1
fix: Fix find_path not respecting non-std preference config correctly
Veykril Aug 10, 2024
e219ac6
Move some stuff
Veykril Aug 10, 2024
01262d9
Add comments regarding workspace structure change querying
Veykril Aug 10, 2024
2e0f5f6
Auto merge of #17849 - Veykril:rust-analyzer-crate, r=Veykril
bors Aug 10, 2024
ec03068
Auto merge of #17844 - Veykril:find-path-std-fix, r=Veykril
bors Aug 10, 2024
97a6fc6
Fix deadlock
mo8it Aug 11, 2024
3ef56c2
Auto merge of #17845 - ShoyuVanilla:tait, r=Veykril
bors Aug 12, 2024
12a3d01
Auto merge of #17833 - edevil:fix_expansion_limit, r=Veykril
bors Aug 12, 2024
7b86c98
do not use the global solver cache for proof trees
lcnr Jul 23, 2024
51338ca
expand fuzzing support
lcnr Jul 23, 2024
e87157b
simplify match + move `debug!` call
lcnr Jul 23, 2024
9308401
tracing: debug to trace
lcnr Jul 23, 2024
e83eacd
move behavior out of shared fn
lcnr Jul 23, 2024
0c75c08
merge impl blocks
lcnr Jul 23, 2024
f860873
split provisional cache and stack lookup
lcnr Jul 23, 2024
94bd4da
Revert "Remove unneeded `send` method"
mo8it Aug 12, 2024
7586ba6
Add track_caller
mo8it Aug 12, 2024
285285d
Add more track_caller
mo8it Aug 12, 2024
f7c4716
Use the send method
mo8it Aug 12, 2024
3355c78
fix: Correctly support `#[rustc_deprecated_safe_2024]`
Veykril Aug 12, 2024
757b0a5
Auto merge of #17859 - Veykril:rustc_deprecated_safe_2024, r=Veykril
bors Aug 12, 2024
c2d1555
Auto merge of #17842 - mo8it:crossbeam-channel, r=Veykril
bors Aug 12, 2024
7c53ff2
Auto merge of #17843 - mo8it:flycheck, r=Veykril
bors Aug 12, 2024
69f6138
minor: Bump lockfile
Veykril Aug 12, 2024
4079447
fix: Fix publish libs workflow
Veykril Aug 12, 2024
234d383
internal: Reply to requests with defaults when vfs is still loading
Veykril Aug 10, 2024
563dc1c
Auto merge of #17860 - Veykril:publish-libs, r=Veykril
bors Aug 12, 2024
5e753ff
Auto merge of #17850 - Veykril:rust-analyzer-crate, r=Veykril
bors Aug 12, 2024
696ecea
Only keep lib/ in publish-libs
lnicola Aug 12, 2024
a2b10a3
Auto merge of #17862 - lnicola:publish-libs-members, r=lnicola
bors Aug 12, 2024
9431039
Allow new license combination
Veykril Aug 12, 2024
bdc0b78
Auto merge of #17861 - Veykril:bump-lock, r=Veykril
bors Aug 12, 2024
1ebd727
Resolve included files to their calling modules in IDE layer
Veykril Aug 12, 2024
ff63552
Auto merge of #17863 - Veykril:include-diags, r=Veykril
bors Aug 12, 2024
1b983e3
Build and run build scripts in lsif command
Veykril Aug 12, 2024
e66f3db
Auto merge of #17864 - Veykril:lsif, r=Veykril
bors Aug 12, 2024
3bb7f35
fix: Missing non-exhaustive let diagnostics inside async or unsafe block
ShoyuVanilla Aug 12, 2024
0a336b3
Auto merge of #17865 - ShoyuVanilla:exhaust-block, r=Veykril
bors Aug 12, 2024
81561ff
fix: Trailing excess comma in "Convert to named struct" assist
ShoyuVanilla Aug 12, 2024
1b6df71
Explicitly specify type parameter on FromResidual impls in stdlib.
zachs18 Aug 10, 2024
84ac708
Auto merge of #17867 - ShoyuVanilla:issue-17854, r=Veykril
bors Aug 13, 2024
705a89e
Remove unreachable logic for include token mapping
Veykril Aug 13, 2024
acc2c5d
Auto merge of #17876 - Veykril:semantics-include-simplify, r=Veykril
bors Aug 13, 2024
2097160
feat: `min-exhaustive-patterns
ShoyuVanilla Aug 11, 2024
6911d9f
Temporarily remove non-working test case
ShoyuVanilla Aug 12, 2024
4ea0db9
Bump `rustc_pattern_analysis`
ShoyuVanilla Aug 12, 2024
00423bb
Auto merge of #17853 - ShoyuVanilla:min-exhaustive-pat, r=ShoyuVanilla
bors Aug 13, 2024
ddb8551
Preparing for merge from rust-lang/rust
lnicola Aug 13, 2024
28af7e0
Merge from rust-lang/rust
lnicola Aug 13, 2024
f96e296
Auto merge of #17880 - lnicola:sync-from-rust, r=lnicola
bors Aug 13, 2024
0aa17a4
implement a performant and fuzzed solver cache
lcnr Jul 24, 2024
850bcbd
Test showing previous behavior
compiler-errors Aug 13, 2024
5df13af
Use the right type when coercing fn items to pointers
compiler-errors Aug 12, 2024
342b374
Port `run-make/sysroot-crates-are-unstable` to rmake
Zalathar Aug 14, 2024
241f1d5
Rollup merge of #128828 - lcnr:search-graph-11, r=compiler-errors
matthiaskrgr Aug 14, 2024
81c4124
Rollup merge of #128954 - zachs18:fromresidual-no-default, r=scottmcm
matthiaskrgr Aug 14, 2024
88b3169
Rollup merge of #129054 - lnicola:sync-from-ra, r=lnicola
matthiaskrgr Aug 14, 2024
9f46639
Rollup merge of #129059 - compiler-errors:subtyping-correct-type, r=lcnr
matthiaskrgr Aug 14, 2024
cd37a32
Rollup merge of #129071 - Zalathar:sysroot-unstable, r=jieyouxu
matthiaskrgr Aug 14, 2024
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
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1989,9 +1989,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {

let ty_fn_ptr_from = Ty::new_fn_ptr(tcx, fn_sig);

if let Err(terr) = self.eq_types(
*ty,
if let Err(terr) = self.sub_types(
ty_fn_ptr_from,
*ty,
location.to_locations(),
ConstraintCategory::Cast { unsize_to: None },
) {
Expand All @@ -2014,9 +2014,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let ty_fn_ptr_from =
Ty::new_fn_ptr(tcx, tcx.signature_unclosure(sig, *safety));

if let Err(terr) = self.eq_types(
*ty,
if let Err(terr) = self.sub_types(
ty_fn_ptr_from,
*ty,
location.to_locations(),
ConstraintCategory::Cast { unsize_to: None },
) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
at.lub(DefineOpaqueTypes::Yes, b, a)
} else {
at.sup(DefineOpaqueTypes::Yes, b, a)
.map(|InferOk { value: (), obligations }| InferOk { value: a, obligations })
.map(|InferOk { value: (), obligations }| InferOk { value: b, obligations })
};

// In the new solver, lazy norm may allow us to shallowly equate
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_middle/src/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ macro_rules! arena_types {
[] dtorck_constraint: rustc_middle::traits::query::DropckConstraint<'tcx>,
[] candidate_step: rustc_middle::traits::query::CandidateStep<'tcx>,
[] autoderef_bad_ty: rustc_middle::traits::query::MethodAutoderefBadTy<'tcx>,
[] canonical_goal_evaluation:
rustc_type_ir::solve::inspect::CanonicalGoalEvaluationStep<
rustc_middle::ty::TyCtxt<'tcx>
>,
[] query_region_constraints: rustc_middle::infer::canonical::QueryRegionConstraints<'tcx>,
[] type_op_subtype:
rustc_middle::infer::canonical::Canonical<'tcx,
Expand Down
9 changes: 0 additions & 9 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
self.mk_predefined_opaques_in_body(data)
}
type DefiningOpaqueTypes = &'tcx ty::List<LocalDefId>;
type CanonicalGoalEvaluationStepRef =
&'tcx solve::inspect::CanonicalGoalEvaluationStep<TyCtxt<'tcx>>;
type CanonicalVars = CanonicalVarInfos<'tcx>;
fn mk_canonical_var_infos(self, infos: &[ty::CanonicalVarInfo<Self>]) -> Self::CanonicalVars {
self.mk_canonical_var_infos(infos)
Expand Down Expand Up @@ -277,13 +275,6 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
self.debug_assert_args_compatible(def_id, args);
}

fn intern_canonical_goal_evaluation_step(
self,
step: solve::inspect::CanonicalGoalEvaluationStep<TyCtxt<'tcx>>,
) -> &'tcx solve::inspect::CanonicalGoalEvaluationStep<TyCtxt<'tcx>> {
self.arena.alloc(step)
}

fn mk_type_list_from_iter<I, T>(self, args: I) -> T::Output
where
I: Iterator<Item = T>,
Expand Down
106 changes: 14 additions & 92 deletions compiler/rustc_next_trait_solver/src/solve/inspect/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
//! see the comment on [ProofTreeBuilder].

use std::marker::PhantomData;
use std::mem;

use derive_where::derive_where;
use rustc_type_ir::inherent::*;
use rustc_type_ir::{self as ty, search_graph, Interner};
use rustc_type_ir::{self as ty, Interner};

use crate::delegate::SolverDelegate;
use crate::solve::eval_ctxt::canonical;
Expand Down Expand Up @@ -94,31 +93,10 @@ impl<I: Interner> WipGoalEvaluation<I> {
}
}

#[derive_where(PartialEq, Eq; I: Interner)]
pub(in crate::solve) enum WipCanonicalGoalEvaluationKind<I: Interner> {
Overflow,
CycleInStack,
ProvisionalCacheHit,
Interned { final_revision: I::CanonicalGoalEvaluationStepRef },
}

impl<I: Interner> std::fmt::Debug for WipCanonicalGoalEvaluationKind<I> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Overflow => write!(f, "Overflow"),
Self::CycleInStack => write!(f, "CycleInStack"),
Self::ProvisionalCacheHit => write!(f, "ProvisionalCacheHit"),
Self::Interned { final_revision: _ } => {
f.debug_struct("Interned").finish_non_exhaustive()
}
}
}
}

#[derive_where(PartialEq, Eq, Debug; I: Interner)]
struct WipCanonicalGoalEvaluation<I: Interner> {
goal: CanonicalInput<I>,
kind: Option<WipCanonicalGoalEvaluationKind<I>>,
encountered_overflow: bool,
/// Only used for uncached goals. After we finished evaluating
/// the goal, this is interned and moved into `kind`.
final_revision: Option<WipCanonicalGoalEvaluationStep<I>>,
Expand All @@ -127,25 +105,17 @@ struct WipCanonicalGoalEvaluation<I: Interner> {

impl<I: Interner> WipCanonicalGoalEvaluation<I> {
fn finalize(self) -> inspect::CanonicalGoalEvaluation<I> {
// We've already interned the final revision in
// `fn finalize_canonical_goal_evaluation`.
assert!(self.final_revision.is_none());
let kind = match self.kind.unwrap() {
WipCanonicalGoalEvaluationKind::Overflow => {
inspect::CanonicalGoalEvaluation {
goal: self.goal,
kind: if self.encountered_overflow {
assert!(self.final_revision.is_none());
inspect::CanonicalGoalEvaluationKind::Overflow
}
WipCanonicalGoalEvaluationKind::CycleInStack => {
inspect::CanonicalGoalEvaluationKind::CycleInStack
}
WipCanonicalGoalEvaluationKind::ProvisionalCacheHit => {
inspect::CanonicalGoalEvaluationKind::ProvisionalCacheHit
}
WipCanonicalGoalEvaluationKind::Interned { final_revision } => {
} else {
let final_revision = self.final_revision.unwrap().finalize();
inspect::CanonicalGoalEvaluationKind::Evaluation { final_revision }
}
};

inspect::CanonicalGoalEvaluation { goal: self.goal, kind, result: self.result.unwrap() }
},
result: self.result.unwrap(),
}
}
}

Expand Down Expand Up @@ -308,7 +278,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
) -> ProofTreeBuilder<D> {
self.nested(|| WipCanonicalGoalEvaluation {
goal,
kind: None,
encountered_overflow: false,
final_revision: None,
result: None,
})
Expand All @@ -329,11 +299,11 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}

pub fn canonical_goal_evaluation_kind(&mut self, kind: WipCanonicalGoalEvaluationKind<I>) {
pub fn canonical_goal_evaluation_overflow(&mut self) {
if let Some(this) = self.as_mut() {
match this {
DebugSolver::CanonicalGoalEvaluation(canonical_goal_evaluation) => {
assert_eq!(canonical_goal_evaluation.kind.replace(kind), None);
canonical_goal_evaluation.encountered_overflow = true;
}
_ => unreachable!(),
};
Expand Down Expand Up @@ -547,51 +517,3 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}
}

impl<D, I> search_graph::ProofTreeBuilder<I> for ProofTreeBuilder<D>
where
D: SolverDelegate<Interner = I>,
I: Interner,
{
fn try_apply_proof_tree(
&mut self,
proof_tree: Option<I::CanonicalGoalEvaluationStepRef>,
) -> bool {
if !self.is_noop() {
if let Some(final_revision) = proof_tree {
let kind = WipCanonicalGoalEvaluationKind::Interned { final_revision };
self.canonical_goal_evaluation_kind(kind);
true
} else {
false
}
} else {
true
}
}

fn on_provisional_cache_hit(&mut self) {
self.canonical_goal_evaluation_kind(WipCanonicalGoalEvaluationKind::ProvisionalCacheHit);
}

fn on_cycle_in_stack(&mut self) {
self.canonical_goal_evaluation_kind(WipCanonicalGoalEvaluationKind::CycleInStack);
}

fn finalize_canonical_goal_evaluation(
&mut self,
tcx: I,
) -> Option<I::CanonicalGoalEvaluationStepRef> {
self.as_mut().map(|this| match this {
DebugSolver::CanonicalGoalEvaluation(evaluation) => {
let final_revision = mem::take(&mut evaluation.final_revision).unwrap();
let final_revision =
tcx.intern_canonical_goal_evaluation_step(final_revision.finalize());
let kind = WipCanonicalGoalEvaluationKind::Interned { final_revision };
assert_eq!(evaluation.kind.replace(kind), None);
final_revision
}
_ => unreachable!(),
})
}
}
66 changes: 44 additions & 22 deletions compiler/rustc_next_trait_solver/src/solve/search_graph.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::convert::Infallible;
use std::marker::PhantomData;

use rustc_type_ir::inherent::*;
use rustc_type_ir::search_graph::{self, CycleKind, UsageKind};
use rustc_type_ir::search_graph::{self, PathKind};
use rustc_type_ir::solve::{CanonicalInput, Certainty, QueryResult};
use rustc_type_ir::Interner;

use super::inspect::{self, ProofTreeBuilder};
use super::FIXPOINT_STEP_LIMIT;
use super::inspect::ProofTreeBuilder;
use super::{has_no_inference_or_external_constraints, FIXPOINT_STEP_LIMIT};
use crate::delegate::SolverDelegate;

/// This type is never constructed. We only use it to implement `search_graph::Delegate`
Expand All @@ -22,43 +23,48 @@ where
{
type Cx = D::Interner;

const ENABLE_PROVISIONAL_CACHE: bool = true;
type ValidationScope = Infallible;
fn enter_validation_scope(
_cx: Self::Cx,
_input: CanonicalInput<I>,
) -> Option<Self::ValidationScope> {
None
}

const FIXPOINT_STEP_LIMIT: usize = FIXPOINT_STEP_LIMIT;

type ProofTreeBuilder = ProofTreeBuilder<D>;
fn inspect_is_noop(inspect: &mut Self::ProofTreeBuilder) -> bool {
inspect.is_noop()
}

const DIVIDE_AVAILABLE_DEPTH_ON_OVERFLOW: usize = 4;
fn recursion_limit(cx: I) -> usize {
cx.recursion_limit()
}

fn initial_provisional_result(
cx: I,
kind: CycleKind,
kind: PathKind,
input: CanonicalInput<I>,
) -> QueryResult<I> {
match kind {
CycleKind::Coinductive => response_no_constraints(cx, input, Certainty::Yes),
CycleKind::Inductive => response_no_constraints(cx, input, Certainty::overflow(false)),
PathKind::Coinductive => response_no_constraints(cx, input, Certainty::Yes),
PathKind::Inductive => response_no_constraints(cx, input, Certainty::overflow(false)),
}
}

fn reached_fixpoint(
cx: I,
kind: UsageKind,
fn is_initial_provisional_result(
cx: Self::Cx,
kind: PathKind,
input: CanonicalInput<I>,
provisional_result: Option<QueryResult<I>>,
result: QueryResult<I>,
) -> bool {
if let Some(r) = provisional_result {
r == result
} else {
match kind {
UsageKind::Single(CycleKind::Coinductive) => {
response_no_constraints(cx, input, Certainty::Yes) == result
}
UsageKind::Single(CycleKind::Inductive) => {
response_no_constraints(cx, input, Certainty::overflow(false)) == result
}
UsageKind::Mixed => false,
match kind {
PathKind::Coinductive => response_no_constraints(cx, input, Certainty::Yes) == result,
PathKind::Inductive => {
response_no_constraints(cx, input, Certainty::overflow(false)) == result
}
}
}
Expand All @@ -68,14 +74,30 @@ where
inspect: &mut ProofTreeBuilder<D>,
input: CanonicalInput<I>,
) -> QueryResult<I> {
inspect.canonical_goal_evaluation_kind(inspect::WipCanonicalGoalEvaluationKind::Overflow);
inspect.canonical_goal_evaluation_overflow();
response_no_constraints(cx, input, Certainty::overflow(true))
}

fn on_fixpoint_overflow(cx: I, input: CanonicalInput<I>) -> QueryResult<I> {
response_no_constraints(cx, input, Certainty::overflow(false))
}

fn is_ambiguous_result(result: QueryResult<I>) -> bool {
result.is_ok_and(|response| {
has_no_inference_or_external_constraints(response)
&& matches!(response.value.certainty, Certainty::Maybe(_))
})
}

fn propagate_ambiguity(
cx: I,
for_input: CanonicalInput<I>,
from_result: QueryResult<I>,
) -> QueryResult<I> {
let certainty = from_result.unwrap().value.certainty;
response_no_constraints(cx, for_input, certainty)
}

fn step_is_coinductive(cx: I, input: CanonicalInput<I>) -> bool {
input.value.goal.predicate.is_coinductive(cx)
}
Expand Down
10 changes: 3 additions & 7 deletions compiler/rustc_trait_selection/src/solve/inspect/analyse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,9 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {

pub fn candidates(&'a self) -> Vec<InspectCandidate<'a, 'tcx>> {
let mut candidates = vec![];
let last_eval_step = match self.evaluation_kind {
inspect::CanonicalGoalEvaluationKind::Overflow
| inspect::CanonicalGoalEvaluationKind::CycleInStack
| inspect::CanonicalGoalEvaluationKind::ProvisionalCacheHit => {
warn!("unexpected root evaluation: {:?}", self.evaluation_kind);
return vec![];
}
let last_eval_step = match &self.evaluation_kind {
// An annoying edge case in case the recursion limit is 0.
inspect::CanonicalGoalEvaluationKind::Overflow => return vec![],
inspect::CanonicalGoalEvaluationKind::Evaluation { final_revision } => final_revision,
};

Expand Down
Loading
Loading