Ryo Yoshida
6aa03c5d15
Use Cast::cast()
instead of interning GenericArgData
2023-08-09 00:47:29 +09:00
Tadeo Kondrak
92a97c292a
hir: Remove Expr::While
...
The previous commit desugared it to a loop.
2023-08-01 19:08:16 -06:00
bors
037844c8a0
Auto merge of #15271 - lowr:patch/re-castable, r=HKalbasi
...
Properly infer types with type casts
This PR reenables `Expectation::Castable` (previous attempt at #14104 , reverted by #14120 ) and implements type cast checks, which enable us to infer a bit more.
Castable expectations are relatively weak -- they only influence the inference if we cannot infer the types by other means. Therefore, we need to defer possible type unification with the casted type until we type check all expressions of the body. This PR adds a struct and slots in `InferenceContext` for the deferred cast checks (c.f. [`CastCheck`] in `rustc_hir_typeck`).
I only implemented the bits that affect the inference result. It should be possible to return type adjustments for well-formed casts and report diagnostics for invalid casts, but I'm leaving them for future work for now.
Fixes #11571
Fixes #15246
[`CastCheck`]: da1d099f91/compiler/rustc_hir_typeck/src/cast.rs (L55)
2023-07-28 07:17:38 +00:00
hkalbasi
b7d91ca5b2
Normalize expected ty in call arguments
2023-07-22 01:06:58 +03:30
hkalbasi
eb143383c3
Pass TraitEnvironment
into layout_ty
and const_eval
2023-07-20 13:08:38 +03:30
Ryo Yoshida
074488b290
Properly infer types with type casts
2023-07-13 00:14:15 +09:00
hkalbasi
3a1054fc1c
Replace x
with it
2023-07-06 17:33:17 +03:30
Ryo Yoshida
827a0530bc
Don't show unresolved-field
diagnostic for missing names
2023-07-06 20:39:48 +09:00
bors
5703346523
Auto merge of #15118 - alexkirsz:alexkirsz/resolve-deref-raw, r=Veykril
...
Follow raw pointers in autoderef chain when resolving methods with custom receiver
Fixes #15083
I believe this stopped working after e797479651
2023-07-03 14:55:08 +00:00
Ryo Yoshida
4e793e7859
Use anonymous lifetime where possible
2023-06-29 23:27:28 +09:00
Alex Kirszenberg
5991f0d869
Follow raw pointers in autoderef chain when resolving methods with custom receiver
2023-06-23 15:35:41 +02:00
Lukas Wirth
c3186202a2
Shrink size of hir::Binding
2023-06-18 12:03:04 +02:00
Lukas Wirth
abe249559d
internal: Give ConstBlockId and InTypeConstId named Location types
2023-06-12 18:21:17 +02:00
hkalbasi
a481e004b0
Lower const params with a bad id
2023-06-11 00:39:28 +03:30
Ryo Yoshida
a3789eabc9
Minor refactorings
...
- use `DefWithBodyId::as_generic_def_id()`
- add comments on `InferenceResult` invariant
- move local helper function to bottom to comply with style guide
2023-06-04 19:39:49 +09:00
Ryo Yoshida
275afd6e79
fix: consider outer binders when folding captured items' type
2023-06-04 19:38:47 +09:00
hkalbasi
f44fc271d4
Remove unnecessary StorageDead
2023-06-03 17:24:10 +03:30
hkalbasi
51368793b4
MIR episode 6
2023-05-28 23:25:15 +03:30
Lukas Wirth
8bc826dd53
Add diagnostic for _
expressions (typed holes)
2023-05-28 14:55:28 +02:00
hkalbasi
cd4bffdd69
Evaluate UnevalutedConst
before trait solving
2023-05-27 00:28:11 +03:30
hkalbasi
c21d09f3cc
insert type vars in function arguments
2023-05-26 14:26:13 +03:30
hkalbasi
780349bdaf
fix need-mut
false positive in closure capture of match scrutinee
2023-05-26 02:08:37 +03:30
hkalbasi
7ef185d65e
evaluate UnevaluatedConst
in unify
2023-05-25 19:37:20 +03:30
Lukas Wirth
c7ef6c25b7
internal: Replace Display impl for Name
2023-05-24 20:55:12 +02:00
Ryo Yoshida
01f42d2405
fix: introduce new type var when expectation for ref pat is not ref
2023-05-22 23:13:41 +09:00
hkalbasi
60379dabfb
resolve types in closure capture copy detection
2023-05-19 14:54:57 +03:30
hkalbasi
c5ea2d7adc
handle match scrutinee in closure captures
2023-05-19 12:04:12 +03:30
hkalbasi
b55fbd3ad7
Add moved-out-of-ref
diagnostic
2023-05-18 19:17:06 +03:30
bors
9ce95674e8
Auto merge of #14837 - Veykril:rustc-lexer, r=Veykril
...
Support c string literals
2023-05-18 11:55:38 +00:00
Lukas Wirth
3e528b85f9
Fix cstring literals construct &CStr not &str
2023-05-18 12:03:15 +02:00
bors
034d7c8537
Auto merge of #14787 - HKalbasi:mir2, r=HKalbasi
...
MIR episode 5
This PR inits drop support (it is very broken at this stage, some things are dropped multiple time, drop scopes are wrong, ...) and adds stdout support (`println!` doesn't work since its expansion is dummy, but `stdout().write(b"hello world\n")` works if you use `RA_SYSROOT_HACK`) for interpreting. There is no useful unit test that it can interpret yet, but it is a good sign that it didn't hit a major road block yet.
In MIR lowering, it adds support for slice pattern and anonymous const blocks, and some fixes so that we can evaluate `SmolStr::new_inline` in const eval. With these changes, 57 failed mir body remains.
2023-05-18 09:44:26 +00:00
Lukas Wirth
4b577e2bc8
Support c string literals
2023-05-18 11:06:05 +02:00
bors
a20a08f3e2
Auto merge of #14824 - Veykril:ty-diag-unit, r=Veykril
...
fix: Diagnose non-value return and break type mismatches
Could definitely deserve more polished diagnostics, but this at least brings the message across for now.
2023-05-18 05:03:42 +00:00
Lukas Wirth
478705baf5
fix: Diagnose non-value return and break type mismatches
2023-05-16 22:47:27 +02:00
Lukas Wirth
08dc0e21af
feat: Render hover actions for closure captures and sig
2023-05-15 19:35:27 +02:00
hkalbasi
cbcafd3539
MIR episode 5
2023-05-12 18:17:15 +03:30
bors
d3ce333ec8
Auto merge of #14742 - Veykril:closure-capture-inlays, r=Veykril
...
feat: Closure capture inlay hints
I opted for a fictional `move(foo, &bar, &mut qux)` syntax here, disabled by default as these are not correct rust syntax and hence could cause confusion.
![image](https://user-images.githubusercontent.com/3757771/236447484-649a4ea6-ad61-496e-bad8-765a5236150e.png )
2023-05-08 09:52:29 +00:00
Lukas Wirth
4c5fd19ee5
Render places in capture inlay hints
2023-05-08 09:50:58 +02:00
Lukas Wirth
8081a654da
feat: Closure capture inlay hints
2023-05-05 13:38:22 +02:00
hkalbasi
aafe9b1e06
Lazy evaluate consts in path_to_const
2023-05-05 01:17:11 +03:30
hkalbasi
36c9d5ce17
Fix pattern type mismatch in tuples
2023-05-04 16:03:36 +03:30
Laurențiu Nicola
7197a27028
Use triomphe Arc
2023-05-02 20:02:43 +03:00
Lukas Wirth
5a97a326a9
Simplify
2023-05-02 09:05:28 +02:00
Lukas Wirth
a64626d99e
Highlight closure captures when cursor is on pipe
2023-05-02 08:59:40 +02:00
hkalbasi
6312fbf521
MIR episode 4
2023-05-01 23:23:10 +03:30
hkalbasi
5df545b3f0
Add hover for closure
2023-04-30 14:31:43 +03:30
Ryo Yoshida
12ba5cab11
Register obligations during path inference
2023-04-24 12:39:48 +09:00
hkalbasi
0c621065fb
Fix need-mut large span in closures and a false positive
2023-04-21 02:15:19 +03:30
bors
2400b36a2e
Auto merge of #14577 - jsoref:spelling, r=lnicola
...
Spelling
This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling ).
The misspellings have been reported at https://github.com/jsoref/rust-analyzer/actions/runs/4699991040#summary-12751355796
The action reports that the changes in this PR would make it happy: https://github.com/jsoref/rust-analyzer/actions/runs/4699991284#summary-12751356293
closes #14567
2023-04-19 14:05:40 +00:00
Josh Soref
bc7d84c3ce
Spelling
...
* a rule
* access
* after
* amount
* annotations
* assignment
* assist
* associated
* attribute
* borrowed
* built-in type
* clarification
* command
* const
* constructor
* corresponding
* counterparts
* curlies
* dependencies
* deterministic
* diagnostic
* duplicates
* edge
* edited
* efficient
* elsewhere
* execution
* expression
* extensions
* extracted
* fill
* github
* helper
* heuristic
* incomplete
* indent end
* inlay
* invocation
* lifetime
* looking
* maybe
* move
* mutability
* mutable
* necessarily
* necessary
* negative
* nonexistent
* occurred
* offsets
* offsetted
* overridden
* parameters
* params
* params_and_where_preds_in_scope
* paredit
* parent
* parentheses
* prepended if
* punctuation
* receive
* receiver
* referring
* repeated
* representing
* semantically
* separately
* shouldnot
* siblings
* similar
* something's
* statement
* struct
* structure
* surprise
* the
* this
* transparent
* unimplemented
* unnamed
* unnecessary
* unneeded
* unreachable
* unterminated
* utilities
* variant
* variants
* visibility
* work around (v)
* workaround
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-19 09:45:55 -04:00