summary refs log tree commit diff
path: root/src/test/ui/resolve
AgeCommit message (Collapse)AuthorLines
2020-10-02Fix span for incorrect pattern field and add labelEsteban Küber-2/+4
2020-09-09Rollup merge of #75984 - kornelski:typeormodule, r=matthewjasperTyler Mandry-3/+3
Improve unresolved use error message "use of undeclared type or module `foo`" doesn't mention that it could be a crate. This error can happen when users forget to add a dependency to `Cargo.toml`, so I think it's important to mention that it could be a missing crate. I've used a heuristic based on Rust's naming conventions. It complains about an unknown type if the ident starts with an upper-case letter, and crate or module otherwise. It seems to work very well. The expanded error help covers both an unknown type and a missing crate case.
2020-09-02pretty: trim paths of unique symbolsDan Aloni-16/+16
If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
2020-09-01Clarify message about unresolved useKornel-3/+3
2020-08-13Suggest adding `&self` when accessing `self` in static assoc `fn`Esteban Küber-14/+13
2020-08-10Add missing primary labelEsteban Küber-1/+1
2020-08-10Point at item definition in foreign cratesEsteban Küber-0/+5
2020-08-10Do not suggest similarly named enclosing itemEsteban Küber-7/+0
2020-08-10Tweak ordering of suggestionsEsteban Küber-20/+20
Modify logic to make it easier to follow and recover labels that would otherwise be lost.
2020-07-27mv std libs to library/mark-1/+1
2020-07-14Rollup merge of #74228 - estebank:unsized-param, r=davidtwcoManish Goregaokar-2/+4
Provide structured suggestion on unsized fields and fn params * Suggest borrowing or boxing unsized fields * Suggest borrowing fn parameters * Remove some verbosity of unsized errors * Remove `on_unimplemented` note from `trait Sized` Fix #23286, fix #28653. r? @davidtwco
2020-07-14Suggest borrowing in more unsized fn param casesEsteban Küber-1/+4
2020-07-14Remove `Sized` `on_unimplemented` noteEsteban Küber-1/+0
2020-07-14Suggest struct pat on incorrect unit or tuple patEsteban Küber-12/+18
When encountering a unit or tuple pattern for a struct-like item, suggest using the correct pattern. Use `insert_field_names_local` when evaluating variants and store field names even when the list is empty in order to produce accurate structured suggestions.
2020-07-06Rollup merge of #73953 - JohnTitor:audit-hidden-sugg, r=estebankManish Goregaokar-1/+49
Audit hidden/short code suggestions Should fix #73641. Audit uses of `span_suggestion_short` and `tool_only_span_suggestion` (`span_suggestion_hidden` is already tested with `run-rustfix`). Leave some FIXMEs for futher improvements/fixes. r? @estebank
2020-07-02resolve: disallow label use through closure/asyncDavid Wood-4/+9
This commit modifies resolve to disallow `break`/`continue` to labels through closures or async blocks. This doesn't make sense and should have been prohibited anyway. Signed-off-by: David Wood <david@davidtw.co>
2020-07-02Audit uses of `tool_only_span_suggestion`Yuki Okushi-1/+13
2020-07-02Audit uses of `span_suggestion_short`Yuki Okushi-0/+36
2020-06-23Add re-exports to use suggestionsDan Aloni-5/+7
In the following example, an inaccessible path is suggested via `use foo::bar::X;` whereas an accessible public exported path can be suggested instead. ``` mod foo { mod bar { pub struct X; } pub use self::bar::X; } fn main() { X; } ``` This fixes the issue.
2020-06-21Prefer accessible paths in 'use' suggestionsDan Aloni-4/+1
This fixes an issue with the following sample: mod foo { mod inaccessible { pub struct X; } pub mod avail { pub struct X; } } fn main() { X; } Instead of suggesting both `use crate::foo::inaccessible::X;` and `use crate::foo::avail::X;`, it should only suggest the latter. It is done by trimming the list of suggestions from inaccessible paths if accessible paths are present. Visibility is checked with `is_accessible_from` now instead of being hard-coded. - Some tests fixes are trivial, and others require a bit more explaining, here are my comments: src/test/ui/issues/issue-35675.stderr: Only needs to make the enum public to have the suggestion make sense. src/test/ui/issues/issue-42944.stderr: Importing the tuple struct won't help because its constructor is not visible, so the attempted constructor does not work. In that case, it's better not to suggest it. The case where the constructor is public is covered in `issue-26545.rs`.
2020-06-09Remove noisy suggestion of hash_map #72642Ayush Kumar Mishra-9/+3
Fixed failing test-cases Remove noisy suggestion of hash_map #72642 Fixed failing test-cases
2020-06-07Free `default()` forwarding to `Default::default()`Ilya Bobyr-1/+10
When creating default values a trait method needs to be called with an explicit trait name. `Default::default()` seems redundant. A free function on the other hand, when imported directly, seems to be a better API, as it is just `default()`. When implementing the trait, a method is still required.
2020-06-02Improve E0433, so that it suggests missing importsPatryk Wychowaniec-0/+49
2020-05-31Add descriptions for all queriesMatthew Jasper-12/+12
2020-05-09adjust testsRalf Jung-2/+3
2020-05-07reword "possible candidate" import suggestionAndy Russell-23/+23
2020-05-05Ignore SGX on a few ui testsMohsen Zohrevandi-1/+3
2020-04-26Tweak some suggestions in `rustc_resolve`Esteban Küber-3/+15
2020-04-16ty: convert `ErrorHandled::Reported` to `ConstKind::Error`.Eduard-Mihai Burtescu-14/+3
2020-04-11rustc: Add a warning count upon completionRoccoDev-1/+1
2020-04-03def_collector, visit_fn: account for no bodyMazdak Farrokhzad-0/+85
2020-04-02tests: remove ignore directives from tests that mention core/alloc/std spans.Eduard-Mihai Burtescu-12/+8
2020-03-24Rollup merge of #70077 - Aaron1011:feature/new-def-path-ident, r=petrochenkovMazdak Farrokhzad-1/+4
Store idents for `DefPathData` into crate metadata Previously, we threw away the `Span` associated with a definition's identifier when we encoded crate metadata, causing us to lose location and hygiene information. We now store the identifier's `Span` in a side table, which gets encoded into the crate metadata. When we decode items from the metadata, we combine the name and span back into an `Ident`. This improves the output of several tests, which previously had messages suppressed due to dummy spans. This is a prerequisite for #68686, since throwing away a `Span` means that we lose hygiene information.
2020-03-24Rollup merge of #69981 - oli-obk:const_blocks, r=eddybMazdak Farrokhzad-2/+13
Evaluate repeat expression lengths as late as possible Fixes #68567 r? @varkor
2020-03-23Evaluate repeat expression lengths as late as possibleOliver Scherer-2/+13
2020-03-23Rollup merge of #69942 - estebank:sized-verbose-sugg, r=matthewjasperMazdak Farrokhzad-23/+34
Increase verbosity when suggesting subtle code changes Do not suggest changes that are actually quite small inline, to minimize the likelihood of confusion. Fix #69243.
2020-03-22Store idents for `DefPathData` into crate metadataAaron Hill-1/+4
Previously, we threw away the `Span` associated with a definition's identifier when we encoded crate metadata, causing us to lose location and hygiene information. We now store the identifier's `Span` in the crate metadata. When we decode items from the metadata, we combine the name and span back into an `Ident`. This improves the output of several tests, which previously had messages suppressed due to dummy spans. This is a prerequisite for #68686, since throwing away a `Span` means that we lose hygiene information.
2020-03-22Normalize wording of privacy access labelsEsteban Küber-11/+16
2020-03-22Increase verbosity when suggesting subtle code changesEsteban Küber-12/+18
2020-03-21Bless testsLeSeulArtichaut-62/+28
2020-03-14resolve: Fix regression in resolution of raw keywords in pathsVadim Petrochenkov-0/+14
2020-03-04resolve, inconsistent binding mode: tweak wording.Mazdak Farrokhzad-49/+50
2020-02-28Rollup merge of #69539 - Centril:fix-69401, r=petrochenkovMazdak Farrokhzad-0/+15
late resolve, visit_fn: bail early if there's no body. Fixes https://github.com/rust-lang/rust/issues/69401 which was injected by https://github.com/rust-lang/rust/commit/b2c6eeb713d4cf9b35b7dda6ff2b0274e7f24684 in https://github.com/rust-lang/rust/pull/68788. r? @petrochenkov
2020-02-28Rollup merge of #69452 - Centril:typeck-pat, r=estebankMazdak Farrokhzad-5/+22
typeck: use `Pattern` obligation cause more for better diagnostics r? @estebank
2020-02-28late resolve, visit_fn: bail early if there's no body.Mazdak Farrokhzad-0/+15
2020-02-26Rollup merge of #67637 - Mark-Simulacrum:primitive-mod, r=dtolnayDylan DPC-0/+5
Add primitive module to libcore This re-exports the primitive types from libcore at `core::primitive` to allow macro authors to have a reliable location to use them from. Fixes #44865
2020-02-25check_pat_path: use pattern_causeMazdak Farrokhzad-1/+3
2020-02-25improve or-pattern type consistency diagnosticsMazdak Farrokhzad-4/+19
2020-02-11On mismatched argument count point at argumentsEsteban Küber-3/+5
2020-02-06Add primitive module to libcore/stdMark Rousskov-0/+5
This re-exports the primitive types from libcore at `core::primitive` to allow macro authors to have a reliable location to use them from.