Commit graph

713 commits

Author SHA1 Message Date
bors
e2fd1db609 Auto merge of #17859 - Veykril:rustc_deprecated_safe_2024, r=Veykril
fix: Correctly support `#[rustc_deprecated_safe_2024]`

Fixes https://github.com/rust-lang/rust-analyzer/issues/17852
2024-08-12 08:59:08 +00:00
Lukas Wirth
ded3e21fdd fix: Correctly support #[rustc_deprecated_safe_2024] 2024-08-12 10:56:59 +02:00
bors
6d9af33b31 Auto merge of #17845 - ShoyuVanilla:tait, r=Veykril
feat: Implement TAIT and fix ATPIT a bit

Closes #16296 (Commented on the issue)

In #16852, I implemented ATPIT, but as I didn't discern ATPIT and other non-assoc TAIT, I guess that it has been working for some TAITs.

As the definining usage of TAIT requires it should be appear in the Def body's type(const blocks' type annotations or functions' signatures), this can be done in simlilar way with ATPIT

And this PR also corrects some defining-usage resolution for ATPIT
2024-08-12 08:08:40 +00:00
Nadrieril
459e395519 Fixes in various places 2024-08-10 12:08:46 +02:00
Lukas Wirth
24c0e0bd48 fix: Fix find_path not respecting non-std preference config correctly 2024-08-10 10:32:10 +02:00
Shoyu Vanilla
c530e21714 feat: Implement TAIT 2024-08-10 15:22:05 +09:00
Shoyu Vanilla
aa62c9d664 fix: Panic while rendering function with impl trait arg 2024-08-08 22:03:31 +09:00
Vincent Esche
7dec7e92ea Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
Vincent Esche
6f329e6d5b Add repository URL for published crates' missing [package.repository] fields 2024-08-06 00:25:02 +02:00
Vincent Esche
b5b0f4bc5a Replace "TBD" with more helpful desciptions in published crates' [package.description] fields 2024-08-06 00:25:02 +02:00
Lukas Wirth
deddbbfa60 Surpress type mismatches in calls with mismatched arg counts 2024-08-05 16:15:28 +02:00
Lukas Wirth
fcb88832de Simplify FileDelegate 2024-08-05 13:03:03 +02:00
Shoyu Vanilla
8fa454d7aa fix: Insert a generic arg for impl Trait when lowering generic args 2024-08-05 00:06:29 +09:00
Shoyu Vanilla
b5494d7cc3 Prevent redundant obigation push for assignee exprs 2024-08-01 02:51:33 +09:00
Shoyu Vanilla
20e2623234 fix: Apply IndexMut obligations for non-assigning mutable index usages, too 2024-08-01 02:20:52 +09:00
Shoyu Vanilla
a871730142
Add a test case 2024-07-31 10:47:13 +09:00
Shoyu Vanilla
92a6e51b20 fix: Errors on method call inferences with elided lifetimes 2024-07-31 02:36:44 +09:00
Francis McKenzie
e77752eaf0 Fix for #17497 - Invalid RA diagnostic error: expected 2 arguments, found 1
The issue occurs because in some configurations of traits where one of them has Deref as a supertrait, RA's type inference algorithm fails to resolve the Deref::Target type, and instead uses a TyKind::BoundVar (i.e. an unknown type). This "autoderefed" type then incorrectly acts as if it implements all traits in scope.

The fix is to re-apply the same sanity-check that is done in iterate_method_candidates_with_autoref(), that is: don't try to resolve methods on unknown types. This same sanity-check is now done on each autoderefed type for which trait methods are about to be checked. If the autoderefed type is unknown, then the iterating of the trait methods for that type is skipped.

Includes a unit test that only passes after applying the fixes in this commit.

Includes a change to the assertion count in test syntax_highlighting::tests::benchmark_syntax_highlighting_parser as suggested by Lukas Wirth during review.

Includes a change to the sanity-check code as suggested by Florian Diebold during review.
2024-07-28 00:32:37 +08:00
Lukas Wirth
0e93e6fee7 Make legacy_const_generics_indices thin by double boxing as its seldom used 2024-07-25 11:51:15 +02:00
Lukas Wirth
f2fa456a8c Fix incorrect handling of cfg'd varargs 2024-07-25 11:02:19 +02:00
Lukas Wirth
9cbafa2d49 Remove Params and Fields from AstIdMap 2024-07-25 10:22:05 +02:00
Lukas Wirth
7c374a10bd internal: Shrink size of Binding 2024-07-22 17:14:17 +02:00
Shoyu Vanilla
6e728df43a fix: Panic in debug profile for tuple deconstruct with arity mismatch 2024-07-21 02:37:37 +09:00
bors
b333f85a9d Auto merge of #17639 - Veykril:salsa-perf, r=Veykril
Some more small salsa memory improvements

This does limit our lru limits to 2^16 but if you want to set them higher than that you might as well not set them at all. Also makes `LRU` opt-in per query now, allowing us to drop all the unnecessary LRU stuff for most queries
2024-07-19 18:45:16 +00:00
Lukas Wirth
6d4989b3c7 Make LRU opt-in 2024-07-19 18:38:08 +02:00
bors
fa3dd33c27 Auto merge of #17620 - Veykril:edition-aware-parser, r=Veykril
Edition aware parser

Fixes https://github.com/rust-lang/rust-analyzer/issues/16324 by allowing us to properly thread through the edition to the parser
2024-07-19 14:56:56 +00:00
Lukas Wirth
5264f86242 Encode edition within FileId in the hir layer 2024-07-18 08:49:10 +02:00
bors
a62ea0a59e Auto merge of #17618 - Veykril:rustc_skip_during_method_dispatch, r=Veykril
Support rustc_skip_during_method_dispatch

Fixes https://github.com/rust-lang/rust-analyzer/issues/17256
2024-07-17 09:48:18 +00:00
Lukas Wirth
92268627a8 Support rustc_skip_during_method_dispatch 2024-07-17 11:46:36 +02:00
bors
cf156a7a43 Auto merge of #17609 - lnicola:sync-from-rust, r=lnicola
minor: Sync from downstream
2024-07-16 13:38:39 +00:00
Laurențiu Nicola
6a121d177d Merge from rust-lang/rust 2024-07-16 16:23:47 +03:00
Lukas Wirth
2346a80ab4 Remove Name::to_smol_str 2024-07-16 12:43:58 +02:00
Lukas Wirth
df5f1777b8 More symbol usage 2024-07-16 12:05:16 +02:00
Lukas Wirth
93024ad411 Switch token trees to use Symbols 2024-07-16 10:11:59 +02:00
Laurențiu Nicola
5f9ce1dcd4 Use re-exported Idx and IndexVec in pat_analysis 2024-07-16 10:41:13 +03:00
bors
f913901399 Auto merge of #17559 - Veykril:tokentree, r=Veykril
Encode ident rawness and literal kind separately in tt::Leaf
2024-07-15 11:25:51 +00:00
Lukas Wirth
dcfda55c82 Escape fetched env vars in env! expansion 2024-07-15 13:08:29 +02:00
bors
5ece16cf17 Auto merge of #17588 - CamWass:more-rename, r=Veykril
feat: Add incorrect case diagnostics for enum variant fields and all variables/params

Updates the incorrect case diagnostic to check:

1. Fields of enum variants. Example:
```rust
enum Foo {
    Variant { nonSnake: u8 }
}
```
2. All variable bindings, instead of just let bindings and certain match arm patters. Examples:
```rust
match 1 { nonSnake => () }
match 1 { nonSnake @ 1 => () }
match 1 { nonSnake1 @ nonSnake2 => () } // slightly cursed, but these both introduce new
                                        // bindings that are bound to the same value.

const ONE: i32 = 1;
match 1 { nonSnake @ ONE } //  ONE is ignored since it is not a binding

match Some(1) { Some(nonSnake) => () }

struct Foo { field: u8 }
match (Foo { field: 1 } ) {
    Foo { field: nonSnake } => ();
}

struct Foo { nonSnake: u8 } // diagnostic here, at definition
match (Foo { nonSnake: 1 } ) { // no diagnostic here...
    Foo { nonSnake } => ();    // ...or here, since these are not where the name is introduced
}

for nonSnake in [] {}

struct Foo(u8);
for Foo(nonSnake) in [] {}
```
3. All parameter bindings, instead of just top-level binding identifiers. Examples:
```rust
fn func(nonSnake: u8) {} // worked before

struct Foo { field: u8 }
fn func(Foo { field: nonSnake }: Foo) {} // now get diagnostic for nonSnake
```

This is accomplished by changing the way binding identifier patterns are filtered:
- Previously, all binding idents were skipped, except a few classes of "good" binding locations that were checked.
- Now, all binding idents are checked, except field shorthands which are skipped.

Moving from a whitelist to a blacklist potentially makes the analysis more brittle:
If new pattern types are added in the future where ident pats don't introduce new names, then they may incorrectly create diagnostics.

But the benefit of the blacklist approach is simplicity: I think a whitelist approach would need to recursively visit patterns to collect renaming candidates?
2024-07-15 10:07:37 +00:00
Lukas Wirth
f2d51073d2 Use statics + clone instead of const until const can access statics 2024-07-14 17:52:59 +02:00
Campbell
af30111b1c feat: Add incorrect case diagnostics for enum variant fields and all variables 2024-07-13 21:54:22 +12:00
Lukas Wirth
3fe815b0f3 Use Symbol in Name 2024-07-12 16:06:44 +02:00
beetrees
d5db933f9d
Add f16 and f128 support 2024-07-10 10:43:14 +01:00
beetrees
320022622c
fix: Fix double rounding of f32 literals 2024-07-08 16:31:32 +01:00
bors
a494aaba87 Auto merge of #17523 - wada314:master, r=Veykril
Add an option to use "::" for the external crate prefix.

Fixes #11823 .
Hi I'm very new to rust-analyzer and not sure how the review process are. Can somebody take a look at this PR? thanks!
2024-07-07 08:32:46 +00:00
Lukas Wirth
866102cdaf Re-implement tidy as an xtask action 2024-07-07 09:12:16 +02:00
Lukas Wirth
b9c1c42959 Allow new clippy lint in test 2024-07-07 08:41:41 +02:00
bors
058c88da66 Auto merge of #17551 - Veykril:has-errors, r=Veykril
Also mark InferenceResult::has_errors flag when there are error types

Should work around https://github.com/rust-lang/rust-analyzer/issues/15090#issuecomment-2211647133
2024-07-06 18:56:23 +00:00
Lukas Wirth
e0105c473e Also mark InferenceResult::has_errors flag when there are error types 2024-07-06 20:45:23 +02:00
Lukas Wirth
4420e7148f Diagnose unresolved self value in path expression 2024-07-06 15:44:12 +02:00
Shoyu Vanilla
4bb623decb Disallow nested impl traits 2024-07-04 23:31:55 +09:00
Lukas Wirth
26c7bfd0b4 Skip match exhaustiveness checking if pattern type contains errors 2024-07-03 08:31:40 +02:00
Lukas Wirth
baa959fa99 Move lifetimes in front of type and const params but after self 2024-07-02 14:17:34 +02:00
Lukas Wirth
966798b7ba Make GenericParams::lifetimes private 2024-07-02 13:45:53 +02:00
Lukas Wirth
be1ea4028b Make GenericParams::where_predicates private 2024-07-02 13:45:50 +02:00
Lukas Wirth
372e2d22e6 Make GenericParams::type_or_consts private 2024-07-02 13:45:48 +02:00
Lukas Wirth
1a929d6485 Fix lifetime parameters moving paramter defaults 2024-07-02 12:34:32 +02:00
Shohei Wada
3725ab3146 squash. 2024-07-02 01:52:34 +09:00
bors
72f278b5be Auto merge of #17522 - Veykril:comptimes, r=Veykril
internal: Cut compiletimes slightly
2024-07-01 08:43:11 +00:00
Lukas Wirth
d859e40db9 Bump rustc_pattern_analysis 2024-06-30 18:41:55 +02:00
bors
ea7fdada6a Auto merge of #17520 - Veykril:slim-proc-macro-api, r=Veykril
internal: Cleanup proc-macro-srv some more
2024-06-30 15:12:50 +00:00
Lukas Wirth
21a3d01875 Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
Shoyu Vanilla
7e9da2d67d Use proper ImplTraits in insert_inference_vars_for_impl_trait 2024-06-27 23:51:33 +09:00
Shoyu Vanilla
50b7678621 Add a regression test for issue 17199 that causes stack overflow 2024-06-27 23:48:15 +09:00
Lukas Wirth
8df034d453 Shrink mbe's Op 2024-06-24 10:07:32 +02:00
Lukas Wirth
5548aecdca Save a bit on empty item trees by deduplicating them 2024-06-24 10:07:32 +02:00
Lukas Wirth
3168ab5b99 Enum variants are not generic def ids 2024-06-24 10:07:31 +02:00
Lukas Wirth
4c62e6b05f Prevent re-allocation in CallableSig::from_params_and_return 2024-06-21 19:26:08 +02:00
Lukas Wirth
34ba8db3ed Save allocations for empty generic_defaults query results 2024-06-21 19:21:27 +02:00
Lukas Wirth
2761b1e236 Don't attempt to compute implict sized clauses for empty generics 2024-06-21 19:10:57 +02:00
Lukas Wirth
4d709cc866 Save allocations for empty generic_predicates query results 2024-06-21 19:10:45 +02:00
Lukas Wirth
7a16e06009 Lazy generics 2024-06-21 18:38:37 +02:00
Lukas Wirth
c01f4cf902 Simplify 2024-06-21 18:27:05 +02:00
Lukas Wirth
480bfd5a7d There can only be one self param 2024-06-21 17:55:16 +02:00
Lukas Wirth
cf2b757a1a Light docs and privacy 2024-06-21 17:54:40 +02:00
Lukas Wirth
585cc9e014 Extract generics module 2024-06-21 10:55:05 +02:00
Laurențiu Nicola
0a2652390a Merge from rust-lang/rust 2024-06-20 08:03:36 +03:00
Wilfred Hughes
3874681cb6 Prefer plain trait definitions over macros for salsa 2024-06-13 17:32:06 -07:00
Ralf Jung
588eb6b6ad use is_none_or in some places in the compiler 2024-06-12 16:20:07 +02:00
bors
22648b2655 Auto merge of #17405 - Veykril:modpath-clone, r=Veykril
internal: Don't unnecessarily clone ModPaths in early name res
2024-06-12 09:27:49 +00:00
Lukas Wirth
855282fa53 internal: Don't unnecessarily clone ModPaths in early name res 2024-06-12 11:25:19 +02:00
bors
c07076b35c Auto merge of #17394 - Veykril:recurse-fix, r=Veykril
fix: Fix `HirDisplay` stackoverflow for parameter Self defaults

Fixes https://github.com/rust-lang/rust-analyzer/issues/10932
2024-06-11 15:05:26 +00:00
Lukas Wirth
1ecf230792 fix: Fix HirDisplay stackoverflow for parameter Self defaults 2024-06-11 17:04:07 +02:00
roife
78118f98f6 feat: add hover config for showing container bounds 2024-06-11 21:02:13 +08:00
Lukas Wirth
d4dc3ca83b Register virtual workspace Cargo.toml files in the VFS 2024-06-09 12:54:50 +02:00
Wilfred Hughes
27182bb96b chore: Prefer tracing span shorthand macros 2024-06-06 16:52:25 -07:00
Lukas Wirth
60fa981df1 Simplify 2024-06-03 19:06:58 +02:00
bors
89218cf29c Auto merge of #17329 - Nilstrieb:rustc_deprecated_safe_2024, r=Veykril
Don't mark `#[rustc_deprecated_safe_2024]` functions as unsafe

`std::env::set_var` will be unsafe in edition 2024, but not before it. I couldn't quite figure out how to check for the span properly, so for now we just turn the false positives into false negatives, which are less bad.
2024-06-03 12:44:21 +00:00
Nilstrieb
0e1353bebd Don't mark #[rustc_deprecated_safe_2024] functions as unsafe
`std::env::set_var` will be unsafe in edition 2024, but not before it.
I couldn't quite figure out how to check for the span properly, so for now
we just turn the false positives into false negatives, which are less bad.
2024-06-02 15:04:26 +02:00
Hamir Mahal
7c34eb3880
style: simplify string interpolation 2024-05-30 16:18:49 -07:00
bors
f6fc109fcb Auto merge of #17287 - Veykril:sysroot-encode-empty, r=Veykril
Allow sysroots to only consist of the source root dir

Fixes https://github.com/rust-lang/rust-analyzer/issues/17159

This PR encodes the `None` case of an optional sysroot into `Sysroot` itself. This simplifies a lot of things and allows us to have sysroots that consist of nothing, only standard library sources, everything but the standard library sources or everything. This makes things a lot more flexible. Additionally, this removes the workspace status bar info again, as it turns out that that can be too much information for the status bar to handle (this is better rendered somewhere else, like in the status view).
2024-05-23 18:13:47 +00:00
Lukas Wirth
bd37e2790b Allow sysroots to only consist of the source root dir 2024-05-23 20:12:31 +02:00
bors
dec43b6cb3 Auto merge of #17174 - Kohei316:fix-infer-async-block-with-tail-return-expr, r=Veykril
Fix: infer type of async block with tail return expr

Fixes #17106
The `infer_async_block` method calls the `infer_block` method internally, which returns the never type without coercion when `tail_expr` is `None` and `ctx.diverges` is `Diverges::Always`.This is the reason for the bug in this issue.
cfce2bb46d/crates/hir-ty/src/infer/expr.rs (L1411-L1413)

This PR solves the bug by adding a process to coerce after calling `infer_block` method.

This code passes all the tests, including tests I added for this isuue, however, I am not sure if this solution is right. I think that this solution is an ad hoc solution. So, I would appreciate to have your review.
I apologize if I'm off the mark, but `infer_async_block` method should be rewritten to share code with the process of infering type of `expr::Closure` instead of the `infer_block` method. That way it will be closer to the infer process of rustc.
2024-05-23 08:42:09 +00:00
Lukas Wirth
ac3b2d4b54
Update crates/hir-ty/src/infer/expr.rs 2024-05-23 10:36:57 +02:00
Lukas Wirth
3a7dcf91c4 Simplify 2024-05-22 21:57:44 +02:00
David Barsky
b75301cec8 internal: refactor prefer_no_std/prefer_prelude bools into a struct 2024-05-22 20:46:30 +02:00
bors
6a16749eb0 Auto merge of #17277 - Veykril:find-path-fixes, r=Veykril
fix: Various find path fixes

Fixes https://github.com/rust-lang/rust-analyzer/issues/17271
2024-05-22 18:22:32 +00:00
bors
daf66ad8eb Auto merge of #17268 - Veykril:signatures, r=Veykril
feat: More callable info

With this PR we retain more info about callables other than functions, allowing for closure parameter type inlay hints to be linkable as well as better signature help around closures and `Fn*` implementors.
2024-05-22 12:48:17 +00:00
Lukas Wirth
c88b421853 fix: Fix general find-path inconsistencies 2024-05-22 14:05:24 +02:00
Laurențiu Nicola
49cae17fa2 Merge from rust-lang/rust 2024-05-19 11:20:26 +03:00
Lukas Wirth
7bd343e085 Show fn traits in signature info for trait implementors 2024-05-18 16:22:59 +02:00
Lukas Wirth
ff79903cf6 Render closure fn trait kind in siganture help 2024-05-18 15:01:37 +02:00
beetrees
861cca5249
Refactor float Primitives to a separate Float type 2024-05-06 14:56:10 +01:00
dfireBird
8cbeb04ba2
fix lifetime bound var index in dyn trait 2024-05-05 23:40:34 +05:30
Lukas Wirth
c97ac34caa Fix impl trait params not being counted properly 2024-05-02 13:56:10 +02:00
Lukas Wirth
8241d8a0b8 fix: Fix implicit ty args being lowered where they shouldn't 2024-05-02 11:53:53 +02:00
Wilfred Hughes
c981ff0944 fix: Tracing span names should match function names
When viewing traces, it's slightly confusing when the span name doesn't
match the function name. Ensure the names are consistent.

(It might be worth moving most of these to use #[tracing::instrument]
so the name can never go stale. @davidbarsky suggested that is marginally
slower, so I've just done the simple change here.)
2024-04-30 11:22:47 -07:00
morine0122
da3fa2b7f0 Fix coercion of async block 2024-04-30 18:31:10 +09:00
dfireBird
40a677ddf0
implement creating generics for impl traits in associated types 2024-04-29 23:55:02 +05:30
Lukas Wirth
bfe59bbdc8 fix: Fix attributes on generic parameters colliding in item tree 2024-04-27 13:15:36 +02:00
Lukas Wirth
ac389ce2ef fix: Fix expression scopes not being calculated for inline consts 2024-04-25 09:49:19 +02:00
Lukas Wirth
31304ad1ad Drop unknown lifetimes when rendering generic args 2024-04-24 21:22:48 +02:00
Bao Zhiyuan
5c88e98419 different error code based on variant 2024-04-23 20:54:03 +08:00
bors
4c08e2d32f Auto merge of #16938 - Nilstrieb:dont-panic-tests, r=Veykril
Implement `BeginPanic` handling in const eval

for #16935, needs some figuring out of how to write these tests correctly
2024-04-21 16:22:02 +00:00
Lukas Wirth
3b9a2af21f Peek for panic message in test output 2024-04-21 08:50:25 +02:00
Laurențiu Nicola
4c94e69115 Add in-rust-tree feature to hir-expand 2024-04-20 18:44:27 +03:00
Lukas Wirth
6de838c255 Implement BeginPanic for mir eval 2024-04-19 12:42:32 +02:00
Lukas Wirth
a9140e197c Fix #[rustc_const_panic_str] functions not actually being hooked 2024-04-18 15:49:08 +02:00
Nilstrieb
805f569adc Handle panicking like rustc CTFE does
Instead of using `core::fmt::format` to format panic messages, which may in turn
panic too and cause recursive panics and other messy things, redirect
`panic_fmt` to `const_panic_fmt` like CTFE, which in turn goes to
`panic_display` and does the things normally. See the tests for the full
call stack.
2024-04-18 12:20:54 +02:00
David Barsky
5ba37f3f8e chore: fix a few spans without .entered() 2024-04-17 12:44:49 -04:00
Lukas Wirth
531a270d91 Generally optimize diagnostics performance 2024-04-15 22:15:41 +02:00
Lukas Wirth
94e38261b3 Optimize exhaustiveness checking perf a bit 2024-04-15 19:35:48 +02:00
Lukas Wirth
91659da5a6 internal: Use hir_fmt_args everywhere in hir_ty::display 2024-04-15 16:17:29 +02:00
Lukas Wirth
1915980031 fix: Fix impl Trait<Self> causing stackoverflows 2024-04-15 15:41:20 +02:00
Laurențiu Nicola
f5e4eb2ef9 Fix rustc_skip_array_during_method_dispatch edition check 2024-04-15 08:54:07 +03:00
Lukas Wirth
83370fe5d7 Use Edition::CURRENT 2024-04-14 15:30:29 +02:00
Lukas Wirth
8078c3d9e8 Bump chalk 2024-04-08 11:03:19 +02:00
Lukas Wirth
a82e028e30 Cleanup util::Generics method names 2024-04-06 14:29:40 +02:00
Lukas Wirth
336dee3415 Remove some allocs 2024-04-06 13:40:15 +02:00
Lukas Wirth
13890697eb Simplify 2024-04-06 13:12:07 +02:00
Lukas Wirth
86967032f7 Consider ADT generic parameter defaults for unsubstituted layout calculations 2024-04-03 09:01:27 +02:00
bors
c3b8c2a254 Auto merge of #16996 - Veykril:lt-err, r=Veykril
internal: Lower outlive goals, respect them in display impls
2024-04-02 14:13:22 +00:00
Lukas Wirth
707be6b99c Adjust display impls to respect lifetime bounds 2024-04-02 14:51:08 +02:00
Lukas Wirth
0927f86247 Replace static_lifetime usages with error_lifetime, lower outlives goals 2024-04-02 14:51:06 +02:00
bors
23dd54b010 Auto merge of #16968 - roife:fix-issue-16801, r=Veykril
fix: silence mismatches involving unresolved projections

fix #16801
2024-04-01 20:05:33 +00:00
roife
2636e44378 fix: simplify the usage of UnknownMismatch 2024-04-02 03:26:32 +08:00
roife
3d373fec8c tests: add tests for mismatches with unresolved projections 2024-04-02 01:32:43 +08:00
roife
8d6b65c544 fix: silence mismatches involving unresolved projections 2024-04-02 01:27:22 +08:00
bors
3691380c35 Auto merge of #16920 - Veykril:clippy-lints, r=Veykril
internal: Fix new nightly clippy lints
2024-04-01 16:00:18 +00:00
Lukas Wirth
2ae3e57c26 Fix new clippy lints 2024-04-01 17:55:56 +02:00
Nadrieril
7e8f2d8fd3 Use contiguous indices for enum variants 2024-04-01 12:27:16 +02:00
dfireBird
69c4ac6304
implement len and is_empty method in generic_params 2024-03-29 18:26:46 +05:30
dfireBird
20b12c2bac
fix lifetime length are not added in count of params in highlight 2024-03-27 23:21:17 +05:30
Laurențiu Nicola
85947bba49 Update comment on provenance_split 2024-03-26 10:58:35 +02:00
bors
0583aaa555 Auto merge of #16805 - dfireBird:lifetime_lowering, r=Veykril
feat: Implement resolving and lowering of Lifetimes (no inference yet)
2024-03-26 07:58:43 +00:00
dfireBird
0e54e2b55a
use references in Generics iter methods 2024-03-26 13:04:54 +05:30
Nadrieril
1716cc8433 Revert to the crates.io version of rustc_pattern_analysis 2024-03-25 13:09:37 +01:00
bors
6f6b03f9de Auto merge of #16935 - Nilstrieb:dont-panic, r=HKalbasi
Handle panicking like rustc CTFE does

Instead of using `core::fmt::format` to format panic messages, which may in turn panic too and cause recursive panics and other messy things, redirect `panic_fmt` to `const_panic_fmt` like CTFE, which in turn goes to `panic_display` and does the things normally. See the tests for the full call stack.

The tests don't work yet, I probably missed something in minicore.

fixes #16907 in my local testing, I also need to add a test for it
2024-03-24 18:17:36 +00:00
Nilstrieb
2dfe7de8b6 Handle panicking like rustc CTFE does
Instead of using `core::fmt::format` to format panic messages, which may in turn
panic too and cause recursive panics and other messy things, redirect
`panic_fmt` to `const_panic_fmt` like CTFE, which in turn goes to
`panic_display` and does the things normally. See the tests for the full
call stack.
2024-03-24 15:40:26 +01:00
6d7a
142ef764ee fix: Check stack depth to prevent stack overflows in create_memory_map 2024-03-24 10:19:25 +01:00
6d7a
7c1be82cd9 fix: Prevent stack overflow in recursive const types
In the evaluation of const values of recursive types
certain declarations could cause an endless call-loop
within the interpreter (hir-ty’s create_memory_map),
which would lead to a stack overflow.
This commit adds a check that prevents values that contain
an address in their value (such as TyKind::Ref) from being
allocated at the address they contain.
The commit also adds a test for this edge case.
2024-03-21 22:57:21 +01:00
Lukas Wirth
255a8aef92 Move Edition into span crate 2024-03-21 10:21:44 +01:00
bors
a2f73d3142 Auto merge of #16879 - Nadrieril:fuel, r=Veykril
Add fuel to match checking

Exhaustiveness checking is NP-hard hence can take extremely long to check some specific matches. This PR makes ehxaustiveness bail after a set number of steps. I chose a bound that takes ~100ms on my machine, which should be more than enough for normal matches.

I'd like someone with less recent hardware to run the test to see if that limit is low enough for them. Also curious if the r-a team thinks this is a good ballpark or if we should go lower/higher. I don't have much data on how complex real-life matches get, but we can definitely go lower than `500 000` steps.

The second commit is a drive-by soundness fix which doesn't matter much today but will matter once `min_exhaustive_patterns` is stabilized.

Fixes https://github.com/rust-lang/rust-analyzer/issues/9528 cc `@matklad`
2024-03-19 14:44:05 +00:00
Lukas Wirth
b38d5394bb internal: Move grammar codegen into xtask 2024-03-19 10:57:53 +01:00
dfireBird
b357bcab2b
modify insert_type_vars for lifetimes 2024-03-19 10:14:45 +05:30
Nadrieril
040f37a99d Avoid hanging on complex matches 2024-03-18 21:21:52 +01:00
Nadrieril
e67adf40c9 Don't assume place validity when we don't know 2024-03-18 21:21:52 +01:00
Nadrieril
3cfcd4ed96 Abstract over the uses of compute_match_usefulness 2024-03-18 21:21:52 +01:00
dfireBird
13301e7a1a
replace static_lifetime with new_lifetime_var where necessary
implemented suggested fixes and changes and fix merge conflicts
2024-03-18 17:53:09 +05:30
dfireBird
a555e95c9a
fix make HirDisplay format lifetimes first 2024-03-18 17:18:08 +05:30
dfireBird
8d08b337fa
include lifetime in the filter for data layout in analysis-stats
clippy fixes
2024-03-18 17:18:08 +05:30
dfireBird
490391f576
fix HirDisplay inserting anonymous lifetimes and update tests 2024-03-18 17:18:08 +05:30
dfireBird
0669ae7faf
handle lifetimes separately in substs function 2024-03-18 17:18:08 +05:30
dfireBird
a6c8cbfd91
update Generics iter methods to return GenericParamId 2024-03-18 17:18:08 +05:30
dfireBird
d6e3929841
include lifetime in ParamKind and in Generics::provenance_split 2024-03-18 17:18:08 +05:30
dfireBird
e463a3e1cf
update make_binders to include lifetimes in generics
adds a bunch of iter methods that include lifetimes
2024-03-18 17:18:08 +05:30
dfireBird
16493e301e
fix index returned for the use of BoundVar 2024-03-18 17:18:08 +05:30
dfireBird
f95b3d4cd2
implement resolving and lowering of Lifetimes 2024-03-18 17:18:06 +05:30
bors
d3eeadc242 Auto merge of #16852 - ShoyuVanilla:atpit, r=Veykril
feat: Implement ATPIT

Resolves #16584

Note: This implementation only works for ATPIT, not for TAIT.
The main hinderence that blocks the later is the defining sites of TAIT can be inner blocks like in;
```rust
type X = impl Default;

mod foo {
    fn bar() -> super::X {
        ()
    }
}
```
So, to figure out we are defining it or not, we should recursively probe for nested modules and bodies.

For ATPIT, we can just look into current body because `error[E0401]: can't use 'Self' from outer item` prevent such nested structures;

```rust
trait Foo {
    type Item;
    fn foo() -> Self::Item;
}

struct Bar;

impl Foo for Bar {
    type Item = impl Default;
    fn foo() -> Self::Item {
        fn bar() -> Self::Item {
                    ^^^^^^^^^^
                    |
                    use of `Self` from outer item
                    refer to the type directly here instead
            5
        }
        bar()
    }
}
```

But this implementation does not checks for unification of same ATPIT between different bodies, monomorphization, nor layout for similar reason. (But these can be done with lazyness if we can utilize something like "mutation of interned value" with `db`. I coundn't find such thing but I would appreciate it if such thing exists and you could let me know 😅)
2024-03-18 10:38:24 +00:00
Shoyu Vanilla
d034ab0f92 Apply reviewed suggestions 2024-03-18 18:25:41 +09:00
bors
a71a0328d8 Auto merge of #16830 - Jesse-Bakker:fix-ty-panic, r=ShoyuVanilla
Fix panic with impl trait associated types in where clause

Not sure if this is the correct fix, but the tests are green :')

Fixes #16823
2024-03-18 08:35:53 +00:00
bors
65c601fa42 Auto merge of #16863 - Nadrieril:update-pat-ana, r=Veykril
Bump dependencies and use in-tree `rustc_pattern_analysis`

One last `pattern_analysis` API change. I don't have any more planned! So we can now use the in-tree version when available.
2024-03-18 08:08:11 +00:00
Nadrieril
8d59aaf735 Use in-tree rustc_pattern_analysis 2024-03-17 14:16:30 +01:00
Nadrieril
b99618c191 Bump dependencies 2024-03-17 14:11:44 +01:00
Matthias Krüger
2a8edaa14d remove redundant clone()s 2024-03-17 14:06:21 +01:00
Shoyu Vanilla
fc53c59388 fix: typo 2024-03-16 03:53:55 +09:00
Shoyu Vanilla
d2aba91a0c feat: Implement ATPIT 2024-03-16 03:31:12 +09:00
Jesse Bakker
95828850b2 Fix panic with impl trait associated types in where clause 2024-03-13 18:02:15 +01:00
Lukas Wirth
9ba4493918 internal: Improve rooted upmapping 2024-03-12 13:46:58 +01:00
Lukas Wirth
fdc527f096 fix: Fix method resolution snapshotting receiver_ty too early 2024-03-11 15:35:06 +01:00
bors
8f8bcfc131 Auto merge of #16335 - lnicola:salsa-lz4-file-text, r=Veykril
internal: Compress file text using LZ4

I haven't tested properly, but this roughly looks like:

```
1246 MB
    59mb   4899 FileTextQuery

1008 MB
    20mb   4899 CompressedFileTextQuery
   555kb   1790 FileTextQuery
```

We might want to test on something more interesting, like `bevy`.
2024-03-11 13:43:33 +00:00
bors
2320e12541 Auto merge of #16771 - Veykril:self-param-split, r=Veykril
internal: Don't desugar self param into a pattern

Small experiment to see if this simplifies things
2024-03-11 12:45:46 +00:00
bors
a5035f4931 Auto merge of #16749 - Veykril:on-demand-validation-err, r=Veykril
internal: Some method resolution cleanups
2024-03-11 09:18:24 +00:00
bors
1069f57d8b Auto merge of #16784 - Veykril:body-invalid, r=Veykril
internal: Remove synstructure const hack support

The latest version of it no longer emits these
2024-03-11 09:05:26 +00:00
Lukas Wirth
c679482d7e Add method resolution deref inference var test 2024-03-11 10:02:03 +01:00
Lukas Wirth
458f4a2960 internal: Treat the self param as different from patterns when lowering 2024-03-11 09:46:28 +01:00
Lukas Wirth
558feeab61 internal: Remove synstructure const hack support 2024-03-11 09:44:40 +01:00
Laurențiu Nicola
aa74d57825 Merge commit '574e23ec508064613783cba3d1833a95fd9a5080' into sync-from-ra 2024-03-10 08:47:38 +02:00
Laurențiu Nicola
0f43b55e83 Stop using an Arc when setting the file text 2024-03-08 20:30:12 +02:00
Laurențiu Nicola
02b6c181dd Compress file text using lz4 in salsa 2024-03-08 20:22:08 +02:00
Laurențiu Nicola
cd2347e132 Skip match diagnostics for partially unknown types 2024-03-07 19:11:23 +02:00
bors
bbb441ec6d Auto merge of #16778 - Nadrieril:update-pat-ana, r=lnicola
Update `rustc_pattern_analysis` to 0.42.0

There was an important API change in 0.41.0, and (hopefully) a fix for https://github.com/rust-lang/rust-analyzer/issues/16774 in 0.42.0.
2024-03-07 16:22:26 +00:00
Nadrieril
e31484c108 Update the other crates too 2024-03-07 16:44:46 +01:00
Nadrieril
1b0b4220fd Update rustc_pattern_analysis to 0.42.0 2024-03-07 16:33:31 +01:00
bors
e101f24798 Auto merge of #16776 - Veykril:parse-macro-parse, r=Veykril
fix: Don't force draw a dependency edge to the real_span_map query

This can cause extra invalidations as like direct `AstIdMap` dependencies
2024-03-07 13:19:36 +00:00
Lukas Wirth
c04c0dd5ba fix: Don't force draw a dependency edge to the real_span_map query 2024-03-07 14:14:59 +01:00
bors
00f6a7aced Auto merge of #16772 - Veykril:salsa-tracing, r=Veykril
internal: Add tracing spans to macro generated database
2024-03-07 10:16:53 +00:00
Lukas Wirth
a3b6e891ea Add tracing spans to macro generated database 2024-03-06 20:19:36 +01:00
Shoyu Vanilla
a8f56112ea fix: Function argument type inference with associated type impl trait 2024-03-06 21:16:41 +09:00
roife
9cc3a9cfc2 fix: formatting 2024-03-05 19:55:31 +08:00
Lukas Wirth
d21f88883b Remove some unnecessary cloning in method_resolution 2024-03-05 12:39:27 +01:00