about summary refs log tree commit diff
path: root/compiler/rustc_resolve
AgeCommit message (Collapse)AuthorLines
2021-03-27Auto merge of #83103 - petrochenkov:unilex, r=Aaron1011bors-138/+87
resolve: Partially unify early and late scope-relative identifier resolution Reuse `early_resolve_ident_in_lexical_scope` instead of a chunk of code in `resolve_ident_in_lexical_scope` doing the same job. `early_resolve_ident_in_lexical_scope`/`visit_scopes` had to be slightly extended to be able to 1) start from a specific module instead of the current parent scope and 2) report one deprecation lint. `early_resolve_ident_in_lexical_scope` still doesn't support walking through "ribs", that part is left in `resolve_ident_in_lexical_scope` (moreover, I'm pretty sure it's buggy, but that's a separate issue, cc https://github.com/rust-lang/rust/issues/52389 at least).
2021-03-27resolve: Partially unify early and late scope-relative ident resolutionVadim Petrochenkov-138/+87
2021-03-27Rollup merge of #82917 - cuviper:iter-zip, r=m-ou-seDylan DPC-3/+4
Add function core::iter::zip This makes it a little easier to `zip` iterators: ```rust for (x, y) in zip(xs, ys) {} // vs. for (x, y) in xs.into_iter().zip(ys) {} ``` You can `zip(&mut xs, &ys)` for the conventional `iter_mut()` and `iter()`, respectively. This can also support arbitrary nesting, where it's easier to see the item layout than with arbitrary `zip` chains: ```rust for ((x, y), z) in zip(zip(xs, ys), zs) {} for (x, (y, z)) in zip(xs, zip(ys, zs)) {} // vs. for ((x, y), z) in xs.into_iter().zip(ys).zip(xz) {} for (x, (y, z)) in xs.into_iter().zip((ys.into_iter().zip(xz)) {} ``` It may also format more nicely, especially when the first iterator is a longer chain of methods -- for example: ```rust iter::zip( trait_ref.substs.types().skip(1), impl_trait_ref.substs.types().skip(1), ) // vs. trait_ref .substs .types() .skip(1) .zip(impl_trait_ref.substs.types().skip(1)) ``` This replaces the tuple-pair `IntoIterator` in #78204. There is prior art for the utility of this in [`itertools::zip`]. [`itertools::zip`]: https://docs.rs/itertools/0.10.0/itertools/fn.zip.html
2021-03-28Rollup merge of #83526 - klensy:lazy-too, r=petrochenkovYuki Okushi-6/+6
lazily calls some fns Replaced some fn's with it's lazy variants.
2021-03-27lazily calls some fnsklensy-6/+6
2021-03-26Auto merge of #83488 - Aaron1011:ban-expr-inner-attrs, r=petrochenkovbors-6/+15
Ban custom inner attributes in expressions and statements Split out from https://github.com/rust-lang/rust/pull/82608 Custom inner attributes are unstable, so this won't break any stable users. This allows us to speed up token collection, and avoid a redundant call to `collect_tokens_no_attrs` when parsing an `Expr` that has outer attributes. r? `@petrochenkov`
2021-03-26Use iter::zip in compiler/Josh Stone-3/+4
2021-03-25Ban custom inner attributes in expressions and statementsAaron Hill-6/+15
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-23progress, stuff compiles nowlcnr-2/+2
2021-03-23Some refactoringvarkor-21/+25
2021-03-23Add has_default to GenericParamDefKind::Constkadmin-1/+4
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-22Auto merge of #79278 - mark-i-m:stabilize-or-pattern, r=nikomatsakisbors-1/+1
Stabilize or_patterns (RFC 2535, 2530, 2175) closes #54883 This PR stabilizes the or_patterns feature in Rust 1.53. This is blocked on the following (in order): - [x] The crater run in https://github.com/rust-lang/rust/pull/78935#issuecomment-731564021 - [x] The resolution of the unresolved questions and a second crater run (https://github.com/rust-lang/rust/pull/78935#issuecomment-735412705) - It looks like we will need to pursue some sort of edition-based transition for `:pat`. - [x] Nomination and discussion by T-lang - [x] Implement new behavior for `:pat` based on consensus (https://github.com/rust-lang/rust/pull/80100). - [ ] An FCP on stabilization EDIT: Stabilization report is in https://github.com/rust-lang/rust/pull/79278#issuecomment-772815177
2021-03-21Fix ICE with `use clippy::a::b;`Camelid-2/+2
2021-03-19stabilize or_patternsmark-1/+1
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