about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/late
AgeCommit message (Collapse)AuthorLines
2021-03-27lazily calls some fnsklensy-5/+5
2021-03-25write-up what is happeningNiko Matsakis-0/+28
2021-03-24Review commentsJack Huey-16/+37
2021-03-24resolve late lifetimes by itemJack Huey-157/+269
This reverts commit 22ae20733515d710c1134600bc1e29cdd76f6b9b.
2021-03-23Add has_default to GenericParamDefKind::Constkadmin-1/+3
This currently creates a field which is always false on GenericParamDefKind for future use when consts are permitted to have defaults Update const_generics:default locations Previously just ignored them, now actually do something about them. Fix using type check instead of value Add parsing This adds all the necessary changes to lower const-generics defaults from parsing. Change P<Expr> to AnonConst This matches the arguments passed to instantiations of const generics, and makes it specific to just anonymous constants. Attempt to fix lowering bugs
2021-03-18hir: Preserve used syntax in `TyKind::TraitObject`Vadim Petrochenkov-2/+2
2021-03-15Custom error on literal names from other languagesSmitty-0/+26
This detects all Java literal types and all single word C data types, and suggests the corresponding Rust literal type.
2021-03-10Auto merge of #79519 - cjgillot:noattr, r=wesleywiserbors-1/+2
Store HIR attributes in a side table Same idea as #72015 but for attributes. The objective is to reduce incr-comp invalidations due to modified attributes. Notably, those due to modified doc comments. Implementation: - collect attributes during AST->HIR lowering, in `LocalDefId -> ItemLocalId -> &[Attributes]` nested tables; - access the attributes through a `hir_owner_attrs` query; - local refactorings to use this access; - remove `attrs` from HIR data structures one-by-one. Change in behaviour: - the HIR visitor traverses all attributes at once instead of parent-by-parent; - attribute arrays are sometimes duplicated: for statements and variant constructors; - as a consequence, attributes are marked as used after unused-attribute lint emission to avoid duplicate lints. ~~Current bug: the lint level is not correctly applied in `std::backtrace_rs`, triggering an unused attribute warning on `#![no_std]`. I welcome suggestions.~~
2021-03-10Rollup merge of #82942 - m-ou-se:diagnostics-hardcoded-prelude-v1, r=estebankYuki Okushi-1/+1
Don't hardcode the `v1` prelude in diagnostics, to allow for new preludes. Instead of looking for `std::prelude::v1`, this changes the two places where that was hardcoded to look for `std::prelude::<anything>` instead. This is needed for https://github.com/rust-lang/rust/pull/82217. r? `@estebank`
2021-03-09Don't hardcode the `v1` prelude in diagnostics.Mara Bos-1/+1
Instead of looking for `std::prelude::v1`, this changes it to look for `std::prelude::<anything>`.
2021-03-09Remove hir::Item::attrs.Camille GILLOT-1/+2
2021-03-07diagnostics: Differentiate between edition meanings of ::foo in resolve ↵Manish Goregaokar-1/+11
diagnostics for ::foo::Bar
2021-03-03reworded messageEsteban Küber-4/+8
2021-03-02Account for macros when suggesting adding lifetimeEsteban Küber-8/+17
Fix #70152.
2021-02-26Rollup merge of #82456 - klensy:or-else, r=estebankGuillaume Gomez-1/+1
Replaced some unwrap_or and map_or with lazy variants Replaced some `unwrap_or` and `map_or` with `unwrap_or_else` and `map_or_else`.
2021-02-25Rollup merge of #82087 - estebank:abolish-ice, r=oli-obkDylan DPC-20/+8
Fix ICE caused by suggestion with no code substitutions 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-25fix reviewklensy-57/+54
2021-02-24replaced some map_or with map_or_elseklensy-54/+57
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-06Rollup merge of #81680 - camsteffen:primty, r=oli-obkJonas Schievink-2/+2
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-03Refactor out PrimitiveTypeTableCameron Steffen-2/+2
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-1/+3
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-1/+3
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/+13
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-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-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-16correctly deal with late-bound lifetimes in anon constsBastian Kauschke-2/+30
2021-01-15Rollup merge of #80944 - LingMan:map_or, r=nagisaYuki Okushi-3/+2
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-3/+2
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-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-10Rework diagnostics for wrong number of generic argsPatryk Wychowaniec-1/+1
2020-12-31Consistently call editions "Rust 20xx" in messages.Mara Bos-2/+2
2020-12-28Rollup merge of #80344 - matthiaskrgr:matches, r=Dylan-DPCDylan DPC-11/+8
use matches!() macro in more places
2020-12-26stabilize min_const_genericsBastian Kauschke-5/+5