about summary refs log tree commit diff
path: root/compiler/rustc_resolve
AgeCommit message (Collapse)AuthorLines
2021-04-17Auto merge of #84113 - SNCPlay42:suggestion-extern-crate, r=petrochenkovbors-11/+7
Detect when suggested paths enter extern crates more rigorously When reporting resolution errors, the compiler tries to avoid suggesting importing inaccessible paths from other crates. However, the search for suggestions only recognized when it was entering a crate root directly, and so failed to recognize a path like `crate::module::private_item`, where `module` was imported from another crate with `use other_crate::module`, as entering another crate. Fixes #80079 Fixes #84081
2021-04-16Rollup merge of #83944 - jackh726:binder-refactor-fix2, r=lcnrDylan DPC-1/+15
Fix a couple resolve bugs from binder refactor Fixes #83753 Fixes #83907
2021-04-12Rollup merge of #83669 - kwj2104:issue-81508-fix, r=varkorDylan DPC-3/+64
Issue 81508 fix Fix #81508 **Problem**: When variable name is used incorrectly as path, error and warning point to undeclared/unused name, when in fact the name is used, just incorrectly (should be used as a variable, not part of a path). **Summary for fix**: When path resolution errs, diagnostics checks for variables in ```ValueNS``` that have the same name (e.g., variable rather than path named Foo), and adds additional suggestion that user may actually intend to use the variable name rather than a path. The fix does not suppress or otherwise change the *warning* that results. I did not find a straightforward way in the code to modify this, but would love to make changes here as well with any guidance.
2021-04-11detect when suggested paths enter extern crates more rigorouslySNCPlay42-11/+7
2021-04-09Auto merge of #83870 - jackh726:binder-refactor-fix, r=nikomatsakisbors-61/+132
Don't concatenate binders across types Partially addresses #83737 There's actually two issues that I uncovered in #83737. The first is that we are concatenating bound vars across types, i.e. in ``` F: Fn(&()) -> &mut (dyn Future<Output = ()> + Unpin) ``` the bound vars on `Future` get set as `for<anon>` since those are the binders on `Fn(&()`. This is obviously wrong, since we should only concatenate directly nested trait refs. This is solved here by introducing a new `TraitRefBoundary` scope, that we put around the "syntactical" trait refs and basically don't allow concatenation across. Now, this alone *shouldn't* be a super terrible problem. At least not until you consider the other issue, which is a much more elusive and harder to design a "perfect" fix. A repro can be seen in: ``` use core::future::Future; async fn handle<F>(slf: &F) where F: Fn(&()) -> &mut (dyn for<'a> Future<Output = ()> + Unpin), { (slf)(&()).await; } ``` Notice the `for<'a>` around `Future`. Here, `'a` is unused, so the `for<'a>` Binder gets changed to a `for<>` Binder in the generator witness, but the "local decl" still has it. This has heavy intersections with region anonymization and erasing. Luckily, it's not *super* common to find this unique set of circumstances. It only became apparently because of the first issue mentioned here. However, this *is* still a problem, so I'm leaving #83737 open. r? `@nikomatsakis`
2021-04-08Rollup merge of #83980 - pierwill:fix-compiler-librustc-names, r=davidtwcoDylan DPC-1/+1
Fix outdated crate names in compiler docs Changes `librustc_X` to `rustc_X`, only in documentation comments. Plain code comments are left unchanged.
2021-04-08Fix outdated crate names in compiler docspierwill-1/+1
Changes `librustc_X` to `rustc_X`, only in documentation comments. Plain code comments are left unchanged. Also fix incorrect file paths.
2021-04-08add commentsNiko Matsakis-1/+23
2021-04-07Added additional comments and minor editsK-44/+62
2021-04-07Rollup merge of #83634 - JohnTitor:proc-macro-ice, r=varkorDylan DPC-1/+3
Do not emit the advanced diagnostics on macros Fixes #83510
2021-04-06Fix a couple resolve bugs from binder refactorJack Huey-1/+15
2021-04-05Use more appropriate return type for `resolve_associated_item`Joshua Nelson-0/+1
Previously, the types looked like this: - None means this is not an associated item (but may be a variant field) - Some(Err) means this is known to be an error. I think the only way that can happen is if it resolved and but you had your own anchor. - Some(Ok(_, None)) was impossible. Now, this returns a nested Option and does the error handling and fiddling with the side channel in the caller. As a side-effect, it also removes duplicate error handling. This has one small change in behavior, which is that `resolve_primitive_associated_item` now goes through `variant_field` if it fails to resolve something. This is not ideal, but since it will be quickly rejected anyway, I think the performance hit is worth the cleanup. This also fixes a bug where struct fields would forget to set the side channel, adds a test for the bug, and ignores `private_intra_doc_links` in rustc_resolve (since it's always documented with --document-private-items).
2021-04-05Don't concatenate binders across typesJack Huey-61/+110
2021-04-04resolve: Stable order for derive helper attributesVadim Petrochenkov-6/+9
2021-04-04resolve/expand: Cache intermediate results of `#[derive]` expansionVadim Petrochenkov-42/+60
2021-04-01Fixed diagnostic and added test for issue 81508Kevin Jiang-14/+57
2021-03-31Cleanups and commentsJack Huey-257/+211
2021-03-31Add var to BoundRegion. Add query to get bound vars for applicable items.Jack Huey-87/+635
2021-03-31Make late and late_anon regions track the bound var positionJack Huey-39/+75
2021-03-29Do not emit the advanced diagnostics on macrosJohnTitor-1/+3
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