about summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
2019-08-27metadata: Eliminate `FullProcMacro`Vadim Petrochenkov-8/+8
Fix caching of loaded proc macros
2019-08-23resolve: Do not rely on default transparency when detecting proc macro derivesVadim Petrochenkov-5/+9
2019-08-21resolve/expand: Rename some things for clarity and add commentsVadim Petrochenkov-14/+22
2019-08-21expand: Keep the correct current expansion ID for eager expansionsVadim Petrochenkov-1/+3
Solve the problem of `ParentScope` entries for eager expansions not exising in the resolver map by creating them on demand.
2019-08-17resolve/expand: Rename some things for clarityVadim Petrochenkov-22/+22
2019-08-17resolve: Properly integrate derives and `macro_rules` scopesVadim Petrochenkov-13/+21
2019-08-17Move type parameter shadowing errors to resolveMatthew Jasper-10/+53
For some reason type checking did this. Further it didn't consider hygiene.
2019-08-16Fix rebaseVadim Petrochenkov-9/+12
Move some code into `build_reduced_graph.rs` to keep `BuildReducedGraphVisitor` it private Also move the def collector call to `build_reduced_graph.rs`, it belongs there.
2019-08-16resolve: Move some code aroundVadim Petrochenkov-74/+73
2019-08-16resolve: Populate external traits lazily as wellVadim Petrochenkov-22/+9
2019-08-16resolve: Populate external modules in more automatic and lazy wayVadim Petrochenkov-71/+73
The modules are now populated implicitly on the first access
2019-08-15resolve: `ParentScope::default` -> `ParentScope::module`Vadim Petrochenkov-7/+9
2019-08-15hygiene: `ExpnInfo` -> `ExpnData`Vadim Petrochenkov-5/+5
For naming consistency with everything else in this area
2019-08-15hygiene: Merge `ExpnInfo` and `InternalExpnData`Vadim Petrochenkov-5/+6
2019-08-15resolve: Add some comments to the main modulesVadim Petrochenkov-3/+26
2019-08-15resolve: Privatize `BuildReducedGraphVisitor`Vadim Petrochenkov-18/+23
2019-08-15resolve: Make `ParentScope` `Copy`Vadim Petrochenkov-33/+32
By allocating its derive paths on the resolver arena.
2019-08-15resolve: Eliminate `InvocationData`Vadim Petrochenkov-91/+53
It was very similar to `ParentScope` and mostly could be replaced by it.
2019-08-15resolve: Add `ParentScope::default`, eliminate `dummy_parent_scope`Vadim Petrochenkov-29/+29
Remove some unnecessary parameters from functions
2019-08-15resolve: Do not "normalize away" trait/enum modules prematurelyVadim Petrochenkov-4/+6
The previous approach was brittle - what would happen if `ParentScope` wasn't created by `invoc_parent_scope`? That's exactly the case for various uses of `ParentScope` in diagnostics and in built-in attribute validation.
2019-08-15resolve: Move macro resolution traces from `Module`s to `Resolver`Vadim Petrochenkov-24/+19
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-15hygiene: Remove `Option`s from functions returning `ExpnInfo`Vadim Petrochenkov-2/+1
The expansion info is not optional and should always exist
2019-08-15`Ident::with_empty_ctxt` -> `Ident::with_dummy_span`Vadim Petrochenkov-16/+16
`Ident` has had a full span rather than just a `SyntaxContext` for a long time now.
2019-08-15syntax_pos: `NO_EXPANSION`/`SyntaxContext::empty()` -> `SyntaxContext::root()`Vadim Petrochenkov-1/+1
For consistency with `ExpnId::root`. Also introduce a helper `Span::with_root_ctxt` for creating spans with `SyntaxContext::root()` context
2019-08-15syntax_pos: Introduce a helper for checking whether a span comes from expansionVadim Petrochenkov-2/+2
2019-08-15Remove `Spanned` from `ast::Mac`Vadim Petrochenkov-1/+1
2019-08-14Merge Variant and Variant_Caio-5/+5
2019-08-12Rollup merge of #63449 - petrochenkov:builtinagain, r=eddybMazdak Farrokhzad-12/+0
resolve: Remove remaining special cases from built-in macros Edition and definition sites of the macros are now also taken from the `#[rustc_builtin_macro]` definitions in `libcore`. --- The edition switch may be a breaking change for `Rustc{Encodable,Decodable}` derives if they are used in combination with the unstable crate `serialize` from sysroot like this ```rust extern crate serialize; use serialize as rustc_serialize; #[derive(RustcEncodable)] struct S; ``` (see the updated `ui-fulldeps` tests).
2019-08-12Rollup merge of #63406 - ↵Mazdak Farrokhzad-53/+55
jakubadamw:resolve-inconsistent-names-suggest-qualified-path, r=petrochenkov Suggest using a qualified path in patterns with inconsistent bindings A program like the following one: ```rust enum E { A, B, C } fn f(x: E) -> bool { match x { A | B => false, C => true } } ``` is rejected by the compiler due to `E` variant paths not being in scope. In this case `A`, `B` are resolved as pattern bindings and consequently the pattern is considered invalid as the inner or-patterns do not bind to the same set of identifiers. This is expected but the compiler errors that follow could be surprising or confusing to some users. This commit adds a help note explaining that if the user desired to match against variants or consts, they should use a qualified path. The help note is restricted to cases where the identifier starts with an upper-case sequence so as to reduce the false negatives. Since this happens during resolution, there's no clean way to check what it is the patterns match against. The syntactic criterium, however, is in line with the convention that's assumed by the `non-camel-case-types` lint. Fixes #50831.
2019-08-10Apply suggestions from code reviewJakub Adam Wieczorek-32/+32
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-08-10Suggest using a qualified path in patterns with inconsistent bindingsJakub Adam Wieczorek-44/+46
A program like the following one: ```rust enum E { A, B, C } fn f(x: E) -> bool { match x { A | B => false, C => true } } ``` is rejected by the compiler due to `E` variant paths not being in scope. In this case `A`, `B` are resolved as pattern bindings and consequently the pattern is considered invalid as the inner or-patterns do not bind to the same set of identifiers. This is expected but the compiler errors that follow could be surprising or confusing to some users. This commit adds a help note explaining that if the user desired to match against variants or consts, they should use a qualified path. The note is restricted to cases where the identifier starts with an upper-case sequence so as to reduce the false negatives. Since this happens during resolution, there's no clean way to check what the patterns match against. The syntactic criterium, however, is in line with the convention that's assumed by the `non-camel-case-types` lint.
2019-08-10diagnostics: Describe crate root modules in `DefKind::Mod` as "crate"Vadim Petrochenkov-27/+14
2019-08-10resolve: Remove remaining special cases from built-in macrosVadim Petrochenkov-12/+0
2019-08-10resolve: Address FIXME from the previous commitVadim Petrochenkov-15/+13
Make the `is_import` flag in `ScopeSet` independent from namespace Fix rebase
2019-08-10Fix calls to resolver from rustdoc and HIR loweringVadim Petrochenkov-36/+35
Cleanup some surrounding code. Support resolution of intra doc links in unnamed block scopes. (Paths from rustdoc now use early resolution and no longer need results of late resolution like all the built ribs.) Fix one test hitting file path limits on Windows.
2019-08-10resolve: Move some more code aroundVadim Petrochenkov-616/+602
Move methods logically belonging to build-reduced-graph into `impl BuildReducedGraphVisitor` and `build_reduced_graph.rs` Move types mostly specific to late resolution closer to the late resolution visitor
2019-08-10resolve: Turn `resolve_error` into a method on `Resolver`Vadim Petrochenkov-422/+411
Rename it to `report_error` and move into `diagnostics.rs` Also turn `check_unused` into a method on `Resolver`
2019-08-10resolve: Remove `Deref<Target=Resolver>` implementationsVadim Petrochenkov-319/+269
It's now immediately clear what fields belong to the global resolver state and what are specific to passes/visitors.
2019-08-10resolve: Track whole parent scope in the visitorsVadim Petrochenkov-96/+78
Instead of tracking current module and other components separately. (`ParentScope` includes the module as a component.)
2019-08-10resolve: Move late resolution visitor into a separate fileVadim Petrochenkov-2634/+2663
2019-08-10resolve: Move late resolution into a separate visitorVadim Petrochenkov-280/+396
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-09Mention that tuple structs are private if their fields areEsteban Küber-3/+28
2019-08-09Rollup merge of #63289 - kornelski:missingcrate, r=zackmdavisMazdak Farrokhzad-1/+1
Don't recommend `extern crate` syntax `extern crate` syntax is not a good recommendation any more, so I've changed it to just print a suggested crate name.
2019-08-06Rollup merge of #63286 - Mark-Simulacrum:resolve-no-cb, r=petrochenkovMazdak Farrokhzad-24/+17
Replace error callback with Result r? @petrochenkov
2019-08-05Don't recommend `extern crate` syntaxKornel-1/+1
2019-08-05Force callers of resolve_ast_path to deal with Res::Err correctlyMark Rousskov-10/+2
2019-08-05Don't store &SpanMark Rousskov-4/+4
This is just needless indirection.
2019-08-05Replace error callback with ResultMark Rousskov-23/+24
2019-08-05Auto merge of #63248 - petrochenkov:nomarker, r=matthewjasperbors-5/+49
Move special treatment of `derive(Copy, PartialEq, Eq)` from expansion infrastructure to elsewhere As described in https://github.com/rust-lang/rust/pull/62086#issuecomment-515195477. Reminder: - `derive(PartialEq, Eq)` makes the type it applied to a "structural match" type, so constants of this type can be used in patterns (and const generics in the future). - `derive(Copy)` notifies other derives that the type it applied to implements `Copy`, so `derive(Clone)` can generate optimized code and other derives can generate code working with `packed` types and types with `rustc_layout_scalar_valid_range` attributes. First, the special behavior is now enabled after properly resolving the derives, rather than after textually comparing them with `"Copy"`, `"PartialEq"` and `"Eq"` in `fn add_derived_markers`. The markers are no longer kept as attributes in AST since derives cannot modify items and previously did it through hacks in the expansion infra. Instead, the markers are now kept in a "global context" available from all the necessary places, namely - resolver. For `derive(PartialEq, Eq)` the markers are created by the derive macros themselves and then consumed during HIR lowering to add the `#[structural_match]` attribute in HIR. This is still a hack, but now it's a hack local to two specific macros rather than affecting the whole expansion infra. Ideally we should find the way to put `#[structural_match]` on the impls rather than on the original item, and then consume it in `rustc_mir`, then no hacks in expansion and lowering will be required. (I'll make an issue about this for someone else to solve, after this PR lands.) The marker for `derive(Copy)` cannot be emitted by the `Copy` macro itself because we need to know it *before* the `Copy` macro is expanded for expanding other macros. So we have to do it in resolve and block expansion of any derives in a `derive(...)` container until we know for sure whether this container has `Copy` in it or not. Nasty stuff. r? @eddyb or @matthewjasper
2019-08-04Rename `ItemImplKind::Type` to `ItemImplKind::TyAlias`varkor-1/+1