about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
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
2021-01-15Rollup merge of #80944 - LingMan:map_or, r=nagisaYuki Okushi-6/+5
Use Option::map_or instead of `.map(..).unwrap_or(..)` ``@rustbot`` modify labels +C-cleanup +T-compiler
2021-01-14Use Option::map_or instead of `.map(..).unwrap_or(..)`LingMan-6/+5
2021-01-14Auto merge of #79689 - Vooblin:patch1, r=tmandrybors-10/+10
Update tests of "unused_lifetimes" lint for async functions and corresponding source code Before this PR the following code would cause an error: ``` #![deny(unused_lifetimes)] async fn f<'a>(_: &'a i32) {} fn main() {} ``` It was happening because of the desugaring of return type in async functions. As a result of the desugaring, the return type contains all lifetimes involved in the function signature. And these lifetimes were interpreted separately from the same in the function scope => so they are unused. Now, all lifetimes from the return type are interpreted as used. It is also not perfect, but at least this lint doesn't cause wrong errors now. This PR connected to issues #78522, #77217
2021-01-13Auto merge of #77524 - Patryk27:fixes/66228, r=estebankbors-1/+1
Rework diagnostics for wrong number of generic args (fixes #66228 and #71924) This PR reworks the `wrong number of {} arguments` message, so that it provides more details and contextual hints.
2021-01-13Auto merge of #79322 - jyn514:refactor-impl, r=estebankbors-4/+4
Separate out a `hir::Impl` struct This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases. See `rustc_save_analysis::dump_visitor::process_impl` or `rustdoc::clean::clean_impl` for a good example of how this makes `impl`s easier to work with. r? `@petrochenkov` maybe?
2021-01-12Separate out a `hir::Impl` structJoshua Nelson-4/+4
This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases.
2021-01-12Rollup merge of #80927 - LingMan:matches, r=estebankYuki Okushi-2/+1
Replace a simple `if let` with the `matches` macro `@rustbot` modify labels +C-cleanup +T-compiler
2021-01-12Replace a simple `if let` with the `matches` macroLingMan-2/+1
2021-01-12Rollup merge of #80870 - petrochenkov:bmactable, r=oli-obkYuki Okushi-7/+9
resolve: Simplify built-in macro table We don't use full `SyntaxExtension`s from the table, only `SyntaxExtensionKind`s, and `Ident` in `register_builtin_macro` always had dummy span. This PR removes unnecessary data from the table and related function signatures. Noticed when reviewing #80850.
2021-01-11resolve: Simplify collection of traits in scopeVadim Petrochenkov-127/+74
2021-01-10Auto merge of #80782 - petrochenkov:viscopes, r=matthewjasperbors-56/+81
resolve: Scope visiting doesn't need an `Ident` Resolution scope visitor (`fn visit_scopes`) currently takes an `Ident` parameter, but it doesn't need a full identifier, or even its span, it only needs the `SyntaxContext` part. The `SyntaxContext` part is necessary because scope visitor has to jump to macro definition sites, so it has to be directed by macro expansion information somehow. I think it's clearer to pass only the necessary part. Yes, usually visiting happens as a part of an identifier resolution, but in cases like collecting traits in scope (#80765) or collecting typo suggestions that's not the case. r? `@matthewjasper`
2021-01-10Rework diagnostics for wrong number of generic argsPatryk Wychowaniec-1/+1
2021-01-10resolve: Simplify built-in macro tableVadim Petrochenkov-7/+9
2021-01-10Rollup merge of #80850 - m-ou-se:rustc-builtin-macro-name, r=petrochenkovYuki Okushi-5/+5
Allow #[rustc_builtin_macro = "name"] This adds the option of specifying the name of a builtin macro in the `#[rustc_builtin_macro]` attribute: `#[rustc_builtin_macro = "name"]`. This makes it possible to have both `std::panic!` and `core::panic!` as a builtin macro, by using different builtin macro names for each. This is needed to implement the edition-specific behaviour of the panic macros of RFC 3007. Also removes `SyntaxExtension::is_derive_copy`, as the macro name (e.g. `sym::Copy`) is now tracked and provides that information directly. r? ``@petrochenkov``
2021-01-10Rollup merge of #80801 - estebank:correct-binding-sugg-span, r=petrochenkovYuki Okushi-16/+31
Use correct span for structured suggestion On structured suggestion for `let` -> `const` and `const` -> `let`, use a proper `Span` and update tests to check the correct application. Follow up to #80012.
2021-01-09Allow #[rustc_builtin_macro = "name"].Mara Bos-5/+5
This makes it possible to have both std::panic and core::panic as a builtin macro, by using different builtin macro names for each. Also removes SyntaxExtension::is_derive_copy, as the macro name (e.g. sym::Copy) is now tracked and provides that information directly.
2021-01-09resolve/expand: Improve attribute expansion on macro definitions and callsVadim Petrochenkov-16/+24