about summary refs log tree commit diff
path: root/src/librustc_resolve/lib.rs
AgeCommit message (Collapse)AuthorLines
2019-09-05Replace diagnostic plugins with macro_rulesMark Rousskov-5/+1
2019-09-05Allow ast passes to create hygienic spansMatthew Jasper-0/+22
2019-09-05resolve: extract `try_resolve_as_non_binding`.Mazdak Farrokhzad-0/+1
2019-08-23resolve: Do not rely on default transparency when detecting proc macro derivesVadim Petrochenkov-4/+8
2019-08-17resolve/expand: Rename some things for clarityVadim Petrochenkov-2/+2
2019-08-17Move type parameter shadowing errors to resolveMatthew Jasper-1/+1
For some reason type checking did this. Further it didn't consider hygiene.
2019-08-16Fix rebaseVadim Petrochenkov-7/+1
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-0/+20
2019-08-16resolve: Populate external modules in more automatic and lazy wayVadim Petrochenkov-15/+23
The modules are now populated implicitly on the first access
2019-08-15resolve: `ParentScope::default` -> `ParentScope::module`Vadim Petrochenkov-4/+6
2019-08-15resolve: Add some comments to the main modulesVadim Petrochenkov-0/+9
2019-08-15resolve: Privatize `BuildReducedGraphVisitor`Vadim Petrochenkov-3/+2
2019-08-15resolve: Make `ParentScope` `Copy`Vadim Petrochenkov-5/+9
By allocating its derive paths on the resolver arena.
2019-08-15resolve: Eliminate `InvocationData`Vadim Petrochenkov-15/+14
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-4/+15
Remove some unnecessary parameters from functions
2019-08-15resolve: Do not "normalize away" trait/enum modules prematurelyVadim Petrochenkov-3/+5
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-8/+10
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-15`Ident::with_empty_ctxt` -> `Ident::with_dummy_span`Vadim Petrochenkov-7/+7
`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-12Rollup merge of #63449 - petrochenkov:builtinagain, r=eddybMazdak Farrokhzad-3/+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-0/+1
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-1/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-08-10Suggest using a qualified path in patterns with inconsistent bindingsJakub Adam Wieczorek-0/+1
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-22/+9
2019-08-10resolve: Remove remaining special cases from built-in macrosVadim Petrochenkov-3/+0
2019-08-10resolve: Address FIXME from the previous commitVadim Petrochenkov-9/+8
Make the `is_import` flag in `ScopeSet` independent from namespace Fix rebase
2019-08-10Fix calls to resolver from rustdoc and HIR loweringVadim Petrochenkov-35/+34
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-331/+4
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-298/+15
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-1/+1
It's now immediately clear what fields belong to the global resolver state and what are specific to passes/visitors.
2019-08-10resolve: Move late resolution visitor into a separate fileVadim Petrochenkov-1960/+74
2019-08-10resolve: Move late resolution into a separate visitorVadim Petrochenkov-169/+248
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-2/+18
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
2019-08-04Rename `ItemKind::Ty` to `ItemKind::TyAlias`varkor-1/+1
2019-08-03Move special treatment of `derive(Copy, PartialEq, Eq)` from expansion ↵Vadim Petrochenkov-2/+18
infrastructure to elsewhere
2019-08-02Replace "existential" by "opaque"varkor-3/+3
2019-07-30Rollup merge of #63083 - matthewjasper:parameter-hygiene, r=petrochenkovMazdak Farrokhzad-8/+18
Make generic parameters always use modern hygiene * E0263 (lifetime parameter declared twice in the same scope) now compares modernized identifiers. * Const parameters are now resolved with modern hygiene. Closes #58307 Closes #60746 Closes #61574 Closes #62433
2019-07-28Deny `unused_lifetimes` through rustbuildVadim Petrochenkov-2/+0
2019-07-28Remove lint annotations in specific crates that are already enforced by ↵Vadim Petrochenkov-1/+0
rustbuild Remove some random unnecessary lint `allow`s
2019-07-28Resolve const parameters with modern hygieneMatthew Jasper-8/+18
Declarations were already modernized, resulting in cases where a macro couldn't resolve it's own identifier.
2019-07-26Introduce built-in macros through libcoreVadim Petrochenkov-11/+13