summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2021-03-18hir: Preserve used syntax in `TyKind::TraitObject`Vadim Petrochenkov-2/+2
2021-03-16ast: Reduce size of `ExprKind` by boxing fields of `ExprKind::Struct`Vadim Petrochenkov-2/+2
2021-03-16ast/hir: Rename field-related structuresVadim Petrochenkov-13/+17
StructField -> FieldDef ("field definition") Field -> ExprField ("expression field", not "field expression") FieldPat -> PatField ("pattern field", not "field pattern") Also rename visiting and other methods working on them.
2021-03-15Rollup merge of #82989 - Smittyvb:other-lang-literal-errors, r=varkorDylan DPC-0/+26
Custom error on literal names from other languages This detects all Java literal types and all single word C data types, and suggests the corresponding Rust literal type.
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-14expand: Resolve and expand inner attributes on out-of-line modulesVadim Petrochenkov-2/+25
2021-03-12Make def_key and HIR parenting consistent.Camille GILLOT-22/+82
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: Don't mention external crates when hitting import errors on ↵Manish Goregaokar-1/+3
crate imports in 2018
2021-03-07diagnostics: Differentiate between edition meanings of ::foo in resolve ↵Manish Goregaokar-1/+11
diagnostics for ::foo::Bar
2021-03-07diagnostics: Differentiate between edition meanings of ::foo in resolve ↵Manish Goregaokar-4/+10
diagnostics (for bare `::foo`)
2021-03-05Rollup merge of #80763 - petrochenkov:pubusecrate, r=estebankMara-12/+20
resolve: Reduce scope of `pub_use_of_private_extern_crate` deprecation lint This lint was deny-by-default since July 2017, crater showed 7 uses on crates.io back then (https://github.com/rust-lang/rust/pull/42894#issuecomment-311921147). Unfortunately, the construction `pub use foo as bar` where `foo` is `extern crate foo;` was used by an older version `bitflags`, so turning it into an error causes too many regressions. So, this PR reduces the scope of the lint instead of turning it into a hard error, and only turns some more rarely used components of it into errors.
2021-03-04Rollup merge of #82717 - estebank:issue-70152, r=lcnrYuki Okushi-8/+21
Account for macros when suggesting adding lifetime Fix #70152.
2021-03-03reworded messageEsteban Küber-4/+8
2021-03-02Account for macros when suggesting adding lifetimeEsteban Küber-8/+17
Fix #70152.
2021-03-02use outer_expn_data() instead of outer_expn().expn_data()klensy-1/+1
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-25Auto merge of #82447 - Amanieu:legacy_const_generics, r=oli-obkbors-2/+79
Add #[rustc_legacy_const_generics] This is the first step towards removing `#[rustc_args_required_const]`: a new attribute is added which rewrites function calls of the form `func(a, b, c)` to `func::<{b}>(a, c)`. This allows previously stabilized functions in `stdarch` which use `rustc_args_required_const` to use const generics instead. This new attribute is not intended to ever be stabilized, it is only intended for use in `stdarch` as a replacement for `#[rustc_args_required_const]`. ```rust #[rustc_legacy_const_generics(1)] pub fn foo<const Y: usize>(x: usize, z: usize) -> [usize; 3] { [x, Y, z] } fn main() { assert_eq!(foo(0 + 0, 1 + 1, 2 + 2), [0, 2, 4]); assert_eq!(foo::<{1 + 1}>(0 + 0, 2 + 2), [0, 2, 4]); } ``` r? `@oli-obk`
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-25Add a cache for rustc_legacy_const_genericsAmanieu d'Antras-14/+29
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