Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
208 commits
Select commit Hold shift + click to select a range
b623ba1
fn_addr_eq: we actually can guarantee basically nothing
RalfJung Sep 1, 2026
a5f61b3
Refactor infer bodies collection in hir-ty tests
ChayimFriedman2 Aug 17, 2026
26bd558
Fix handling of generic params in anon consts
ChayimFriedman2 Aug 17, 2026
bc80b71
simplify path encoding
stefnotch Sep 12, 2026
df6729a
Refactor `SyntaxContext` to not reimplement Salsa macros
ChayimFriedman2 Sep 7, 2026
c2fa5e5
Micro-optimization: avoid interning the empty slice in `new_from_slic…
ChayimFriedman2 Aug 20, 2026
7061c78
Micro-optimization: use `TraitRef::from_assoc()` in `trait_ref_and_ow…
ChayimFriedman2 Aug 20, 2026
8f9bba8
Micro-optimization: make calculating the number of lifetimes O(1) ins…
ChayimFriedman2 Aug 20, 2026
7f2c4b9
Define MIR's `Projection` via the `interned_slice!()` macro
ChayimFriedman2 Aug 20, 2026
7edfac1
Do not the same types twice in hir-ty lowering
ChayimFriedman2 Aug 19, 2026
9bef938
Include bounds declared on the parent for `type_alias_bounds()`
ChayimFriedman2 Aug 19, 2026
2986154
fix: cache macro-expanded roots when climbing ancestors
0xull Sep 14, 2026
a8c2091
Merge pull request #23359 from 0xull/fix-23327-macro-item-cache
ChayimFriedman2 Sep 14, 2026
b31f3f6
Merge pull request #23308 from ChayimFriedman2/syntaxcontext-refactor
Veykril Sep 14, 2026
f4ef0e3
fix: Include working directory when discover command fails
Wilfred Sep 14, 2026
468439c
internal: Remove deprecated eslint-define-config dependency
Wilfred Sep 14, 2026
fa42ba6
Merge pull request #23361 from Wilfred/fix/remove-eslint-define-config
ChayimFriedman2 Sep 15, 2026
e86d521
Merge pull request #23360 from Wilfred/log_discover_dir
ChayimFriedman2 Sep 15, 2026
798ec7b
fix: hover show impl header when impl with trait
A4-Tacks Sep 15, 2026
2059c2f
fix: return an error early for unsupported string binary operations
edragain2nd Sep 15, 2026
f51832d
fix: Panic when trait solver re-enters itself
Wilfred Sep 14, 2026
0cc61fe
Merge pull request #23367 from Wilfred/panic_on_solver_reentry
ChayimFriedman2 Sep 15, 2026
20f3519
Merge pull request #23368 from edragain2nd/fix/early_return_binary_op…
ChayimFriedman2 Sep 15, 2026
016459c
fix: const eval cast of single-variant enum
hlsxx Aug 28, 2026
26b0869
fix: avoid recursion when casting enum variant discriminants
hlsxx Sep 14, 2026
f54308b
fix: restore the server binary check broken by rust-lang/rust-analyze…
devjgm Sep 15, 2026
265ca85
Merge pull request #23370 from devjgm/greg/ra-await-valid-executable
ChayimFriedman2 Sep 15, 2026
b586c24
fix: watch include roots recursively once, not every directory
scovich Sep 16, 2026
cba9bb5
Merge pull request #23375 from scovich/lsp-macos-hang-fix
ChayimFriedman2 Sep 17, 2026
eaf1e51
Don't fail extension activation when the server fails to start.
michaelgruenewald Sep 17, 2026
ec57e2f
Add builtin cfg!() to minicore
A4-Tacks Sep 17, 2026
72f9ef8
internal: xtask reformat ignore nightly dates
A4-Tacks Sep 18, 2026
f7bb5b4
Add CfgPredExpr and CfgPredPat syntax
A4-Tacks Sep 18, 2026
df5962d
feat: support completions inside `cfg!()`
A4-Tacks Sep 17, 2026
57e9254
Add cfg!() in pattern refutable test
A4-Tacks Sep 18, 2026
f5d1d2c
fix: complete cfg value in string
A4-Tacks Sep 19, 2026
8868eca
Merge pull request #23384 from A4-Tacks/comp-cfg-macro
ChayimFriedman2 Sep 20, 2026
5caa7ad
feat: support hover on cfg predicate
A4-Tacks Sep 18, 2026
62cf546
Add a test expand other crate macro
A4-Tacks Sep 19, 2026
3442a08
Add test for hover inside cfg!()
A4-Tacks Sep 20, 2026
3b30621
fix: not complete attr args when before exists args
A4-Tacks Sep 20, 2026
5c16f21
Prepare for merging from rust-lang/rust
invalid-email-address Sep 21, 2026
197fa27
Merge ref 'd287eb7a292c' from rust-lang/rust
invalid-email-address Sep 21, 2026
042762b
Merge pull request #23401 from rust-lang/rustc-pull
lnicola Sep 21, 2026
087a56f
minor: suggest first uppercase for introduce_named_type_parameter
A4-Tacks Sep 21, 2026
ec3e078
fix: correct order deprecated const in builtin ty
A4-Tacks Sep 21, 2026
739fbd0
fix: add type_match relevance for type-alias
A4-Tacks Sep 21, 2026
8473cfc
feat: Prioritise required items in trait autocomplete
Nereuxofficial Sep 21, 2026
5666f00
Merge pull request #23407 from Nereuxofficial/master
A4-Tacks Sep 21, 2026
1b441aa
Merge pull request #23405 from A4-Tacks/float-deprecated-order
ChayimFriedman2 Sep 22, 2026
3f86391
Merge pull request #23404 from A4-Tacks/implty-first-uppercase
ChayimFriedman2 Sep 22, 2026
c57694e
Merge pull request #23399 from A4-Tacks/attr-before-arg-no-paren
ChayimFriedman2 Sep 22, 2026
6738da6
Merge pull request #23395 from A4-Tacks/cfg-kv-in-string
ChayimFriedman2 Sep 22, 2026
8cf15a5
feat: add all_types that exposes implicit type parameters from Generi…
anatawa12 Sep 19, 2026
8903445
Merge pull request #23391 from A4-Tacks/xtask-fmt-nightly-date
ChayimFriedman2 Sep 22, 2026
0ba3a4c
Merge pull request #23398 from anatawa12/add-all-types
ChayimFriedman2 Sep 22, 2026
a17c72e
Merge pull request #23390 from A4-Tacks/hover-cfg-pred
ChayimFriedman2 Sep 22, 2026
5e4f224
fix: do not type match unknown type
A4-Tacks Sep 23, 2026
8746bd2
Merge pull request #23406 from A4-Tacks/type-alias-comp-ty-match
A4-Tacks Sep 23, 2026
a72b274
Add a pure generic arg ret-type fn test
A4-Tacks Sep 23, 2026
13bd2bc
fix: Panic in async closures with HRTB
Wilfred Sep 23, 2026
919dd95
Merge pull request #23409 from Wilfred/fix/async-closure-hrtb
ChayimFriedman2 Sep 23, 2026
5a17694
fix: don't clear semantic tokens cache on refresh
sainad2222 Sep 23, 2026
d683bf6
fix: deduplicate 'derive' and 'test' attribute macro
A4-Tacks Sep 24, 2026
ae9a4a3
fix: complete attr value inside string without quotes
A4-Tacks Sep 24, 2026
2c51f79
Merge pull request #23413 from A4-Tacks/dedup-derive
ChayimFriedman2 Sep 24, 2026
c6af564
Merge pull request #23414 from A4-Tacks/attr-snip-insert-mode
ChayimFriedman2 Sep 24, 2026
df562f0
fix: coersion safe fn to unsafe fn
hlsxx Sep 24, 2026
1a50ad3
Merge pull request #23416 from hlsxx/coersion-fn-unsafe
ChayimFriedman2 Sep 24, 2026
440292e
Merge pull request #23410 from sainad2222/fix/semantic-tokens-delta-c…
ChayimFriedman2 Sep 24, 2026
6cde801
Merge pull request #23185 from hlsxx/enum-dicr-evaluation
ChayimFriedman2 Sep 24, 2026
58c90dc
Merge pull request #23351 from stefnotch/simplify-path-encoding
ChayimFriedman2 Sep 24, 2026
ab8dade
Merge pull request #23386 from osdyne/push-lpktqwoxnytr
ChayimFriedman2 Sep 24, 2026
ee76f60
Merge pull request #23365 from A4-Tacks/hover-always-container
ChayimFriedman2 Sep 24, 2026
073aa1b
fix: complete 'false' in cfg attribute
A4-Tacks Sep 17, 2026
2ae0b5c
Merge pull request #23408 from A4-Tacks/ty-match-unknown
A4-Tacks Sep 25, 2026
3eee583
Merge pull request #23382 from A4-Tacks/comp-false-cfg-cond
A4-Tacks Sep 25, 2026
cf905ad
Implement opaques_with_sub_unified_hidden_type
solodevstack Sep 25, 2026
fc0557a
internal: Don't compute hover information for SCIP
Wilfred Sep 25, 2026
98538a2
fix: return UB instead of panicking when reading the discriminant of …
0xull Sep 26, 2026
388c469
Merge pull request #23421 from 0xull/fix-23131
Veykril Sep 26, 2026
05ec690
Bump salsa
Veykril Sep 26, 2026
8b9e099
Merge pull request #23423 from Veykril/lukaswirth/push-ryxzsxyoxxzr
Veykril Sep 26, 2026
a539bf5
feat: support inline call in macro call
A4-Tacks Sep 27, 2026
2c9a054
Use self-repository syntax
BenjaminBrienen Sep 27, 2026
1593832
Merge pull request #23429 from BenjaminBrienen/self-repository
lnicola Sep 27, 2026
059131b
internal: fix check_with_base_items() fixture
A4-Tacks Sep 28, 2026
3634b49
fix: don't panic on malformed let-pattern with mismatched or-arm arities
GauravPawar101 Sep 26, 2026
871f4cd
fix: transform usage path when extract trait to module
A4-Tacks Sep 30, 2026
755429e
internal: remove workaround for salsa bug
ada4a Sep 25, 2026
0cf2ee3
fix: Add missing HIR database when running unresolved-references
Wilfred Sep 30, 2026
c97b5be
internal: Grammar fixes in panic message
Wilfred Sep 30, 2026
e2f27cb
Prepare for merging from rust-lang/rust
invalid-email-address Oct 1, 2026
df97f99
Merge ref '6006fd03947b' from rust-lang/rust
invalid-email-address Oct 1, 2026
0676e14
Pin `unicode-ident`
ShoyuVanilla Oct 1, 2026
8677350
Merge pull request #23448 from rust-lang/ShoyuVanilla-patch-1
ShoyuVanilla Oct 1, 2026
d7ec5a4
Merge pull request #23442 from ada4a/push-zosutkyuyxyo
ShoyuVanilla Oct 1, 2026
62de62b
Fix `unicode-ident`, take 2
ShoyuVanilla Oct 1, 2026
15fff81
Ignore `unicode-ident` from cargo-machete
ShoyuVanilla Oct 1, 2026
92d3747
Merge pull request #23449 from rust-lang/ShoyuVanilla-patch-1
ShoyuVanilla Oct 1, 2026
ad7498b
minor: add semicolon on hover non-record struct
A4-Tacks Oct 1, 2026
f280291
feat: do not suggest arg-list in expected callable arg
A4-Tacks Oct 1, 2026
39d714c
Use n_params and ret-type instead impls_fnonce
A4-Tacks Oct 1, 2026
cf04744
Update lockfile with `cargo check`
BenjaminBrienen Oct 2, 2026
ac6532b
Merge pull request #23455 from BenjaminBrienen/update-lockfile
ShoyuVanilla Oct 2, 2026
c647bd3
Merge pull request #23450 from A4-Tacks/hover-struct-semi
ShoyuVanilla Oct 2, 2026
c14df22
fix: name-match ignore leading tailing underscore
A4-Tacks Oct 2, 2026
e2544ca
Merge pull request #23419 from Wilfred/scip-hover-config
Veykril Oct 2, 2026
3bf4e3c
generate variant for self in impl
born-in-autumn Oct 2, 2026
3e738bb
fix: use sub-unification roots in type_var_is_sized
ABHIRAM-CREATOR06 Oct 2, 2026
dd02a40
Merge pull request #23462 from born-in-autumn/master
ShoyuVanilla Oct 3, 2026
2495d86
feat: complete 'let' 'letm' in arm expr and closure expr
A4-Tacks Oct 3, 2026
1e2cbe7
feat: complete turbofish when fn can't infer param
A4-Tacks Oct 4, 2026
341a2bd
Merge pull request #23197 from ChayimFriedman2/interneds-perf
ChayimFriedman2 Oct 4, 2026
ded3504
Merge pull request #23196 from ChayimFriedman2/no-relower
ChayimFriedman2 Oct 4, 2026
92fa29a
Merge pull request #23468 from A4-Tacks/let-kw-in-arm-expr
ChayimFriedman2 Oct 4, 2026
7727d4d
Merge pull request #23464 from ABHIRAM-CREATOR06/fix-23114-sized-subt…
ChayimFriedman2 Oct 4, 2026
0ce29fb
Merge pull request #23456 from A4-Tacks/name-match-side
ChayimFriedman2 Oct 5, 2026
4a5e438
Merge pull request #23444 from Wilfred/fix/unresolved-references-db-a…
ChayimFriedman2 Oct 5, 2026
36168f2
Merge pull request #23441 from A4-Tacks/extract-trait-to-module
ChayimFriedman2 Oct 5, 2026
644dbcb
Merge pull request #23434 from A4-Tacks/comp-test-fixture
ChayimFriedman2 Oct 5, 2026
12a3273
Merge pull request #23422 from GauravPawar101/fix-23336-let-pattern-a…
ChayimFriedman2 Oct 5, 2026
6a710d6
Merge pull request #23061 from solodevstack/first-os
ChayimFriedman2 Oct 5, 2026
35aae6b
fix: Improve in-block heuristic check in nested ambiguous
A4-Tacks Oct 3, 2026
56ac0be
Combination some 'let' snippets
A4-Tacks Oct 5, 2026
e521414
Use hir::Function instead of callback
A4-Tacks Oct 5, 2026
fe89c14
Add no turbofish test
A4-Tacks Oct 5, 2026
04050d0
Make ExpectedInfo to a struct
A4-Tacks Oct 5, 2026
f2d2328
Add heuristic conditions
A4-Tacks Oct 5, 2026
0cfe55a
Merge pull request #23467 from A4-Tacks/fix-heuristic-in-block
A4-Tacks Oct 5, 2026
ec692ce
fix: complete let in macro when expand at macro stmts
A4-Tacks Aug 1, 2026
38a5725
fix: do not bump some `}` after attr
A4-Tacks Oct 5, 2026
337a70e
Remove stmt() patches
A4-Tacks Oct 5, 2026
a0f2818
Merge pull request #22982 from A4-Tacks/comp-let-in-macro-stmts
ChayimFriedman2 Oct 5, 2026
7dc3d7b
Merge pull request #23452 from A4-Tacks/no-paren-fn
ChayimFriedman2 Oct 5, 2026
9131b5c
Merge pull request #23477 from A4-Tacks/attr-end-list
A4-Tacks Oct 5, 2026
746e1aa
fix: add downcast handling in enum closure capture
edragain2nd Oct 5, 2026
dc55467
Add a config flag
A4-Tacks Oct 5, 2026
3055e36
Fix typo
A4-Tacks Oct 5, 2026
67eb25d
Merge pull request #23473 from A4-Tacks/comp-fn-turbofish
A4-Tacks Oct 5, 2026
2d2ff8d
minor: complete string for cfg key-value completions
A4-Tacks Oct 5, 2026
40553db
Merge pull request #23479 from A4-Tacks/comp-cfg-with-str
ChayimFriedman2 Oct 5, 2026
fd0bcf8
Sync target feature implications from rustc_target
TechnoPorg Oct 6, 2026
33dced8
Mini refactors in closure capture inference
Jules-Bertholet Oct 6, 2026
7f905cc
Merge pull request #23482 from Jules-Bertholet/upvar-refactor
ChayimFriedman2 Oct 6, 2026
838b26c
Merge pull request #23483 from TechnoPorg/push-zxtvumkyonzr
ChayimFriedman2 Oct 6, 2026
6cf1436
Merge pull request #23476 from edragain2nd/fix/enum_closure_capture_d…
ChayimFriedman2 Oct 7, 2026
0fcc7af
Use trusted publishing for lib crates
Kobzol Oct 7, 2026
a9eb2c0
Note that adding new lib crates requires changes in `team`
Kobzol Oct 7, 2026
abb5917
fix: complete in top-level after inner-doc
A4-Tacks Oct 7, 2026
a08c5c7
fix: check call no-paren after path colons
A4-Tacks Oct 7, 2026
026f932
Merge pull request #23485 from Kobzol/lib-crates-trusted-publishing
ubiratansoares Oct 8, 2026
0e1c23d
fix: Don't source-map #[doc] strings that contain escapes
simonether Sep 30, 2026
25c4869
Merge pull request #23443 from simonether/doc-attr-escapes
ChayimFriedman2 Oct 9, 2026
4a626a8
fix: assist do not add lifetime only turbofish
A4-Tacks Oct 9, 2026
42dbcf0
Use trusted publishing for autopublish crates
Kobzol Oct 9, 2026
8a081e2
Restrict application of optimization attributes from instance
tmiasko Oct 7, 2026
5660ed3
Merge pull request #23494 from Kobzol/trusted-publishing-autopublish
ubiratansoares Oct 9, 2026
c1c3daa
Uplift flatten_answer_tree to next-solver
lsunsi Oct 7, 2026
61d4201
Add test for transmute recycle on next solver
lsunsi Oct 6, 2026
01d70ab
Update is_transmutable on next solver to consider nested goals
lsunsi Oct 7, 2026
247b4de
Update test to reflect previous fix
lsunsi Oct 7, 2026
5eb32c9
tidy up!
lsunsi Oct 7, 2026
b6fecaf
Replace require_lang_item with require_trait_lang_item (avoiding dumm…
lsunsi Oct 7, 2026
da48483
Avoid needless collect
lsunsi Oct 7, 2026
1266bc0
Add a couple more tests
lsunsi Oct 7, 2026
d995a73
Make flatten_answer_tree Interner generic
lsunsi Oct 7, 2026
0f6564e
Remove middle from next-solver (sorry)
lsunsi Oct 8, 2026
372a9e9
Remove needless param: assume
lsunsi Oct 9, 2026
21b29a6
is_transmutable returns answer now
lsunsi Oct 9, 2026
5b216e0
Uplift transmute Answer/Condition into type-ir
lsunsi Oct 9, 2026
ae3df03
Make transmute test suite next-solver
lsunsi Oct 9, 2026
0f13998
Fix test imports for moved transmute
lsunsi Oct 9, 2026
2c21fc5
Add test that checks add_goals for flattened goals
lsunsi Oct 9, 2026
cf94b14
Mark fixed transmutability tests as fixed
lsunsi Oct 10, 2026
c35e35b
When the initializer in `let` diverges, allow non-diverging `else`
ChayimFriedman2 Oct 10, 2026
10d2bb9
Fix an needless import and needless full path
lsunsi Oct 10, 2026
7c75468
Add revision to a couple of tests
lsunsi Oct 10, 2026
71f84bd
Fix a couple of type references in doc (what was I thinking)
lsunsi Oct 10, 2026
3e780c4
Add revisions to all previously edited tests
lsunsi Oct 10, 2026
1906ff6
Merge pull request #23487 from A4-Tacks/no-paren-after-colon
ChayimFriedman2 Oct 10, 2026
932012d
Merge pull request #23486 from A4-Tacks/comp-after-innee-doc
ChayimFriedman2 Oct 10, 2026
c798b31
Merge pull request #23430 from rust-lang/rustc-pull
lnicola Oct 11, 2026
8eaa009
Prepare for merging from rust-lang/rust
lnicola Oct 12, 2026
5c832f4
Merge ref '03cbd412d986' from rust-lang/rust
lnicola Oct 12, 2026
ce570e3
Merge pull request #23505 from lnicola/sync-from-rust
lnicola Oct 12, 2026
e6f6dc2
Merge pull request #23500 from ChayimFriedman2/let-diverge-else
ShoyuVanilla Oct 12, 2026
fbb8e34
Merge pull request #23179 from ChayimFriedman2/anon-const-params
ShoyuVanilla Oct 12, 2026
3927b5a
Merge pull request #23493 from A4-Tacks/no-lifetime-turbofish
ShoyuVanilla Oct 12, 2026
b5e7e91
Merge pull request #23428 from A4-Tacks/inline-call-in-macro
ShoyuVanilla Oct 12, 2026
5a6bffb
Copy over some methods from At to InferCtxt
fallible-algebra Oct 8, 2026
8880c1b
Call into for the bodies of the methods to avoid repeating behaviour…
fallible-algebra Oct 12, 2026
56c1ad8
use unsigned unpackers for unsigned data
Walnut356 Oct 12, 2026
7c32373
Remove couple more unused imports
lsunsi Oct 12, 2026
a2d2de0
improve output consistency
Walnut356 Oct 12, 2026
2cee0dc
trait-system-refactor-initiative#152 is not a bug anymore
lsunsi Oct 12, 2026
2cb8b0b
Move the creation of `IndividualTestOptions` into the test runner clo…
GuillaumeGomez Oct 12, 2026
031d65a
Re-directions in doc comments + _raw prefix
fallible-algebra Oct 12, 2026
ecc137b
replace region variables with bound variables too
BoxyUwU Oct 6, 2026
13694b6
Drop two repeated tests and an unecessary directive
lsunsi Oct 12, 2026
b34bf38
Rollup merge of #164196 - lnicola:sync-from-ra, r=lnicola
JonathanBrouwer Oct 12, 2026
00c6f85
Rollup merge of #164037 - tmiasko:deduce-instance, r=saethlin
JonathanBrouwer Oct 12, 2026
66e39ab
Rollup merge of #164201 - Walnut356:unsigned_unpack, r=Kobzol
JonathanBrouwer Oct 12, 2026
0bfc997
Rollup merge of #164202 - GuillaumeGomez:fix-doctest-temp-removal, r=…
JonathanBrouwer Oct 12, 2026
bd86817
Rollup merge of #162140 - RalfJung:fn_addr_eq, r=joboet
JonathanBrouwer Oct 12, 2026
cee2a0d
Rollup merge of #163946 - lsunsi:next-transmute, r=lcnr,ShoyuVanilla
JonathanBrouwer Oct 12, 2026
e1d10f3
Rollup merge of #163978 - fallible-algebra:at-removal/at-methods-on-i…
JonathanBrouwer Oct 12, 2026
5bbae1e
Rollup merge of #164045 - BoxyUwU:abby_s_region_vars_bound_vars, r=kh…
JonathanBrouwer Oct 12, 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
151 changes: 150 additions & 1 deletion compiler/rustc_infer/src/infer/at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

use relate::lattice::{LatticeOp, LatticeOpKind};
use rustc_middle::ty::relate::solver_relating::RelateExt as NextSolverRelate;
use rustc_middle::ty::{Const, TypingMode};
use rustc_middle::ty::{Const, ParamEnv, TypingMode};
use rustc_span::bug;

use super::*;
Expand Down Expand Up @@ -124,6 +124,143 @@ impl<'tcx> InferCtxt<'tcx> {
forked.inner.borrow_mut().projection_cache().clear();
forked
}

/// Makes `actual <: expected`. For example, if type-checking a
/// call like `foo(x)`, where `foo: fn(i32)`, you might have
/// `sup(i32, x)`, since the "expected" type is the type that
/// appears in the signature.
///
/// If possible, prefer the wrapper methods on `ObligationCtxt`,
/// `FnCtxt`, or `TypeChecker`.
pub fn sup_raw<T>(
self,
cause: &ObligationCause<'tcx>,
param_env: ParamEnv<'tcx>,
define_opaque_types: DefineOpaqueTypes,
expected: T,
actual: T,
) -> InferResult<'tcx, ()>
where
T: ToTrace<'tcx>,
{
self.at(cause, param_env).sup(define_opaque_types, expected, actual)
}

/// Makes `expected <: actual`.
///
/// If possible, prefer the wrapper methods on `ObligationCtxt`,
/// `FnCtxt`, or `TypeChecker`.
pub fn sub_raw<T>(
self,
cause: &ObligationCause<'tcx>,
param_env: ParamEnv<'tcx>,
define_opaque_types: DefineOpaqueTypes,
expected: T,
actual: T,
) -> InferResult<'tcx, ()>
where
T: ToTrace<'tcx>,
{
self.at(cause, param_env).sub(define_opaque_types, expected, actual)
}

/// Makes `expected == actual`.
///
/// If possible, prefer the wrapper methods on `ObligationCtxt`,
/// `FnCtxt`, or `TypeChecker`.
pub fn eq_raw<T>(
self,
cause: &ObligationCause<'tcx>,
param_env: ParamEnv<'tcx>,
define_opaque_types: DefineOpaqueTypes,
expected: T,
actual: T,
) -> InferResult<'tcx, ()>
where
T: ToTrace<'tcx>,
{
self.eq_trace_raw(
cause,
param_env,
define_opaque_types,
ToTrace::to_trace(cause, expected, actual),
expected,
actual,
)
}

/// Makes `expected == actual`.
///
/// If possible, prefer the wrapper methods on `ObligationCtxt`,
/// `FnCtxt`, or `TypeChecker`.
pub fn eq_trace_raw<T>(
self,
cause: &ObligationCause<'tcx>,
param_env: ParamEnv<'tcx>,
define_opaque_types: DefineOpaqueTypes,
trace: TypeTrace<'tcx>,
expected: T,
actual: T,
) -> InferResult<'tcx, ()>
where
T: Relate<TyCtxt<'tcx>>,
{
self.at(cause, param_env).eq_trace(define_opaque_types, trace, expected, actual)
}

/// If possible, prefer the wrapper methods on `ObligationCtxt`,
/// `FnCtxt`, or `TypeChecker`.
pub fn relate_raw<T>(
self,
cause: &ObligationCause<'tcx>,
param_env: ParamEnv<'tcx>,
define_opaque_types: DefineOpaqueTypes,
expected: T,
variance: ty::Variance,
actual: T,
) -> InferResult<'tcx, ()>
where
T: ToTrace<'tcx>,
{
self.at(cause, param_env).relate(define_opaque_types, expected, variance, actual)
}

/// Computes the least-upper-bound, or mutual supertype, of two
/// values. The order of the arguments doesn't matter, but since
/// this can result in an error (e.g., if asked to compute LUB of
/// u32 and i32), it is meaningful to call one of them the
/// "expected type".
///
/// If possible, prefer the wrapper methods on `ObligationCtxt`,
/// `FnCtxt`, or `TypeChecker`.
pub fn lub_raw<T>(
self,
cause: &ObligationCause<'tcx>,
param_env: ParamEnv<'tcx>,
expected: T,
actual: T,
) -> InferResult<'tcx, T>
where
T: ToTrace<'tcx>,
{
self.at(cause, param_env).lub(expected, actual)
}

pub fn goals_to_obligations(
&self,
cause: &ObligationCause<'tcx>,
goals: Vec<Goal<'tcx, ty::Predicate<'tcx>>>,
) -> InferOk<'tcx, ()> {
InferOk {
value: (),
obligations: goals
.into_iter()
.map(|goal| {
Obligation::new(self.tcx, cause.clone(), goal.param_env, goal.predicate)
})
.collect(),
}
}
}

pub trait ToTrace<'tcx>: Relate<TyCtxt<'tcx>> + Copy {
Expand All @@ -135,6 +272,8 @@ impl<'a, 'tcx> At<'a, 'tcx> {
/// call like `foo(x)`, where `foo: fn(i32)`, you might have
/// `sup(i32, x)`, since the "expected" type is the type that
/// appears in the signature.
///
/// FIXME: To be removed in favor of the [`InferCtxt::sup_raw`] method instead.
pub fn sup<T>(
self,
define_opaque_types: DefineOpaqueTypes,
Expand Down Expand Up @@ -168,6 +307,8 @@ impl<'a, 'tcx> At<'a, 'tcx> {
}

/// Makes `expected <: actual`.
///
/// FIXME: To be removed in favor of the [`InferCtxt::sub_raw`] method instead.
pub fn sub<T>(
self,
define_opaque_types: DefineOpaqueTypes,
Expand Down Expand Up @@ -201,6 +342,8 @@ impl<'a, 'tcx> At<'a, 'tcx> {
}

/// Makes `expected == actual`.
///
/// FIXME: To be removed in favor of the [`InferCtxt::eq_raw`] method instead.
pub fn eq<T>(
self,
define_opaque_types: DefineOpaqueTypes,
Expand All @@ -219,6 +362,8 @@ impl<'a, 'tcx> At<'a, 'tcx> {
}

/// Makes `expected == actual`.
///
/// FIXME: To be removed in favor of the [`InferCtxt::eq_trace_raw`] method instead.
pub fn eq_trace<T>(
self,
define_opaque_types: DefineOpaqueTypes,
Expand Down Expand Up @@ -252,6 +397,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
}
}

/// FIXME: To be removed in favor of the [`InferCtxt::relate_raw`] method instead.
pub fn relate<T>(
self,
define_opaque_types: DefineOpaqueTypes,
Expand Down Expand Up @@ -281,6 +427,8 @@ impl<'a, 'tcx> At<'a, 'tcx> {
/// this can result in an error (e.g., if asked to compute LUB of
/// u32 and i32), it is meaningful to call one of them the
/// "expected type".
///
/// FIXME: To be removed in favor of the [`InferCtxt::lub_raw`] method instead.
pub fn lub<T>(self, expected: T, actual: T) -> InferResult<'tcx, T>
where
T: ToTrace<'tcx>,
Expand All @@ -295,6 +443,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
Ok(InferOk { value, obligations: op.into_obligations() })
}

/// FIXME: To be removed in favor of the [`InferCtxt::goals_to_obligations`] method instead.
fn goals_to_obligations(
&self,
goals: Vec<Goal<'tcx, ty::Predicate<'tcx>>>,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/ty/context/impl_interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ bidirectional_lang_item_map! {
FnMut,
FnOnce,
FnPtrTrait,
Freeze,
FusedIterator,
Future,
Iterator,
Expand Down
9 changes: 6 additions & 3 deletions compiler/rustc_next_trait_solver/src/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ use std::fmt::Debug;
use std::ops::Deref;

use rustc_type_ir::solve::{
Certainty, ComputeGoalFastPathOutcome, FetchEligibleAssocItemResponse, Goal, NoSolution,
ComputeGoalFastPathOutcome, FetchEligibleAssocItemResponse, Goal, NoSolution,
VisibleForLeakCheck,
};
use rustc_type_ir::{self as ty, CanonicalizerState, Const, InferCtxtLike, Interner, TypeFoldable};
use rustc_type_ir::transmute::Answer;
use rustc_type_ir::{
self as ty, CanonicalizerState, Const, InferCtxtLike, Interner, Region, TypeFoldable,
};

/// `SolverDelegate` is one of the two traits in the `rustc_type_ir` shared abstraction layer
/// between rustc and rust-analyzer abstracting over the [InferCtxt][inferctxt-doc], which had to be
Expand Down Expand Up @@ -113,7 +116,7 @@ pub trait SolverDelegate: Deref<Target = Self::Infcx> + Sized {
src: <Self::Interner as Interner>::Ty,
dst: <Self::Interner as Interner>::Ty,
assume: Const<Self::Interner>,
) -> Result<Certainty, NoSolution>;
) -> Result<Answer<Region<Self::Interner>, <Self::Interner as Interner>::Ty>, NoSolution>;

/// Obtain canonicalizer state, either by allocating it afresh (the default) or by reusing
/// previously allocated state.
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use rustc_type_ir::solve::{
NoSolutionOrRerunNonErased, OpaqueTypesJank, QueryResultOrRerunNonErased, RerunCondition,
RerunNonErased, RerunReason, RerunResultExt, SmallCopySet, TyOrConstInferVar,
};
use rustc_type_ir::transmute::Answer;
use rustc_type_ir::{
self as ty, ClauseKind, Const, InferCtxtLike, Interner, MayBeErased, OpaqueTypeKey,
PredicateKind, PredicateProxy, Region, RegionVid, TypeFoldable, TypeSuperVisitable,
Expand Down Expand Up @@ -1565,7 +1566,7 @@ where
src: I::Ty,
dst: I::Ty,
assume: Const<I>,
) -> Result<Certainty, NoSolution> {
) -> Result<Answer<Region<I>, I::Ty>, NoSolution> {
self.delegate.is_transmutable(dst, src, assume)
}

Expand Down
44 changes: 43 additions & 1 deletion compiler/rustc_next_trait_solver/src/solve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ mod trait_goals;

use derive_where::derive_where;
use rustc_type_ir::inherent::*;
use rustc_type_ir::lang_items::SolverTraitLangItem;
pub use rustc_type_ir::solve::*;
use rustc_type_ir::{self as ty, Const, Interner, Region, TypeVisitableExt};
use rustc_type_ir::transmute::Condition;
use rustc_type_ir::{self as ty, Const, Interner, Region, TraitClause, TypeVisitableExt, Upcast};
use thin_vec::{ThinVec, thin_vec};
use tracing::instrument;

pub use self::eval_ctxt::{
Expand Down Expand Up @@ -491,3 +494,42 @@ pub struct GoalEvaluation<I: Interner> {
/// before rerunning it.
pub stalled_on: Option<GoalStalledOn<I>>,
}

/// Flatten the `Condition` tree into a conjunction of predicates.
#[instrument(level = "debug", skip(interner, predicate))]
pub fn flatten_answer_tree<I: Interner>(
interner: I,
predicate: TraitClause<I>,
cond: Condition<Region<I>, I::Ty>,
) -> ThinVec<I::Predicate> {
match cond {
// FIXME(bryangarza): Add separate `IfAny` case, instead of treating as `IfAll`
// Not possible until the trait solver supports disjunctions of obligations
Condition::IfAll(conds) | Condition::IfAny(conds) => conds
.into_iter()
.flat_map(|cond| flatten_answer_tree(interner, predicate, cond))
.collect(),
Condition::Immutable { ty } => {
let trait_ref = ty::TraitRef::new(
interner,
interner.require_trait_lang_item(SolverTraitLangItem::Freeze),
[I::GenericArg::from(ty)],
);
thin_vec![trait_ref.upcast(interner)]
}
Condition::Outlives { long, short } => {
let outlives = ty::OutlivesClause(long, short);
thin_vec![outlives.upcast(interner)]
}
Condition::Transmutable { src, dst } => {
let transmute_trait = predicate.def_id();
let assume = predicate.trait_ref.args.const_at(2);
let trait_ref = ty::TraitRef::new(
interner,
transmute_trait,
[I::GenericArg::from(dst), I::GenericArg::from(src), I::GenericArg::from(assume)],
);
thin_vec![trait_ref.upcast(interner)]
}
}
}
23 changes: 21 additions & 2 deletions compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::solve::assembly::{
use crate::solve::inspect::ProbeKind;
use crate::solve::{
BuiltinImplSource, CandidateSource, Certainty, EvalCtxt, Goal, GoalSource, MaybeCause,
MergeCandidateInfo, NoSolution, ParamEnvSource, StalledOnCoroutines,
MergeCandidateInfo, NoSolution, ParamEnvSource, StalledOnCoroutines, flatten_answer_tree,
has_only_region_constraints,
};

Expand Down Expand Up @@ -659,6 +659,8 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal<I, Self>,
) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
use rustc_type_ir::transmute::Answer;

if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
Expand All @@ -681,11 +683,28 @@ where
goal.predicate.trait_ref.args.const_at(2),
)?;

let certainty = ecx.is_transmutable(
let answer = ecx.is_transmutable(
goal.predicate.trait_ref.args.type_at(0),
goal.predicate.trait_ref.args.type_at(1),
assume,
)?;

let certainty = match answer {
Answer::No(_) => return Err(NoSolution.into()),
Answer::Yes => Certainty::Yes,
Answer::If(cond) => {
let tcx = ecx.cx();
ecx.add_goals(
GoalSource::Misc,
flatten_answer_tree(tcx, goal.predicate, cond)
.into_iter()
.map(|predicate| Goal::new(tcx, goal.param_env, predicate)),
)?;

Certainty::Yes
}
};

ecx.evaluate_added_goals_and_make_canonical_response(certainty)
},
)
Expand Down
Loading
Loading