about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2021-02-25Address review commentsAmanieu d'Antras-39/+49
2021-02-24Properly reject non-const argumentsAmanieu d'Antras-2/+50
2021-02-24replaced some map_or with map_or_elseklensy-54/+57
2021-02-23Add #[rustc_legacy_const_generics]Amanieu d'Antras-0/+4
2021-02-23Rollup merge of #82296 - spastorino:pubrules, r=nikomatsakisDylan DPC-2/+7
Support `pub` on `macro_rules` This rebases and updates `since` version of #78166 from ``@petrochenkov`` r? ``@nikomatsakis``
2021-02-19Support `pub` on `macro_rules`Vadim Petrochenkov-2/+7
2021-02-19Rollup merge of #82259 - osa1:issue82156, r=petrochenkovDylan DPC-6/+5
Fix popping singleton paths in when generating E0433 Fixes #82156 --- This was introduced with #72923, so pinging `@Patryk27` for reviews.
2021-02-18Fix popping singleton paths in when generating E0433Ömer Sinan Ağacan-6/+5
Fixes #82156
2021-02-18ast: Keep expansion status for out-of-line module itemsVadim Petrochenkov-4/+4
Also remove `ast::Mod` which is mostly redundant now
2021-02-18ast: Stop using `Mod` in `Crate`Vadim Petrochenkov-15/+23
Crate root is sufficiently different from `mod` items, at least at syntactic level. Also remove customization point for "`mod` item or crate root" from AST visitors.
2021-02-16Auto merge of #81611 - cjgillot:meowner, r=estebankbors-14/+26
Only store a LocalDefId in some HIR nodes Some HIR nodes are guaranteed to be HIR owners: Item, TraitItem, ImplItem, ForeignItem and MacroDef. As a consequence, we do not need to store the `HirId`'s `local_id`, and we can directly store a `LocalDefId`. This allows to avoid a bit of the dance with `tcx.hir().local_def_id` and `tcx.hir().local_def_id_to_hir_id` mappings.
2021-02-16avoid full-slicing slicesMatthias Krüger-1/+1
If we already have a slice, there is no need to get another full-range slice from that, just use the original. clippy::redundant_slicing
2021-02-15Fix E0657.Camille GILLOT-12/+20
2021-02-15Only store a LocalDefId in hir::ImplItem.Camille GILLOT-3/+4
2021-02-15Only store a LocalDefId in hir::TraitItem.Camille GILLOT-3/+4
2021-02-15Only store a LocalDefId in hir::Item.Camille GILLOT-2/+3
Items are guaranteed to be HIR owner.
2021-02-15Use ItemId as a strongly typed index.Camille GILLOT-2/+3
2021-02-13Fix ICE caused by suggestion with no code substitutionsEsteban Küber-20/+8
Change suggestion logic to filter and checking _before_ creating specific resolution suggestion. Assert earlier that suggestions contain code substitions to make it easier in the future to debug invalid uses. If we find this becomes too noisy in the wild, we can always make the emitter resilient to these cases and remove the assertions. Fix #78651.
2021-02-11resolve: Reduce scope of `pub_use_of_private_extern_crate` deprecation lintVadim Petrochenkov-12/+20
2021-02-10resolve: Remove visibility hacks for enum variants and trait itemsVadim Petrochenkov-96/+11
Special treatment like this was necessary before `pub(restricted)` had been implemented and only two visibilities existed - `pub` and non-`pub`. Now it's no longer necessary and the desired behavior follows from `pub(restricted)`-style visibilities naturally assigned to enum variants and trait items.
2021-02-10resolve: Cleanup visibility resolution in enums and traitsVadim Petrochenkov-63/+42
2021-02-07Feature gate macro attributes in `#[derive]` outputVadim Petrochenkov-0/+30
2021-02-07expand/resolve: Turn `#[derive]` into a regular macro attributeVadim Petrochenkov-65/+83
2021-02-06Rollup merge of #81680 - camsteffen:primty, r=oli-obkJonas Schievink-62/+18
Refactor `PrimitiveTypeTable` for Clippy I removed `PrimitiveTypeTable` and added `PrimTy::ALL` and `PrimTy::from_name` in its place. This allows Clippy to use `PrimTy::from_name` for the `builtin_type_shadow` lint, and a `const` list of primitive types is deleted from Clippy code (the goal). All changes should be a little faster, if anything.
2021-02-05Small refactor with Iterator::reduceCameron Steffen-3/+2
2021-02-03Refactor out PrimitiveTypeTableCameron Steffen-62/+18
2021-02-02Rollup merge of #81636 - LingMan:slice_not_vec, r=petrochenkovJack Huey-2/+2
Directly use `Option<&[T]>` instead of converting from `Option<&Vec<T>>` later on ```@rustbot``` modify labels +C-cleanup +T-compiler
2021-02-02Auto merge of #81405 - bugadani:ast, r=cjgillotbors-15/+24
Box the biggest ast::ItemKind variants This PR is a different approach on https://github.com/rust-lang/rust/pull/81400, aiming to save memory in humongous ASTs. The three affected item kind enums are: - `ast::ItemKind` (208 -> 112 bytes) - `ast::AssocItemKind` (176 -> 72 bytes) - `ast::ForeignItemKind` (176 -> 72 bytes)
2021-02-02Auto merge of #80843 - Mark-Simulacrum:fmt-bump, r=petrochenkovbors-10/+16
Bump rustfmt version
2021-02-02Bump rustfmt versionMark Rousskov-10/+16
Also switches on formatting of the mir build module
2021-02-01Directly use `Option<&[T]>` instead of converting from `Option<&Vec<T>>` ↵LingMan-2/+2
later on
2021-02-01Remove unneeded `mut` variableLingMan-8/+1
`arg_elide` gets initialized, immediately cloned, and only written to after that. The last reading access was removed back in https://github.com/rust-lang/rust/commit/7704762604a8bf4504a06e8c9713bc7c158d362a
2021-02-01Box the biggest ast::ItemKind variantsDániel Buga-15/+24
2021-01-30Rollup merge of #81505 - henryboisdequin:cold_path-not-pub, r=sanxiynYuki Okushi-1/+1
`fn cold_path` doesn't need to be pub Fixes #81429 Note: this PR also fixes a small typo that I found
2021-01-29fix typoHenry Boisdequin-1/+1
2021-01-28Add `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lintAaron Hill-0/+2
cc #79813 This PR adds an allow-by-default future-compatibility lint `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS`. It fires when a trailing semicolon in a macro body is ignored due to the macro being used in expression position: ```rust macro_rules! foo { () => { true; // WARN } } fn main() { let val = match true { true => false, _ => foo!() }; } ``` The lint takes its level from the macro call site, and can be allowed for a particular macro by adding `#[allow(semicolon_in_expressions_from_macros)]`. The lint is set to warn for all internal rustc crates (when being built by a stage1 compiler). After the next beta bump, we can enable the lint for the bootstrap compiler as well.
2021-01-23Rollup merge of #81252 - jyn514:resolve-timing, r=petrochenkovJonas Schievink-10/+8
Add more self-profile info to rustc_resolve The idea is to help me find out where the time is being spent in compiling the docs for `windows-rs`: https://github.com/microsoft/windows-rs/issues/420#issuecomment-764991646
2021-01-21Fix clippy and commentEsteban Küber-1/+1
2021-01-21Avoid emitting redundant "unused label" lintEsteban Küber-1/+3
2021-01-21Add loop head span to hirEsteban Küber-1/+1
2021-01-21Suggest `'a` when given `a` only when appropriateEsteban Küber-9/+19
When encountering a name `a` that isn't resolved, but a label `'a` is found in the current ribs, only suggest `'a` if this name is the value expression of a `break` statement. Solve FIXME.
2021-01-21Add more self-profile info to rustc_resolveJoshua Nelson-10/+8
2021-01-21Rollup merge of #81046 - rylev:unknown-external-crate, r=estebankYuki Okushi-4/+17
Improve unknown external crate error This improves error messages when unknown items in the crate root are encountered. Fixes #63799 r? ```@estebank```
2021-01-18Rollup merge of #81105 - LingMan:init_directly, r=nagisaAshley Mannix-12/+9
Initialize a few variables directly Currently they are declared as `mut`, get initialized to a default value, and then possibly overwritten. By initializing to the final value directly, they don't need to be `mut` and it's clear that they don't get mutated elsewhere later on.
2021-01-18Improve unknown external crate errorRyan Levick-4/+17
2021-01-17Rollup merge of #80765 - petrochenkov:traitsinscope, r=matthewjasperMara Bos-127/+74
resolve: Simplify collection of traits in scope "Traits in scope" for a given location are collected by walking all scopes in type namespace, collecting traits in them and pruning traits that don't have an associated item with the given name and namespace. Previously we tried to prune traits using some kind of hygienic resolution for associated items, but that was complex and likely incorrect, e.g. in #80762 correction to visibilites of trait items caused some traits to not be in scope anymore. I previously had some comments and concerns about this in https://github.com/rust-lang/rust/pull/65351. In this PR we are doing some much simpler pruning based on `Symbol` and `Namespace` comparisons, it should be enough to throw away 99.9% of unnecessary traits. It is not necessary for pruning to be precise because for trait aliases, for example, we don't do any pruning at all, and precise hygienic resolution for associated items needs to be done in typeck anyway. The somewhat unexpected effect is that trait imports introduced by macros 2.0 now bring traits into scope due to the removed hygienic check on associated item names. I'm not sure whether it is desirable or not, but I think it's acceptable for now. The old check was certainly incorrect because macros 2.0 did bring trait aliases into scope. If doing this is not desirable, then we should come up with some other way to avoid bringing traits from macros 2.0 into scope, that would accommodate for trait aliases as well. --- The PR also contains a couple of pure refactorings - Scope walk is done by using `visit_scopes` instead of a hand-rolled version. - Code is restructured to accomodate for rustdoc that also wants to query traits in scope, but doesn't want to filter them by associated items at all. r? ```@matthewjasper```
2021-01-17Rollup merge of #80031 - petrochenkov:builtina, r=estebankMara Bos-4/+10
resolve: Reject ambiguity built-in attr vs different built-in attr Fixes https://github.com/rust-lang/rust/issues/79798. Resolution ensures that inert attributes cannot be used through imports like this, but built-in attributes don't go through initial resolution (only through resolution validation), so we have to keep some extra data (the built-in attribute name) to prevent it from happening.
2021-01-17Initialize a few variables directlyLingMan-12/+9
Currently they are declared as `mut`, get initialized to a default value, and then possibly overwritten. By initializing to the final value directly, they don't need to be `mut` and it's clear that they don't get mutated elsewhere later on.
2021-01-17resolve: Reject ambiguity built-in attr vs different built-in attrVadim Petrochenkov-4/+10
2021-01-16correctly deal with late-bound lifetimes in anon constsBastian Kauschke-2/+30