about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2021-05-08Fix diagnostic for matching/creating x-crate re-exported tuple structs with ↵Luqman Aden-7/+14
private fields. The more helpful diagnostic already existed but wasn't working if the struct in question was a re-export from a different crate.
2021-05-07Fix suggestions for missing return type lifetime parametersFabian Wolff-150/+216
2021-05-07Fix impl type parameter suggestion involving constsmibac138-1/+8
2021-05-05Suggest adding a type parameter for implsmibac138-4/+6
2021-05-02add suggestion for unit enum variant when matched with a paternAliénore Bouttefeux-12/+31
2021-04-30Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkovbors-1/+34
Implement RFC 1260 with feature_name `imported_main`. This is the second extraction part of #84062 plus additional adjustments. This (mostly) implements RFC 1260. However there's still one test case failure in the extern crate case. Maybe `LocalDefId` doesn't work here? I'm not sure. cc https://github.com/rust-lang/rust/issues/28937 r? `@petrochenkov`
2021-04-29make feature recommendations optionallcnr-1/+7
2021-04-29Implement RFC 1260 with feature_name `imported_main`.Charles Lew-1/+34
2021-04-28Auto merge of #83713 - spastorino:revert-pub-macro-rules, r=nikomatsakisbors-7/+2
Revert "Rollup merge of #82296 - spastorino:pubrules, r=nikomatsakis" This reverts commit e2561c58a41023a14e0e583113dcf55e1ecb236a, reversing changes made to 2982ba50fc4bb629b8fe4108a81cb2f9b053510b. As discussed in #83641 this feature is not complete and in particular doesn't work cross macros and given that this is not going to be included in edition 2021 nobody seems to be trying to fix the underlying problem. When can add this again I guess, whenever somebody has the time to make it work cross crates. r? `@nikomatsakis`
2021-04-25Auto merge of #84299 - lcnr:const-generics-defaults-name-res, r=varkorbors-90/+48
various const parameter defaults improvements Actually resolve names in const parameter defaults, fixing `struct Foo<const N: usize = { usize::MAX }>`. --- Split generic parameter ban rib for types and consts, allowing ```rust #![feature(const_generics_defaults)] struct Q; struct Foo<T = Q, const Q: usize = 3>(T); ``` --- Remove the type/const ordering restriction if `const_generics_defaults` is active, even if `const_generics` is not. allowing us to stabilize and test const param defaults separately. --- Check well formedness of const parameter defaults, eagerly emitting an error for `struct Foo<const N: usize = { 0 - 1 }>` --- Do not forbid const parameters in param defaults, allowing `struct Foo<const N: usize, T = [u8; N]>(T)` and `struct Foo<const N: usize, const M: usize = N>`. Note that this should not change anything which is stabilized, as on stable, type parameters must be in front of const parameters, which means that type parameter defaults are only allowed if no const parameters exist. We still forbid generic parameters inside of const param types. r? `@varkor` `@petrochenkov`
2021-04-23Auto merge of #83729 - JohnTitor:issue-43913, r=estebankbors-1/+8
Add a suggestion when using a type alias instead of trait alias Fixes #43913 r? `@estebank`
2021-04-23Revert "Rollup merge of #82296 - spastorino:pubrules, r=nikomatsakis"Santiago Pastorino-7/+2
This reverts commit e2561c58a41023a14e0e583113dcf55e1ecb236a, reversing changes made to 2982ba50fc4bb629b8fe4108a81cb2f9b053510b.
2021-04-21More review changesJack Huey-85/+59
2021-04-21Review commentsJack Huey-7/+8
2021-04-21fix name resolution for param defaultslcnr-90/+48
2021-04-21Move nested quantification check to ast_validationJack Huey-66/+14
2021-04-20Remove TraitRefHackInner and use the concatenating functionality instead of ↵Jack Huey-245/+176
trait_ref_hack
2021-04-20Add BinderScopeType to replace binder_depth and from_poly_trait_refJack Huey-111/+86
2021-04-20A non-minimal set of TraitRefBoundarys to work on removing from_poly_trait_refJack Huey-84/+93
2021-04-20Precompute inverse binder depthJack Huey-104/+73
2021-04-19fix few typosklensy-2/+2
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-04-01Add a suggestion when using a type alias instead of trait aliasYuki Okushi-1/+8
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