summary refs log tree commit diff
path: root/src/tools/rust-analyzer/crates/ide-diagnostics
AgeCommit message (Collapse)AuthorLines
2025-02-07fix: Resolve projection types before checking castsShoyu Vanilla-0/+35
2025-02-03Do not use make use of `InferenceResult::has_errors` flag for mir buildingLukas Wirth-1/+4
It generaly does not work as expected right now as we fallback type parameters to errors
2025-01-28Merge pull request #19063 from ↵David Barsky-46/+0
davidbarsky/davidbarsky/backout-struct-default-fields internal: backout `hir-*` changes from #19001
2025-01-28Merge pull request #19015 from Wilfred/mdbookLukas Wirth-1/+1
manual: Convert to mdbook
2025-01-27Back out "feat: Implement `default-field-values`"David Barsky-15/+0
This backs out commit 7de0b2e75a541b98f735ee6fcd12d326be38d23f.
2025-01-27Back out "Handle missing fields diagnostics"David Barsky-31/+0
This backs out commit e6a103ae50699db1dbb0676d075a4bcda2247939.
2025-01-27Merge pull request #19051 from ChayimFriedman2/fn-ptr-unsafeLukas Wirth-0/+12
fix: Report calling unsafe fn pointer as unsafe
2025-01-27Merge pull request #19049 from ChayimFriedman2/add-reference-tyLukas Wirth-2/+2
minor: Remove duplicate method from `hir::Type`
2025-01-27Report calling unsafe fn pointer as unsafeChayim Refael Friedman-0/+12
2025-01-27Remove duplicate method from `hir::Type`Chayim Refael Friedman-2/+2
I added it by mistake in #18927. I chose to keep the method as not static, because it's more comfortable, and keep the name `add_reference()` and not `reference()`, because it is clearer and better matches `strip_reference[s]()`.
2025-01-27Fix #[rustc_deprecated_safe_2024]Chayim Refael Friedman-11/+45
It should be considered by the edition of the caller, not the callee. Technically we still don't do it correctly - we need the span of the method name (if it comes from a macro), but we don't keep it and this is good enough for now.
2025-01-27Handle missing fields diagnosticsShoyu Vanilla-0/+31
2025-01-27feat: Implement `default-field-values`Shoyu Vanilla-0/+15
2025-01-26Support RFC 2396Chayim Refael Friedman-0/+20
AKA. target_feature 1.1, or non unsafe target_feature.
2025-01-25Fix flyimport not filtering via stability of import pathLukas Wirth-2/+10
2025-01-24manual: Convert to mdbookWilfred Hughes-1/+1
Split manual.adoc into markdown files, one for each chapter. For the parts of the manual that are generated from source code doc comments, update the comments to use markdown syntax and update the code generators to write to `generated.md` files. For the weekly release, stop copying the .adoc files to the `rust-analyzer/rust-analyzer.github.io` at release time. Instead, we'll sync the manual hourly from this repository. See https://github.com/rust-analyzer/rust-analyzer.github.io/pull/226 for the sync. This PR should be merged first, and that PR needs to be merged before the next weekly release. This change is based on #15795, but rebased and updated. I've also manually checked each page for markdown syntax issues and fixed any I encountered. Co-authored-by: Lukas Wirth <lukastw97@gmail.com> Co-authored-by: Josh Rotenberg <joshrotenberg@gmail.com>
2025-01-21Cleanup `Name` string renderingLukas Wirth-2/+2
2025-01-19Fix a bug where enum variants were not considered properly in type ns resolutionChayim Refael Friedman-0/+19
They should be considered just as well as in value ns, for example for struct literals.
2025-01-16Add missing `#[rust_analyzer::rust_fixture]` annotationsLukas Wirth-10/+29
2025-01-16update chalkWaffle Lapkin-1/+0
this brings in support from trait upcasting, yay! (and as such fixes a test)
2025-01-16add a test for trait upcasting type mismatchWaffle Lapkin-0/+32
this adds a test asserting *incorrect* behavior that can be seen in <https://github.com/rust-lang/rust-analyzer/issues/18083>, and a test asserting the *correct* behavior for the case of no super traits.
2025-01-13Fix another bug when reaching macro expansion limit caused a stack overflowChayim Refael Friedman-0/+26
This time without missing bindings. Solve it by returning to the old ways, i.e. just throw the extra nodes away. In other words, I acknowledge defeat.
2025-01-10Re-implement rust string highlighting via tool attributeLukas Wirth-7/+13
2025-01-09Merge pull request #18861 from ChayimFriedman2/await-editionLukas Wirth-0/+34
fix: Make edition per-token, not per-file
2025-01-09minor: Fixup macro error kindsLukas Wirth-3/+3
2025-01-09Make edition per-token, not per-fileChayim Refael Friedman-0/+34
More correctly, *also* per-token. Because as it turns out, while the top-level edition affects parsing (I think), the per-token edition affects escaping of identifiers/keywords.
2025-01-07Fix a bug with missing binding in MBEChayim Refael Friedman-0/+2728
We should immediately mark them as finished, on the first entry. The funny (or sad) part was that this bug was pre-existing, but previously to #18327, it was causing us to generate bindings non-stop, 65535 of them, until we get to the hardcoded repetition limit, and then throw it all away. And it was so Blazingly Fast that nobody noticed. With #18327 however, this is still what happens, except that now instead of *merging* the fragments into the result, we write them on-demand. Meaning that when we hit the limit, we've already written all previous entries. This is a minor change, I thought for myself when I was writing this, and it's actually for the better, so who cares. Minor change? Not so fast. This caused us to emit 65535 repetitions, all of which the MBE infra needs to handle when calling other macros with the expansion, and convert to rowan tree etc., which resulted a *massive* hang. The test (and also `analysis-stats`) used to crash with stack overflow on this macro, because we were dropping some crazily deep rowan tree. Now they work properly. Because I am lazy, and also because I could not find the exact conditions that causes a macro match but with a missing binding, I just copied all macros from tracing. Easy.
2025-01-06fix: Handle newstyle `rustc_intrinsic` safety correctlyLukas Wirth-0/+18
2024-12-28Consider `Enum::Variant` even when it comes from a different crateChayim Refael Friedman-0/+25
2024-12-24Unify handling of path diagnostics in hir-tyChayim Refael Friedman-0/+140
Because it was a mess. Previously, pretty much you had to handle all path diagnostics manually: remember to check for them and handle them. Now, we wrap the resolver in `TyLoweringContext` and ensure proper error reporting. This means that you don't have to worry about them: most of the things are handled automatically, and things that cannot will create a compile-time error (forcing you top `drop(ty_lowering_context);`) if forgotten, instead of silently dropping the diagnostics. The real place for error reporting is in the hir-def resolver, because there are other things resolving, both in hir-ty and in hir-def, and they all need to ensure proper diagnostics. But this is a good start, and future compatible. This commit also ensures proper path diagnostics for value/pattern paths, which is why it's marked "feat".
2024-12-18Taking a raw ref of a deref is always safeLukas Wirth-0/+16
2024-12-16Merge pull request #18700 from ChayimFriedman2/dyn-sendLukas Wirth-1/+18
fix: Fix a panic with a diagnostics fix when a keyword is used as a field
2024-12-16Fix a panic with a diagnostics fix when a keyword is used as a fieldChayim Refael Friedman-1/+18
I found it easiest to fix in the quickfix code, and not deeper (e.g. body lowering).
2024-12-16Report unresolved idents for implicit captures in `format_args!()`Chayim Refael Friedman-8/+8
And also a bit of cleanup by storing the capture's span with the open quote included.
2024-12-12Fix typo in error message for invalid castingPhilipp Hofer-1/+1
Corrected the spelling of "defererence" to "dereference" in the error message that informs users about invalid casting requirements.
2024-12-11Properly handle different defaults for severity of lintsChayim Refael Friedman-45/+103
Previously all lints were assumed to be `#[warn]`, and we had a hand-coded list of `#[allow]` exceptions. Now the severity is autogenerated from rustdoc output. Also support lints that change status between editions, and the `warnings` lint group.
2024-12-09minor: Migrate `remove_unnecessary_wrapper` to `SyntaxEditor`Giga Bowser-20/+43
2024-12-09Add diagnostic fix to remove unnecessary wrapper in type mismatchGiga Bowser-62/+375
I also reorganized the tests in a more logical order, and removed the redundant `test_` prefix from their names.
2024-12-09fix: Non-exhaustive structs may be emptyLukas Wirth-0/+19
2024-12-06Merge pull request #18594 from ChayimFriedman2/async-closuresLukas Wirth-0/+21
feat: Support `AsyncFnX` traits
2024-12-04Merge pull request #18611 from ChayimFriedman2/proc-macro-warnLukas Wirth-0/+6
fix: Do not report warnings from proc macros, ever
2024-12-04Do not report warnings from proc macros, everChayim Refael Friedman-0/+6
2024-12-04Complete diagnostics in ty lowering groundworkChayim Refael Friedman-0/+200
Implement diagnostics in all places left: generics (predicates, defaults, const params' types), fields, and type aliases. Unfortunately this results in a 20mb addition in `analysis-stats .` due to many type methods returning an addition diagnostics result now (even if it's `None` in most cases). I'm not sure if this can be improved. An alternative strategy that can prevent the memory usage growth is to never produce diagnostics in hir-ty methods. Instead, lower all types in the hir crate when computing diagnostics from scratch (with diagnostics this time). But this has two serious disadvantages: 1. This can cause code duplication (although it can probably be not that bad, it will still mean a lot more code). 2. I believe we eventually want to compute diagnostics for the *entire* workspace (either on-type or on-save or something alike), so users can know when they have diagnostics even in inactive files. Choosing this approach will mean we lose all precomputed salsa queries. For one file this is fine, for the whole workspace this will be very slow.
2024-12-04Lay the foundation for diagnostics in ty lowering, and implement a first ↵Chayim Refael Friedman-3/+247
diagnostic The diagnostic implemented is a simple one (E0109). It serves as a test for the new foundation. This commit only implements diagnostics for type in bodies and body-carrying signatures; the next commit will include diagnostics in the rest of the things. Also fix one weird bug that was detected when implementing this that caused `Fn::(A, B) -> C` (which is a valid, if bizarre, alternative syntax to `Fn(A, B) -> C` to lower incorrectly. And also fix a maybe-bug where parentheses were sneaked into a code string needlessly; this was not detected until now because the parentheses were removed (by the make-AST family API), but with a change in this commit they are now inserted. So fix that too.
2024-12-04Extend reported unsafe operationsChayim Refael Friedman-20/+134
We add union fields access (in both expressions and patterns) and inline assembly. That completes the unsafe check (there are some other unsafe things but they are unstable), and so also opens the door to reporting unused unsafe without annoying people about their not-unused unsafe blocks.
2024-12-03Support `AsyncFnX` traitsChayim Refael Friedman-0/+21
Only in calls, because to support them in bounds we need support from Chalk. However we don't yet report error from bounds anyway, so this is less severe. The returned future is shown in its name within inlay hints instead of as a nicer `impl Future`, but that can wait for another PR.
2024-10-31Move child_by_source from hir-def to hirLukas Wirth-1/+1
2024-10-28Merge pull request #18420 from ChayimFriedman2/cfg-true-falseLukas Wirth-0/+16
feat: Support `cfg(true)` and `cfg(false)`
2024-10-28Merge pull request #18421 from Veykril/push-uxxwvwnqvomrLukas Wirth-21/+19
Move text-edit into ide-db
2024-10-28ReformatLukas Wirth-14/+14