summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
2019-09-13Support "soft" feature-gating using a lintVadim Petrochenkov-2/+2
Use it for feature-gating `#[bench]`
2019-09-02expand: Keep the correct current expansion ID for eager expansionsVadim Petrochenkov-7/+9
Solve the problem of `ParentScope` entries for eager expansions not exising in the resolver map by creating them on demand.
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
2019-08-04Rename `ItemKind::Ty` to `ItemKind::TyAlias`varkor-2/+2
2019-08-03Move special treatment of `derive(Copy, PartialEq, Eq)` from expansion ↵Vadim Petrochenkov-5/+49
infrastructure to elsewhere
2019-08-02Replace "existential" by "opaque"varkor-6/+6
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-3/+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-27Move standard library injection into libsyntax_extVadim Petrochenkov-3/+4
2019-07-26Introduce built-in macros through libcoreVadim Petrochenkov-93/+81
2019-07-23normalize use of backticks for compiler messages in remaining modulesSamy Kacimi-1/+1
https://github.com/rust-lang/rust/issues/60532
2019-07-19hygiene: Tweak naming some moreVadim Petrochenkov-7/+7
2019-07-19Adjust other names after the `Mark` renamingVadim Petrochenkov-22/+22
2019-07-19libsyntax: Remove `Mark` into `ExpnId`Vadim Petrochenkov-58/+59
2019-07-18resolve: Support resolving macro paths without macro kind restrictionsVadim Petrochenkov-13/+15
2019-07-18resolve: Attempt to resolve unresolved paths in macro namespaceVadim Petrochenkov-17/+19
2019-07-18resolve: Move some common code into the scope visitorVadim Petrochenkov-142/+114
2019-07-18resolve: Visit all scopes to collect suggestion candidates for unresolved macrosVadim Petrochenkov-122/+230
2019-07-18resolve: Use `feature(custom_attribute)` fallback only if the feature is enabledVadim Petrochenkov-73/+3
Normally `#![feature(...)]` shouldn't change behavior, but custom attributes in particular are in the process of retirement, and we should not produce a message telling to enable them. It also helps with unifying diagnostics for unresolved macros.
2019-07-18resolve: Decouple scope visiting process from visitor actionsVadim Petrochenkov-138/+170
2019-07-18resolve: Rename `WhereToResolve` into `Scope`Vadim Petrochenkov-71/+79
Also move it into the crate root, it's no longer used for macros only
2019-07-18resolve: Move some diagnostic code into `diagnostics.rs`Vadim Petrochenkov-595/+600
2019-07-13Suggest assoc type on type not found in trait method definitionEsteban Küber-35/+70
2019-07-13Make `register_[long_]diagnostics` hygienicMatthew Jasper-1/+1
2019-07-11expand: Move "derive containers" into a separate `InvocationKind` variantVadim Petrochenkov-4/+4
`InvocationKind::Attr { attr: None, .. }` meaning something entirely different from a regular attribute was confusing as hell.
2019-07-11hygiene: Introduce a helper method for creating new expansionsVadim Petrochenkov-2/+5
Creating a fresh expansion and immediately generating a span from it is the most common scenario. Also avoid allocating `allow_internal_unstable` lists for derive markers repeatedly. And rename `ExpnInfo::with_unstable` to `ExpnInfo::allow_unstable`, seems to be a better fitting name.