summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2022-10-29Only ban duplication across parameters.Camille GILLOT-0/+1
2022-09-15Only enable the let_else feature on bootstrapest31-1/+1
On later stages, the feature is already stable. Result of running: rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-08Rollup merge of #101545 - TaKO8Ki:remove-unnecessary-partialord-ord, r=oli-obkDylan DPC-21/+2
Remove unnecessary `PartialOrd` and `Ord`
2022-09-08remove unnecessary `PartialOrd` and `Ord`Takayuki Maeda-21/+2
2022-09-07rustc: Parameterize `ty::Visibility` over used IDVadim Petrochenkov-7/+9
It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
2022-09-05Remove generics_def_id_map from the resolver.Camille GILLOT-8/+0
2022-09-02Rollup merge of #100147 - Bryanskiy:private-in-public, r=petrochenkovGuillaume Gomez-0/+18
optimization of access level table construction Refactoring which was mentioned in #87487
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+0
by module
2022-08-31access_levels.rs refactorBryanskiy-0/+18
2022-08-31Fix a bunch of typoDezhi Wu-1/+1
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-30Auto merge of #101183 - Dylan-DPC:rollup-6kewixv, r=Dylan-DPCbors-5/+1
Rollup of 9 pull requests Successful merges: - #95376 (Add `vec::Drain{,Filter}::keep_rest`) - #100092 (Fall back when relating two opaques by substs in MIR typeck) - #101019 (Suggest returning closure as `impl Fn`) - #101022 (Erase late bound regions before comparing types in `suggest_dereferences`) - #101101 (interpret: make read-pointer-as-bytes a CTFE-only error with extra information) - #101123 (Remove `register_attr` feature) - #101175 (Don't --bless in pre-push hook) - #101176 (rustdoc: remove unused CSS selectors for `.table-display`) - #101180 (Add another MaybeUninit array test with const) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-29Revert let_chains stabilizationNilstrieb-0/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. This is the revert against master, the beta revert was already done in #100538.
2022-08-28Remove `register_attr` featureYuki Okushi-5/+1
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-08-23Improve local generic parameter suggestions.Camille GILLOT-0/+10
2022-08-12Adjust cfgsMark Rousskov-1/+0
2022-08-04Add docs to generics_def_id_mapSantiago Pastorino-1/+4
2022-08-04Implement def_id based remappingSantiago Pastorino-0/+5
2022-07-26Rollup merge of #99729 - cjgillot:rm-unused-tuple, r=michaelwoeristerMatthias Krüger-3/+3
Remove unused tuple fields Found by https://github.com/rust-lang/rust/pull/95977
2022-07-25Unused tuple fields in rustc_resolve.Camille GILLOT-3/+3
2022-07-25Report elision failures on the AST.Camille GILLOT-0/+1
2022-07-16Stabilize `let_chains`Caio-1/+1
2022-07-08Check if E0530 is `rustc_resolve::late::PatternSource::Match` to emit suggestionObei Sideg-2/+2
2022-07-08Check if E0530 is `tuple variant` or `tuple struct` to emit suggestionObei Sideg-1/+1
2022-07-01update cfg(bootstrap)sPietro Albini-1/+0
2022-06-17Auto merge of #98106 - cjgillot:split-definitions, r=michaelwoeristerbors-93/+92
Split up `Definitions` and `ResolverAstLowering`. Split off https://github.com/rust-lang/rust/pull/95573 r? `@michaelwoerister`
2022-06-15Consume resolutions for lowering separately.Camille GILLOT-4/+12
2022-06-15Remove unused item_generics_num_lifetimes.Camille GILLOT-2/+0
2022-06-14Separate `source_span` and `expn_that_defined` from `Definitions`.Camille GILLOT-4/+35
2022-06-14Make ResolverAstLowering a struct.Camille GILLOT-78/+39
2022-06-14Separate Definitions and CrateStore from ResolverOutputs.Camille GILLOT-12/+13
2022-06-15implement `MacroData`Takayuki Maeda-2/+8
2022-06-07Auto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakisbors-1/+1
Remove migrate borrowck mode Closes #58781 Closes #43234 # Stabilization proposal This PR proposes the stabilization of `#![feature(nll)]` and the removal of `-Z borrowck`. Current borrow checking behavior of item bodies is currently done by first infering regions *lexically* and reporting any errors during HIR type checking. If there *are* any errors, then MIR borrowck (NLL) never occurs. If there *aren't* any errors, then MIR borrowck happens and any errors there would be reported. This PR removes the lexical region check of item bodies entirely and only uses MIR borrowck. Because MIR borrowck could never *not* be run for a compiled program, this should not break any programs. It does, however, change diagnostics significantly and allows a slightly larger set of programs to compile. Tracking issue: #43234 RFC: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md Version: 1.63 (2022-06-30 => beta, 2022-08-11 => stable). ## Motivation Over time, the Rust borrow checker has become "smarter" and thus allowed more programs to compile. There have been three different implementations: AST borrowck, MIR borrowck, and polonius (well, in progress). Additionally, there is the "lexical region resolver", which (roughly) solves the constraints generated through HIR typeck. It is not a full borrow checker, but does emit some errors. The AST borrowck was the original implementation of the borrow checker and was part of the initially stabilized Rust 1.0. In mid 2017, work began to implement the current MIR borrow checker and that effort ompleted by the end of 2017, for the most part. During 2018, efforts were made to migrate away from the AST borrow checker to the MIR borrow checker - eventually culminating into "migrate" mode - where HIR typeck with lexical region resolving following by MIR borrow checking - being active by default in the 2018 edition. In early 2019, migrate mode was turned on by default in the 2015 edition as well, but with MIR borrowck errors emitted as warnings. By late 2019, these warnings were upgraded to full errors. This was followed by the complete removal of the AST borrow checker. In the period since, various errors emitted by the MIR borrow checker have been improved to the point that they are mostly the same or better than those emitted by the lexical region resolver. While there do remain some degradations in errors (tracked under the [NLL-diagnostics tag](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-diagnostics), those are sufficiently small and rare enough that increased flexibility of MIR borrow check-only is now a worthwhile tradeoff. ## What is stabilized As said previously, this does not fundamentally change the landscape of accepted programs. However, there are a [few](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-fixed-by-NLL) cases where programs can compile under `feature(nll)`, but not otherwise. There are two notable patterns that are "fixed" by this stabilization. First, the `scoped_threads` feature, which is a continutation of a pre-1.0 API, can sometimes emit a [weird lifetime error](https://github.com/rust-lang/rust/issues/95527) without NLL. Second, actually seen in the standard library. In the `Extend` impl for `HashMap`, there is an implied bound of `K: 'a` that is available with NLL on but not without - this is utilized in the impl. As mentioned before, there are a large number of diagnostic differences. Most of them are better, but some are worse. None are serious or happen often enough to need to block this PR. The biggest change is the loss of error code for a number of lifetime errors in favor of more general "lifetime may not live long enough" error. While this may *seem* bad, the former error codes were just attempts to somewhat-arbitrarily bin together lifetime errors of the same type; however, on paper, they end up being roughly the same with roughly the same kinds of solutions. ## What isn't stabilized This PR does not completely remove the lexical region resolver. In the future, it may be possible to remove that (while still keeping HIR typeck) or to remove it together with HIR typeck. ## Tests Many test outputs get updated by this PR. However, there are number of tests specifically geared towards NLL under `src/test/ui/nll` ## History * On 2017-07-14, [tracking issue opened](https://github.com/rust-lang/rust/issues/43234) * On 2017-07-20, [initial empty MIR pass added](https://github.com/rust-lang/rust/pull/43271) * On 2017-08-29, [RFC opened](https://github.com/rust-lang/rfcs/pull/2094) * On 2017-11-16, [Integrate MIR type-checker with NLL](https://github.com/rust-lang/rust/pull/45825) * On 2017-12-20, [NLL feature complete](https://github.com/rust-lang/rust/pull/46862) * On 2018-07-07, [Don't run AST borrowck on mir mode](https://github.com/rust-lang/rust/pull/52083) * On 2018-07-27, [Add migrate mode](https://github.com/rust-lang/rust/pull/52681) * On 2019-04-22, [Enable migrate mode on 2015 edition](https://github.com/rust-lang/rust/pull/59114) * On 2019-08-26, [Don't downgrade errors on 2015 edition](https://github.com/rust-lang/rust/pull/64221) * On 2019-08-27, [Remove AST borrowck](https://github.com/rust-lang/rust/pull/64790)
2022-06-04Iterate over `maybe_unused_trait_imports` when checking dead trait importsElliot Roberts-2/+2
2022-06-03Fully stabilize NLLJack Huey-1/+1
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-1/+0
2022-05-13resolve: Move collection of all `macro_rules` in the crate to rustdocVadim Petrochenkov-11/+7
2022-05-12Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkovbors-0/+2
Implement a lint to warn about unused macro rules This implements a new lint to warn about unused macro rules (arms/matchers), similar to the `unused_macros` lint added by #41907 that warns about entire macros. ```rust macro_rules! unused_empty { (hello) => { println!("Hello, world!") }; () => { println!("empty") }; //~ ERROR: 1st rule of macro `unused_empty` is never used } fn main() { unused_empty!(hello); } ``` Builds upon #96149 and #96156. Fixes #73576
2022-05-05Implement the unused_macro_rules lintest31-0/+2
2022-05-04Stabilize `bool::then_some`Josh Triplett-1/+0
2022-05-03When suggesting to import an item, also suggest changing the path if appropriateEsteban Küber-0/+3
When we don't find an item we search all of them for an appropriate import and suggest `use`ing it. This is sometimes done for expressions that have paths with more than one segment. We now also suggest changing that path to work with the `use`. Fix #95413
2022-05-02Auto merge of #96431 - petrochenkov:parent, r=cjgillotbors-1/+2
rustc: Panic by default in `DefIdTree::parent` Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-05-02rustc: Panic by default in `DefIdTree::parent`Vadim Petrochenkov-1/+2
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-05-01Auto merge of #96521 - petrochenkov:docrules, r=notriddle,GuillaumeGomezbors-12/+15
rustdoc: Resolve doc links referring to `macro_rules` items cc https://github.com/rust-lang/rust/issues/81633 UPD: the fallback to considering *all* `macro_rules` in the crate for unresolved names is not removed in this PR, it will be removed separately and will be run through crater.
2022-05-01resolve: Merge `last_import_segment` into `Finalize`Vadim Petrochenkov-2/+5
2022-05-01resolve: Turn `enum Finalize` into an optional structVadim Petrochenkov-31/+13
2022-05-01rustdoc: Track `macro_rules` scopes during early doc link resolutionVadim Petrochenkov-1/+9
This way links referring to `macro_rules` items are resolved correctly
2022-04-30rustdoc: Keep full `ParentScope` during early doc link resolutionVadim Petrochenkov-11/+6
2022-04-30When encountering a binding that could be a const or unit variant, suggest ↵Esteban Kuber-4/+4
the right path
2022-04-27Auto merge of #91557 - cjgillot:ast-lifetimes-named, r=petrochenkovbors-1/+15
Perform lifetime resolution on the AST for lowering Lifetime resolution is currently implemented several times. Once during lowering in order to introduce in-band lifetimes, and once in the resolve_lifetimes query. However, due to the global nature of lifetime resolution and how it interferes with hygiene, it is better suited on the AST. This PR implements a first draft of lifetime resolution on the AST. For now, we specifically target named lifetimes and everything we need to remove lifetime resolution from lowering. Some diagnostics have already been ported, and sometimes made more precise using available hygiene information. Follow-up PRs will address in particular the resolution of anonymous lifetimes on the AST. We reuse the rib design of the current resolution framework. Specific `LifetimeRib` and `LifetimeRibKind` types are introduced. The most important variant is `LifetimeRibKind::Generics`, which happens each time we encounter something which may introduce generic lifetime parameters. It can be an item or a `for<...>` binder. The `LifetimeBinderKind` specifies how this rib behaves with respect to in-band lifetimes. r? `@petrochenkov`
2022-04-27Collect extra lifetime parameters during late resolution.Camille GILLOT-0/+7