about summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
2020-04-07Do not suggest adding type param when `use` is already suggestedEsteban Küber-2/+1
Fix #70365, cc #70572.
2020-04-08librustc_hir: return LocalDefId instead of DefId in local_def_idmarmeladema-36/+51
2020-04-03def_collector, visit_fn: account for no bodyMazdak Farrokhzad-4/+3
2020-04-01Rollup merge of #70081 - lcnr:issue68387, r=varkorDylan DPC-1/+1
add `unused_braces` lint Add the lint `unused_braces` which is warn by default. `unused_parens` is also extended and now checks anon consts. closes #68387 r? @varkor
2020-03-31fix internal lint falloutBastian Kauschke-1/+1
2020-03-30try_resolve_as_non_binding: span_bug -> delay_span_bugMazdak Farrokhzad-9/+8
2020-03-30rustc -> rustc_middle part 3 (rustfmt)Mazdak Farrokhzad-22/+22
2020-03-30rustc -> rustc_middle part 2Mazdak Farrokhzad-22/+22
2020-03-30rustc -> rustc_middle part 1Mazdak Farrokhzad-1/+1
2020-03-25Rename `def_span` to `guess_head_span`Esteban Küber-6/+7
2020-03-25Rollup merge of #70373 - Centril:canon-imports, r=Mark-SimulacrumMazdak Farrokhzad-1/+1
normalize some imports & prefer direct ones r? @Mark-Simulacrum
2020-03-24normalize some imports, prefer direct ones.Mazdak Farrokhzad-1/+1
2020-03-24resolve: Remove `rustc_attrs` as a standalone feature gateVadim Petrochenkov-11/+6
Now it only gates specific built-in attributes
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-23Rollup merge of #70233 - petrochenkov:superproc, r=ecstatic-morseMazdak Farrokhzad-1/+8
resolve: Do not resolve visibilities on proc macro definitions twice Fixes https://github.com/rust-lang/rust/issues/68921
2020-03-23Rollup merge of #69942 - estebank:sized-verbose-sugg, r=matthewjasperMazdak Farrokhzad-4/+4
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-23resolve: Do not resolve visibilities on proc macro definitions twiceVadim Petrochenkov-1/+8
2020-03-23Auto merge of #70296 - Centril:rollup-wvfmb3n, r=Centrilbors-1/+10
Rollup of 9 pull requests Successful merges: - #69251 (#[track_caller] in traits) - #69880 (miri engine: turn error sanity checks into assertions) - #70207 (Use getentropy(2) on macos) - #70227 (Only display definition when suggesting a typo) - #70236 (resolve: Avoid "self-confirming" import resolutions in one more case) - #70248 (parser: simplify & remove unused field) - #70249 (handle ConstKind::Unresolved after monomorphizing) - #70269 (remove redundant closures (clippy::redundant_closure)) - #70270 (Clean up E0449 explanation) Failed merges: r? @ghost
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-23Rollup merge of #70236 - petrochenkov:globimpice, r=ecstatic-morseMazdak Farrokhzad-0/+9
resolve: Avoid "self-confirming" import resolutions in one more case So the idea behind "blacklisted bindings" is that we must ignore some name definitions during resolution because otherwise they cause infinite cycles. E.g. import ```rust use my_crate; ``` would refer to itself (on 2018 edition) without this blacklisting, because `use my_crate;` is the first name in scope when we are resolving `my_crate` here. In this PR we are doing this blacklisting for the case ```rust use same::same; ``` , namely blacklisting the second `same` when resolving the first `same`. This was previously forgotten. Fixes https://github.com/rust-lang/rust/issues/62767
2020-03-23Rollup merge of #70227 - LeSeulArtichaut:typo-def, r=CentrilMazdak Farrokhzad-1/+1
Only display definition when suggesting a typo Closes #70206 r? @Centril
2020-03-23Auto merge of #70204 - Centril:unshackled-lowering, r=Zoxcbors-1/+1
Liberate `rustc_ast_lowering` from `rustc` The whole point of this PR is the very last commit, in which we remove `rustc` as one of `rustc_ast_lowering`'s dependencies, thereby improving `./x.py` parallelism and working towards https://github.com/rust-lang/rust/issues/65031. Noteworthy: - From `rustc::arena` we move logic into `arena`, in particular `declare_arena!`. This is then used in `rustc_ast_lowering` so that lowering has its own separate arena. - Some linting code is unfortunately moved to `rustc_session::lint` cause its used both in `rustc_lint` and `rustc_ast_lowering`, and this is their common dependency. - `rustc_session::CrateDisambiguator` is moved into `rustc_ast` so that `rustc::hir::map::definitions` can be moved into `rustc_hir`, so that `rustc_ast_lowering` can stop referring to `rustc::hir`. r? @Zoxc
2020-03-22Normalize wording of privacy access labelsEsteban Küber-4/+4
2020-03-22Rollup merge of #70254 - matthiaskrgr:cl4ppy, r=CentrilDylan DPC-5/+3
couple more clippy fixes (let_and_return, if_same_then_else) * summarize if-else-code with identical blocks (clippy::if_same_then_else) * don't create variable bindings just to return the bound value immediately (clippy::let_and_return)
2020-03-22don't create variable bindings just to return the bound value immediately ↵Matthias Krüger-5/+3
(clippy::let_and_return)
2020-03-21{rustc::hir::map -> rustc_hir}::definitionsMazdak Farrokhzad-1/+1
2020-03-21make some let-if-bindings more idiomatic (clippy::useless_let_if_seq)Matthias Krüger-5/+7
2020-03-21resolve: Avoid "self-confirming" import resolutions in one more caseVadim Petrochenkov-0/+9
2020-03-21Only display definition on typoLeSeulArtichaut-1/+1
2020-03-21Rollup merge of #70187 - matthiaskrgr:cl2ppy, r=Mark-SimulacrumMazdak Farrokhzad-5/+5
more clippy fixes * remove redundant returns (clippy::needless_return) * remove redundant import (clippy::single_component_path_imports) * remove redundant format!() call (clippy::useless_format) * don't use ok() before calling expect() (clippy::ok_expect)
2020-03-20remove redundant returns (clippy::needless_return)Matthias Krüger-5/+5
2020-03-20Fix oudated comment for NamedRegionMapbjorn3-1/+1
2020-03-19rustc: use LocalDefId instead of DefIndex in hir::map::definitions.Eduard-Mihai Burtescu-9/+13
2020-03-19rustc: use LocalDefId instead of DefIndex in HirId.Eduard-Mihai Burtescu-3/+3
2020-03-19rustc: use LocalDefId instead of DefIndex for query keys.Eduard-Mihai Burtescu-14/+3
2020-03-18Rollup merge of #69920 - Centril:hir-cleanup, r=ZoxcMazdak Farrokhzad-25/+22
Remove some imports to the rustc crate - When we have `NestedVisitorMap::None`, we use `type Map = dyn intravisit::Map<'v>;` instead of the actual map. This doesn't actually result in dynamic dispatch (in the future we may want to use an associated type default to simplify the code). - Use `rustc_session::` imports instead of `rustc::{session, lint}`. r? @Zoxc
2020-03-17Rollup merge of #70000 - petrochenkov:rawkeypars, r=davidtwcoMazdak Farrokhzad-4/+1
resolve: Fix regression in resolution of raw keywords in paths Fixes https://github.com/rust-lang/rust/issues/63882.
2020-03-17Rollup merge of #69870 - petrochenkov:cfgacc, r=matthewjasperMazdak Farrokhzad-0/+36
expand: Implement something similar to `#[cfg(accessible(path))]` cc https://github.com/rust-lang/rust/issues/64797 The feature is implemented as a `#[cfg_accessible(path)]` attribute macro rather than as `#[cfg(accessible(path))]` because it needs to wait until `path` becomes resolvable, and `cfg` cannot wait, but macros can wait. Later we can think about desugaring or not desugaring `#[cfg(accessible(path))]` into `#[cfg_accessible(path)]`. This implementation is also incomplete in the sense that it never returns "false" from `cfg_accessible(path)`, it requires some tweaks to resolve, which is not quite ready to answer queries like this during early resolution. However, the most important part of this PR is not `cfg_accessible` itself, but expansion infrastructure for retrying expansions. Before this PR we could say "we cannot resolve this macro path, let's try it later", with this PR we can say "we cannot expand this macro, let's try it later" as well. This is a pre-requisite for - turning `#[derive(...)]` into a regular attribute macro, - properly supporting eager expansion for macros that cannot yet be resolved like ``` fn main() { println!(not_available_yet!()); } macro_rules! make_available { () => { #[macro_export] macro_rules! not_available_yet { () => { "Hello world!" } }} } make_available!(); ```
2020-03-17Rollup merge of #69811 - petrochenkov:privdiag2, r=estebankMazdak Farrokhzad-36/+68
resolve: Print import chains on privacy errors A part of https://github.com/rust-lang/rust/pull/67951 that doesn't require hacks. r? @estebank
2020-03-16Rollup merge of #69989 - petrochenkov:nolegacy, r=eddyb,matthewjasperDylan DPC-125/+158
resolve/hygiene: `macro_rules` are not "legacy" The "modern" vs "legacy" naming was introduced by jseyfried during initial implementation of macros 2.0. At this point it's clear that `macro_rules` are not going anywhere and won't be deprecated in the near future. So this PR changes the naming "legacy" (when it implies "macro_rules") to "macro_rules". This should also help people reading this code because it's wasn't obvious that "legacy" actually meant "macro_rules" in these contexts. The most contentious renaming here is probably ``` fn modern -> fn normalize_to_macros_2_0 fn modern_and_legacy -> fn normalize_to_macro_rules ``` Other alternatives that I could think of are `normalize_to_opaque`/`normalize_to_semitransparent`, or `strip_non_opaque`/`strip_transparent`, but they seemed less intuitive. The documentation to these functions can be found in `symbol.rs`. r? @matthewjasper
2020-03-16use direct imports for `rustc::{lint, session}`.Mazdak Farrokhzad-20/+17
2020-03-16remove unnecessary hir::map importsMazdak Farrokhzad-5/+5
2020-03-15More Method->Fn renamingMark Mansi-8/+6
2020-03-16hygiene: `modern` -> `normalize_to_macros_2_0`Vadim Petrochenkov-48/+63
`modern_and_legacy` -> `normalize_to_macro_rules`
2020-03-16Other `legacy` -> `macro_rules`Vadim Petrochenkov-22/+26
2020-03-16resolve: `Legacy(Scope,Binding)` -> `MacroRules(Scope,Binding)`Vadim Petrochenkov-53/+67
2020-03-16ast/hir: `MacroDef::legacy` -> `MacroDef::macro_rules`Vadim Petrochenkov-3/+3
2020-03-15Auto merge of #68944 - Zoxc:hir-map, r=eddybbors-7/+7
Use queries for the HIR map r? @eddyb cc @michaelwoerister
2020-03-15Rollup merge of #70011 - petrochenkov:asyncice, r=CentrilMazdak Farrokhzad-61/+22
def_collector: Fully visit async functions We forgot to visit attributes previously, it caused ICEs. Special treatment of async functions is also moved from `visit_item` to `visit_fn` to reuse more of the default visitor. Fixes https://github.com/rust-lang/rust/issues/67778.
2020-03-15Rollup merge of #70006 - petrochenkov:fresh, r=CentrilMazdak Farrokhzad-22/+24
resolve: Fix two issues in fresh binding disambiguation Prevent fresh bindings from shadowing ambiguity items. Fixes https://github.com/rust-lang/rust/issues/46079 Correctly treat const generic parameters in fresh binding disambiguation. Fixes https://github.com/rust-lang/rust/issues/68853