about summary refs log tree commit diff
path: root/crates/ide-diagnostics
AgeCommit message (Collapse)AuthorLines
2022-07-19Upgrade to expect-test@1.4.0Amos Wenger-1/+1
cf. https://github.com/rust-analyzer/expect-test/issues/33 cf. https://github.com/rust-lang/rust/pull/99444#issuecomment-1188844202
2022-07-18chore: change str_ref_to_string to str_ref_to_ownedMilo Mirate-7/+7
ToString is implemented by many different types than &str, and represents a serialization into string data. The fact that said data is returned as owned, is an implementation detail. If merely copying borrowed string data to owned string data is all that is desired, ToOwned is a much better choice, because if the user later refactors the code such that the input is no longer an `&str`, then they will get a compiler error instead of a mysterious change-in-behavior.
2022-07-16Auto merge of #12539 - soruh:instanciate_empty_structs, r=Veykrilbors-2/+115
Automatically instaciate trivially instaciable structs in "Generate new" and "Fill struct fields" As proposed in #12535 this PR changes the "Generate new" and "Fill struct fields" assist/diagnostic to instanciate structs with no fields and enums with a single empty variant. For example: ```rust pub enum Bar { Bar {}, } struct Foo<T> { a: usize, bar: Bar, _phantom: std::marker::PhantomData<T>, } impl<T> Foo<T> { /* generate new */ fn random() -> Self { Self { /* Fill struct fields */ } } } ``` was previously: ```rust impl<T> Foo<T> { fn new(a: usize, bar: Bar, _phantom: std::marker::PhantomData<T>) -> Self { Self { a, bar, _phantom } } fn random() -> Self { Self { a: todo!(), bar: todo!(), _phantom: todo!(), } } } ``` and is now: ```rust impl<T> Foo<T> { fn new(a: usize) -> Self { Self { a, bar: Bar::Bar {}, _phantom: std::marker::PhantomData } } fn random() -> Self { Self { a: todo!(), bar: Bar::Bar {}, _phantom: std::marker::PhantomData, } } } ``` I'd be happy about any suggestions. ## TODO - [x] deduplicate `use_trivial_constructor` (unclear how to do as it's used in two separate crates) - [x] write tests Closes #12535
2022-07-14Auto merge of #12691 - Veykril:proc-macro-diag, r=Veykrilbors-3/+11
fix: Fix unresolved proc macro diagnostics pointing to macro expansions Fixes https://github.com/rust-lang/rust-analyzer/issues/12657
2022-07-13add testssoruh-0/+86
2022-07-13Auto merge of #12696 - hi-rustin:rustin-patch-fix, r=Veykrilbors-0/+47
Add str_ref_to_string fix close https://github.com/rust-lang/rust-analyzer/issues/11383 When type mismatch is `&str` -> `String` try to fix it.
2022-07-09Fix testhi-rustin-1/+5
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-07-08Update remaining GitHub URLsJonas Schievink-1/+1
2022-07-05Add str_ref_to_string fixhi-rustin-0/+43
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-07-05fix: Fix unresolved proc macro diagnostics pointing to macro expansionsLukas Wirth-3/+11
2022-07-03Bump eitherLaurențiu Nicola-1/+1
2022-07-01Add tests for #12669Florian Diebold-0/+19
2022-06-30Auto merge of #12634 - iDawer:match-check.witnesses, r=flodieboldbors-49/+49
feat: Show witnesses of non-exhaustiveness in `missing-match-arm` diagnostic Shamelessly copied from rustc. Thus reporting format is same. This extends public api `hir::diagnostics::MissingMatchArms` with `uncovered_patterns: String` field. It does not expose data for implementing a quick fix yet. ----- Worth to note: current implementation does not give a comprehensive list of missing patterns. Also mentioned in [paper](http://moscova.inria.fr/~maranget/papers/warn/warn.pdf): > One may think that algorithm I should make an additional effort to provide more > non-matching values, by systematically computing recursive calls on specialized > matrices when possible, and by returning a list of all pattern vectors returned by > recursive calls. We can first observe that it is not possible in general to supply the > users with all non-matching values, since the signature of integers is (potentially) > infinite.
2022-06-30Auto merge of #12626 - CuriousCorrelation:fix/empty-reasons, r=flodieboldbors-1/+10
fix: trailing ':' on empty inactive reasons ## Description Fixes trailing ':' even when there is no explanation. e.g. ``` sh code is inactive due to #[cfg] directives: ``` ## Issue Fixes: #12615
2022-06-28fix: Report proc macro errors in expressions correctly as wellFlorian Diebold-3/+3
They didn't have a krate before, resulting in the generic "proc macro not found" error. Also improve error messages a bit more.
2022-06-24Improve proc macro errors a bitFlorian Diebold-33/+21
Distinguish between - there is no build data (for some reason?) - there is build data, but the cargo package didn't build a proc macro dylib - there is a proc macro dylib, but it didn't contain the proc macro we expected - the name did not resolve to any macro (this is now an unresolved_macro_call even for attributes) I changed the handling of disabled attribute macro expansion to immediately ignore the macro and report an unresolved_proc_macro, because otherwise they would now result in loud unresolved_macro_call errors. I hope this doesn't break anything. Also try to improve error ranges for unresolved_macro_call / macro_error by reusing the code for unresolved_proc_macro. It's not perfect but probably better than before.
2022-06-23fix: trailing ':' on empty inactive reasonsCuriousCorrelation-1/+10
Fixes: #12615
2022-06-22apply suggestionssoruh-49/+4
2022-06-20Display witnesses of non-exhaustive matchiDawer-49/+49
Reporting format follows rustc and shows at most three witnesses.
2022-06-15Use the correct crates proc-macro loading error messageLukas Wirth-1/+4
2022-06-15Show proc-macro loading errors in unresolved-proc-macro diagnosticsLukas Wirth-11/+15
2022-06-15replace TODO with FIXMEsoruh-1/+1
2022-06-15fix CIsoruh-1/+1
2022-06-15cleanupsoruh-9/+2
2022-06-15instanciate_empty_structssoruh-2/+81
2022-06-14fix: Check for the correct proc-macro settings in missing proc-macro diagnosticsLukas Wirth-9/+25
2022-06-12More precise proc-macro errorsLukas Wirth-4/+10
2022-06-10internal: Bump DependenciesLukas Wirth-1/+1
2022-05-10Auto merge of #12010 - Veykril:r-a-config, r=Veykrilbors-2/+2
Config revamp Fixes https://github.com/rust-lang/rust-analyzer/issues/11790 Fixes https://github.com/rust-lang/rust-analyzer/issues/12115 This PR changes a lot of config names, and a few ones are being merged or split apart. The reason for this is that our configuration names currently are rather inconsistent and some where poorly chosen in regards to extensability. This PR plans to fix that. We still allow the old config names by patching them to the new ones before deserializing to keep backwards compatability with other clients (the VSCode client will auto update the config) but ideally we will get rid of that layer in the future. Here is a list of the changes: These are simple renames `old_name | alias1 | alias2 ... -> new_name` (the vscode client will fix these up automagically): ``` assist_allowMergingIntoGlobImports -> imports_merge_glob assist_exprFillDefault -> assist_expressionFillDefault assist_importEnforceGranularity -> imports_granularity_enforce assist_importGranularity | assist_importMergeBehavior | assist_importMergeBehaviour -> imports_granularity_group assist_importGroup -> imports_group_enable assist_importPrefix -> imports_prefix cache_warmup -> primeCaches_enable cargo_loadOutDirsFromCheck -> cargo_buildScripts_enable cargo_runBuildScripts | cargo_runBuildScriptsCommand -> cargo_runBuildScripts_overrideCommand cargo_useRustcWrapperForBuildScripts -> cargo_runBuildScripts_useRustcWrapper completion_snippets -> completion_snippets_custom diagnostics_enableExperimental -> diagnostics_experimental_enable experimental_procAttrMacros -> procMacro_attributes_enable highlighting_strings -> semanticHighlighting_strings_enable highlightRelated_breakPoints -> semanticHighlighting_breakPoints_enable highlightRelated_exitPoints -> semanticHighlighting_exitPoints_enable highlightRelated_yieldPoints -> semanticHighlighting_yieldPoints_enable highlightRelated_references -> semanticHighlighting_references_enable hover_documentation -> hover_documentation_enable hover_linksInHover | hoverActions_linksInHover -> hover_links_enable hoverActions_debug -> hoverActions_debug_enable hoverActions_enable -> hoverActions_enable_enable hoverActions_gotoTypeDef -> hoverActions_gotoTypeDef_enable hoverActions_implementations -> hoverActions_implementations_enable hoverActions_references -> hoverActions_references_enable hoverActions_run -> hoverActions_run_enable inlayHints_chainingHints -> inlayHints_chainingHints_enable inlayHints_closureReturnTypeHints -> inlayHints_closureReturnTypeHints_enable inlayHints_hideNamedConstructorHints -> inlayHints_typeHints_hideNamedConstructorHints inlayHints_parameterHints -> inlayHints_parameterHints_enable inlayHints_reborrowHints -> inlayHints_reborrowHints_enable inlayHints_typeHints -> inlayHints_typeHints_enable lruCapacity -> lru_capacity runnables_cargoExtraArgs -> runnables_extraArgs runnables_overrideCargo -> runnables_command rustcSource -> rustc_source rustfmt_enableRangeFormatting -> rustfmt_rangeFormatting_enable ``` These are configs that have been merged or split apart, which have to be manually updated by the user: ``` callInfo_full -> signatureInfo_detail, signatureInfo_documentation_enable cargo_allFeatures, cargo_features -> cargo_features checkOnSave_allFeatures, checkOnSave_features -> checkOnSave_features completion_addCallArgumentSnippets completion_addCallParenthesis -> completion_callable_snippets ```
2022-05-04improve the default constructor mode when filling fieldsBenjamin Coenen-5/+12
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-05-01Fix up config docsLukas Wirth-2/+2
2022-05-01update crates names in slow-tests/tidy.rsPeh-0/+0
2022-05-01update diagnostic-docs crate namePeh-1/+1
2022-05-01style: rename crates to kebab casePeh-0/+5582