about summary refs log tree commit diff
path: root/src/test/ui/hygiene
AgeCommit message (Collapse)AuthorLines
2020-09-02pretty: trim paths of unique symbolsDan Aloni-8/+8
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-7/+7
2020-08-16hir: introduce `QPath::LangItem`David Wood-73/+1
This commit introduces `QPath::LangItem` to the HIR and uses it in AST lowering instead of constructing a `hir::Path` from a slice of symbols. This might be better for performance, but is also much cleaner as the previous approach is fragile. In addition, it resolves a bug (#61019) where an extern crate imported as "std" would result in the paths created during AST lowering being resolved incorrectly (or not at all). Co-authored-by: Matthew Jasper <mjjasper1@gmail.com> Signed-off-by: David Wood <david@davidtw.co>
2020-08-16tests: add test for #61019's current behaviourDavid Wood-0/+90
This commit adds a test for #61019 where a extern crate is imported as `std` which results in name resolution to fail due to the uses of `std` types introduced from lowering. Signed-off-by: David Wood <david@davidtw.co>
2020-08-10Add missing primary labelEsteban Küber-2/+2
2020-07-27mv std libs to library/mark-1/+1
2020-07-26Add test for use of $crate in nested foreign macro_rules!Aaron Hill-0/+23
2020-07-26Hygiene serialization implementationAaron Hill-0/+25
2020-07-15Add and use more static symbols.Nicholas Nethercote-1/+4
Note that the output of `unpretty-debug.stdout` has changed. In that test the hash values are normalized from a symbol numbers to small numbers like "0#0" and "0#1". The increase in the number of static symbols must have caused the original numbers to contain more digits, resulting in different pretty-printing prior to normalization.
2020-06-29Serialize all foreign `SourceFile`s into proc-macro crate metadataAaron Hill-2/+2
Normally, we encode a `Span` that references a foreign `SourceFile` by encoding information about the foreign crate. When we decode this `Span`, we lookup the foreign crate in order to decode the `SourceFile`. However, this approach does not work for proc-macro crates. When we load a proc-macro crate, we do not deserialzie any of its dependencies (since a proc-macro crate can only export proc-macros). This means that we cannot serialize a reference to an upstream crate, since the associated metadata will not be available when we try to deserialize it. This commit modifies foreign span handling so that we treat all foreign `SourceFile`s as local `SourceFile`s when serializing a proc-macro. All `SourceFile`s will be stored into the metadata of a proc-macro crate, allowing us to cotinue to deserialize a proc-macro crate without needing to load any of its dependencies. Since the number of foreign `SourceFile`s that we load during a compilation session may be very large, we only serialize a `SourceFile` if we have also serialized a `Span` which requires it.
2020-06-22Revert "Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, ↵Aaron Hill-4/+0
r=nikomatsakis" This reverts commit 372cb9b69c76a042d0b9d4b48ff6084f64c84a2c, reversing changes made to 5c61a8dc34c3e2fc6d7f02cb288c350f0233f944.
2020-06-21Prefer accessible paths in 'use' suggestionsDan Aloni-5/+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-11Explain move errors that occur due to method calls involving `self`Aaron Hill-0/+4
2020-06-09Remove noisy suggestion of hash_map #72642Ayush Kumar Mishra-3/+1
Fixed failing test-cases Remove noisy suggestion of hash_map #72642 Fixed failing test-cases
2020-06-02Improve E0433, so that it suggests missing importsPatryk Wychowaniec-1/+7
2020-05-17Emit a better diagnostic when function actually has a 'self' parameterAaron Hill-0/+40
Fixes #66898 When we are unable to resolve a reference to `self`, we current assume that the containing function doesn't have a `self` parameter, and emit an error message accordingly. However, if the reference to `self` was created by a macro invocation, then resolution will correctly fail, due to hygiene. In this case, we don't want to tell the user that the containing fuction doesn't have a 'self' paramter if it actually has one. This PR checks for the precense of a 'self' parameter, and adjusts the error message we emit accordingly. TODO: The exact error message we emit could probably be improved. Should we explicitly mention hygiene?
2020-05-09adjust testsRalf Jung-2/+4
2020-05-07reword "possible candidate" import suggestionAndy Russell-4/+4
2020-04-11rustc: Add a warning count upon completionRoccoDev-0/+8
2020-03-22Normalize wording of privacy access labelsEsteban Küber-9/+19
2020-03-22Add span label to primary error spanEsteban Küber-2/+2
2020-03-16Make macro metavars respect (non-)hygieneMatthew Jasper-0/+53
2020-02-24parser: `token` -> `normalized_token`, `nonnormalized_token` -> `token`Vadim Petrochenkov-2/+2
2020-02-10use `dyn Trait` more in testsMazdak Farrokhzad-2/+2
2020-02-06rustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros.Eduard-Mihai Burtescu-2/+111
2020-02-06rustc: rename -Zexternal-macro-backtrace to -Zmacro-backtrace.Eduard-Mihai Burtescu-2/+2
2020-01-26Suggest defining type parameter when appropriateEsteban Küber-8/+7
``` error[E0412]: cannot find type `T` in this scope --> file.rs:3:12 | 3 | impl Trait<T> for Struct {} | - ^ not found in this scope | | | help: you might be missing a type parameter: `<T>` ``` Fix #64298.
2020-01-16resolve: Point at the private item definitions in privacy errorsVadim Petrochenkov-1/+7
2020-01-08Unify output of "variant not found" errorsEsteban Küber-3/+3
2019-11-15Cleaned up unused labelsBart Massey-56/+58
Deleted unused labels from compiler and fixed or allowed unused labels in tests. This patch removes some gratuitous unused labels and turns off the warning for unused labels that are a necessary part of tests. This will permit setting the `unused_labels` lint to `warn`.
2019-11-10Make error and warning annotations mandatory in UI testsTomasz Miąsko-63/+116
This change makes error and warning annotations mandatory in UI tests. The only exception are tests that use error patterns to match compiler output and don't have any annotations.
2019-10-24Increase spacing for suggestions in diagnosticsEsteban Küber-0/+3
Make the spacing between the code snippet and verbose structured suggestions consistent with note and help messages.
2019-10-18Change how `Symbol::Debug` works.Nicholas Nethercote-1/+1
Currently, `Symbol::Debug` and `Symbol::Display` produce the same output; neither wraps the symbol in double quotes. This commit changes `Symbol::Debug` so it wraps the symbol in quotes. This change brings `Symbol`'s behaviour in line with `String` and `InternedString`. The change requires a couple of trivial test output adjustments.
2019-10-14Use heuristics for capitalization warning in suggestionsEsteban Küber-1/+1
2019-10-13Bring attention to suggestions when the only difference is capitalizationEsteban Küber-3/+3
2019-09-30Fixed grammar in one diagnostic and blessed tests.Alexander Regueiro-2/+2
2019-09-17Rollup merge of #64486 - matthewjasper:hygiene-debugging, r=petrochenkovTyler Mandry-0/+10
Print out more information for `-Zunpretty=expanded,hygiene` I've found this helpful when trying to understand how hygiene works. Closes #16420
2019-09-17Print syntax contexts and marks when printing hygiene informationMatthew Jasper-0/+10
2019-09-15resolve: Remove `!` from "cannot find" diagnostics for macrosVadim Petrochenkov-4/+4
2019-09-08Give method not found a primary span labelEsteban Küber-2/+2
2019-09-05Make use of hygiene in AST passesMatthew Jasper-0/+30
2019-08-21Add a regression test for issue #63460Vadim Petrochenkov-0/+22
2019-08-21expand: Do not do questionable span adjustment before eagerly expanding an ↵Vadim Petrochenkov-12/+3
expression Maybe it made sense when it was introduced, but now it's doing something incorrect.
2019-08-21expand: Keep the correct current expansion ID for eager expansionsVadim Petrochenkov-0/+3
Solve the problem of `ParentScope` entries for eager expansions not exising in the resolver map by creating them on demand.
2019-08-21Add a test for an opaque macro eagerly expanding its argumentsVadim Petrochenkov-0/+26
2019-08-17Stop emulating cross-crate hygiene with gensymsMatthew Jasper-0/+22
Most `Ident`s are serialized as `InternedString`s the exceptions are: * Reexports * Attributes * Idents in macro definitions Using gensyms helped reexports emulate hygiene. However, the actual item wouldn't have a gensymmed name so would be usable cross-crate. So removing this case until we have proper cross-crate hygiene seems sensible. Codegen attributes (`inline`, `export_name`) are resolved by their `Symbol`. This meant that opaque macro-expanded codegen attributes could cause linker errors. This prevented making built-in derives hygienic.
2019-08-15resolve: Move macro resolution traces from `Module`s to `Resolver`Vadim Petrochenkov-8/+8
Traces already contain module info without that. It's easy to forget to call `finalize_*` on a module. In particular, macros enum and trait modules weren't finalized. By happy accident macros weren't placed into those modules until now.
2019-08-10resolve: Move late resolution into a separate visitorVadim Petrochenkov-0/+38
Move `Resolver` fields specific to late resolution to the new visitor. The `current_module` field from `Resolver` is replaced with two `current_module`s in `LateResolutionVisitor` and `BuildReducedGraphVisitor`. Outside of those visitors `current_module` is replaced by passing `parent_scope` to more functions and using the parent module from it. Visibility resolution no longer have access to later resolution methods and has to use early resolution, so its diagnostics in case of errors regress slightly.
2019-08-05Remove gensym from format_argsMatthew Jasper-0/+12
2019-07-30--bless tests due to INCOMPLETE_FEATURES being a lint.Mazdak Farrokhzad-0/+4