Commit Graph

914 Commits

Author SHA1 Message Date
Alex Chi
51d66714ac fix panic on GAT
Signed-off-by: Alex Chi <iskyzh@gmail.com>
2022-04-11 13:52:02 +08:00
Florian Diebold
340f0fc333 Ignore Drop and Destruct bounds for now
- `T: ~const Drop` has a special meaning in Rust 1.61 that we don't implement.
  (So ideally, we'd only ignore `~const Drop`, but this should be fine
  for now.)
- `Destruct` impls are built-in in 1.62 (current nightlies as of 08-04-2022), so until
  the builtin impls are supported by Chalk, we ignore them as well.
  Since `Destruct` is implemented for everything in non-const contexts
  IIUC, this should also work fine.

Fixes #11932.
2022-04-08 14:29:43 +02:00
bors[bot]
b8ed4a388c
Merge #11920
11920: Consider types of const generics r=flodiebold a=HKalbasi

fix #11913 

We should emit type_mismatch in const generics, probably after #7434. Currently they will lead to a misleading, time of use type error (like the added test).


Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-04-07 17:08:02 +00:00
Jonas Schievink
5d8b4c40eb Determine function unsafety semantically 2022-04-07 18:33:03 +02:00
bors[bot]
12f803d1e3
Merge #11925
11925: internal: Add and use `HirFormatter::write_{str,char}` r=Veykril a=lnicola

Saves slightly over 3 KB of `text`, but comparing the total with that from two weeks ago in #11776, this is a losing battle (we're 951 KB larger).

```
   text	   data	    bss	    dec	    hex	filename
24693512	1542704	   4424	26240640	1906680	rust-analyzer-baseline
24690216	1542112	   4424	26236752	1905750	rust-analyzer-pr
```


Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2022-04-07 14:38:46 +00:00
Jonas Schievink
67495b618b Fix panics with #[cfg]'d-out self parameter 2022-04-07 15:47:03 +02:00
Laurențiu Nicola
bd570903b0 Add and use HirFormatter::write_{str,char} 2022-04-07 16:41:07 +03:00
Jonas Schievink
6501e45131 Remove FnFlags::IS_IN_EXTERN_BLOCK 2022-04-07 15:22:11 +02:00
hkalbasi
204a1561b2 consider types of const generics 2022-04-07 05:30:33 +04:30
Lukas Wirth
3632d5946f minor: Remove pointless rebindings 2022-04-07 01:29:31 +02:00
Jonas Schievink
872b7b9660 Wrap macros in expr position in MacroExpr node 2022-04-05 17:43:34 +02:00
iDawer
86665e50c2 fix: Skip match check on a pattern of unexpected TyKind::FnDef 2022-04-05 00:05:20 +05:00
Florian Diebold
b898808a35 fix: Don't rely on lang items to find primitive impls
rustc has removed the use of lang items to mark the primitive impls, so
just look through the crate graph for them (this should be fine
performance-wise since we cache the crates that contain these impls).

Fixes #11876.
2022-04-02 15:32:40 +02:00
bors[bot]
5fe366c649
Merge #11878
11878: fix: Paper over GAT panic r=flodiebold a=flodiebold

TIL that Chalk expects the arguments to a generic associated type to come *before* the ones for the parent trait, not *after* as we have been doing with all other nested generics. Fixing this requires a larger refactoring, so for now this just papers over the problem by completely ignoring parameters of associated types.

Fixes #11769.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-04-02 12:41:14 +00:00
Florian Diebold
019f48673a fix: Paper over GAT panic
TIL that Chalk expects the arguments to a generic associated type to
come *before* the ones for the parent trait, not *after* as we have been
doing with all other nested generics. Fixing this requires a larger
refactoring, so for now this just papers over the problem by completely
ignoring parameters of associated types.

Fixes #11769.
2022-04-02 13:14:42 +02:00
hkalbasi
049f0a6d2c recover from missing type annotation 2022-04-01 17:20:54 +04:30
Lukas Wirth
75689f2ad8 internal: Enforce Resolver to always have a module scope 2022-03-31 11:12:08 +02:00
Florian Diebold
ea1d0bccef Fix divergence detection for bare match arms
Fixes #11814 and #11837.
2022-03-29 21:56:49 +02:00
Florian Diebold
0c4bdd2f32 Fix duplicate type mismatches with blocks
E.g. when there's a type mismatch on the return value of a function. To
fix this, we have to return the expected type as the type of the block
when there's a mismatch. That meant some IDE code that expected
otherwise had to be adapted, in particular the "add return type" assist.
For the "wrap in Ok/Some" quickfix, this sadly means it usually can't be applied
in all branches of an if expression at the same time anymore, because
there's a type mismatch for each branch that has the wrong type.
2022-03-29 18:06:52 +02:00
bors[bot]
89d495eb30
Merge #11840
11840: Fix another const generic panic r=flodiebold a=HKalbasi

fix #11835

If I change `dyn` to `impl` in the test, it will infer the type as `IntoIterator::Item<impl Iterator<Item = [Ar<u8, 7>; 9]> + ?Sized>` instead of `[Ar<u8, 7>; 9]`. Maybe it needs some action?

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-03-29 10:55:17 +00:00
hkalbasi
4fe0545bb6 fix regression_11688_3 2022-03-29 11:03:55 +04:30
Florian Diebold
c2a31bfbb8 Remove legacy_const_generics_indices from CallableSig
I want to remove CallableSig anyway, and it's not needed anymore.
2022-03-27 19:21:09 +02:00
Florian Diebold
2be7e26d7d Move mismatched-arg-count diagnostic to inference 2022-03-27 19:21:09 +02:00
Laurențiu Nicola
85f797f59c Bump chalk 2022-03-27 10:11:02 +03:00
hkalbasi
bf4a1e4842 use pat_id instead of name in const eval stack 2022-03-24 13:36:37 +04:30
hkalbasi
22eaee25b8 organize const eval tests 2022-03-24 13:20:35 +04:30
hkalbasi
0e2989e421 Support constants in const eval 2022-03-24 13:09:22 +04:30
bors[bot]
b8e1d09b90
Merge #11806
11806: fix: Fix async block type inference using containing function return type r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11804
Should fix https://github.com/rust-analyzer/rust-analyzer/issues/11798#issuecomment-1076880521

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-23 22:45:44 +00:00
Lukas Wirth
ed0c62597f fix: Fix async block type inference using containing function return type 2022-03-23 23:43:04 +01:00
bors[bot]
75fada4aab
Merge #11805
11805: fix: Don't try to resolve methods on unknown types r=Veykril a=flodiebold

Fixes #10454, and some type mismatches.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-03-23 20:20:09 +00:00
Florian Diebold
e0e6bfb924 Fix filter_map in minicore 2022-03-23 19:47:11 +01:00
Florian Diebold
8d98f3c983 Don't try to resolve methods on unknown types
Fixes #10454, and some type mismatches.
2022-03-23 19:18:12 +01:00
bors[bot]
1a92ee5db5
Merge #11792
11792: minor: Bump dependencies r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-22 21:00:24 +00:00
Lukas Wirth
8e91bb7660 minor: Bump dependencies 2022-03-22 17:42:24 +01:00
Florian Diebold
5f24ff0d84 Fix unreachable_pub 2022-03-21 18:54:20 +01:00
Florian Diebold
8498eaa6ab Implement type checking for legacy_const_generics 2022-03-21 16:46:01 +01:00
Florian Diebold
2ef541b35f Cleanups 2022-03-21 16:46:01 +01:00
Florian Diebold
b632d706c7 Remove old diagnostics 2022-03-21 16:46:01 +01:00
Florian Diebold
2d30dd67d3 Expose coercion logic in hir API 2022-03-21 16:45:59 +01:00
Florian Diebold
6133e6a002 Extract coercion logic to InferenceTable
To make it accessible without an InferenceContext.
2022-03-21 16:45:30 +01:00
Laurențiu Nicola
1a37b17162 Replace write! with direct calls 2022-03-21 10:43:36 +02:00
bors[bot]
fedf724d82
Merge #11774
11774: feat: Tag macro calls as unsafe if they expand to unsafe expressions r=Veykril a=Veykril

as long as they aren't inside an unsafe block inside the macro that is.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-20 18:15:29 +00:00
Lukas Wirth
3b7b223b25 Simplify 2022-03-20 19:13:50 +01:00
Lukas Wirth
68de7b30e0 feat: Tag macro calls as unsafe if they expand to unsafe expressions 2022-03-20 19:07:44 +01:00
bors[bot]
966b692422
Merge #11771
11771: feat: Visualize compiler inserted reborrows via inlay hints r=Veykril a=Veykril

Disabled by default.

![image](https://user-images.githubusercontent.com/3757771/159165178-baaf968a-4381-468e-933f-5326ca1b203d.png)

Closes https://github.com/rust-analyzer/rust-analyzer/issues/11275


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-20 13:47:16 +00:00
Lukas Wirth
37b48ceb8f feat: Visualize compiler inserted reborrows via inlay hints 2022-03-20 14:38:16 +01:00
Florian Diebold
60aeb8fa1a Move fallback_bound_vars to the only place it's used now 2022-03-17 17:08:43 +01:00
Florian Diebold
9ea2e0bd5b Fixes for consts 2022-03-17 17:04:32 +01:00
Florian Diebold
59b5696aaa Snapshot obligations 2022-03-17 17:04:32 +01:00
Florian Diebold
8f5b6ac556 Properly try unifying the receivers during method resolution
Instead of hackily checking if they're equal.
2022-03-17 17:03:54 +01:00