about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2022-06-21This comment is out dated and misleadingSantiago Pastorino-3/+0
Arms are about TAIT and RPIT, as the variants clearly show.
2022-06-20Provide a segment res in more casesMichael Goulet-0/+1
2022-06-20Rollup merge of #98267 - compiler-errors:suggest-wildcard-arm, r=oli-obkMatthias Krüger-1/+1
Don't omit comma when suggesting wildcard arm after macro expr * Also adds `Span::eq_ctxt` to consolidate the various usages of `span.ctxt() == other.ctxt()` * Also fixes an unhygenic usage of spans which caused the suggestion to render weirdly when we had one arm match in a macro * Also always suggests a comma (i.e. even after a block) if we're rendering a wildcard arm in a single-line match (looks prettier :rose:) Fixes #94866
2022-06-19Don't suggest adding Self as a type parameterMichael Goulet-1/+1
2022-06-19Mention what item is using an invalid `Self` typeMichael Goulet-0/+21
2022-06-19Use `Span::eq_ctxt` method instead of `.ctxt() == .ctxt()`Michael Goulet-1/+1
2022-06-19Leave the responsibility to create `Fresh` lifetimes to lowering.Camille GILLOT-23/+11
2022-06-19Make matches exhaustive.Camille GILLOT-3/+9
2022-06-19Remove the `region` terminology.Camille GILLOT-9/+9
2022-06-18Separate `AnonymousCreateParameter` and `ReportElidedInPath`.Camille GILLOT-62/+93
2022-06-18Refactor visit_fn.Camille GILLOT-65/+96
2022-06-18Rustfmt resolve_implementation.Camille GILLOT-39/+57
2022-06-18Extract AssocItem handling.Camille GILLOT-166/+131
2022-06-17Auto merge of #98106 - cjgillot:split-definitions, r=michaelwoeristerbors-116/+106
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-15Rollup merge of #98087 - TaKO8Ki:suggest-adding-macro-export, r=oli-obkYuki Okushi-25/+55
Suggest adding a `#[macro_export]` to a private macro fixes #97628
2022-06-15Rollup merge of #97822 - compiler-errors:hesitate-to-suggest-intrinsics, ↵Yuki Okushi-1/+13
r=oli-obk Filter out intrinsics if we have other import candidates to suggest Fixes #97618 Also open to just sorting these candidates to be last. Pretty easy to modify the code to do that, too.
2022-06-15box `diagnostic_metadata` fieldTakayuki Maeda-2/+2
2022-06-14Separate `source_span` and `expn_that_defined` from `Definitions`.Camille GILLOT-14/+46
2022-06-14Make ResolverAstLowering a struct.Camille GILLOT-91/+42
2022-06-14Separate Definitions and CrateStore from ResolverOutputs.Camille GILLOT-12/+13
2022-06-15implement `MacroData`Takayuki Maeda-28/+34
2022-06-14suggest adding a `#[macro_export]` to a private macroTakayuki Maeda-6/+30
2022-06-13remove unnecessary `to_string` and `String::new` for `tool_only_span_suggestion`Takayuki Maeda-7/+2
2022-06-13remove unnecessary `to_string` and `String::new`Takayuki Maeda-24/+19
2022-06-11Auto merge of #97903 - est31:unused_macro_rules_compile_error, r=petrochenkovbors-4/+4
Never regard macro rules with compile_error! invocations as unused The very point of compile_error! is to never be reached, and one of the use cases of the macro, currently also listed as examples in the documentation of compile_error, is to create nicer errors for wrong macro invocations. Thus, we should never warn about unused macro arms that contain invocations of compile_error. See also https://github.com/rust-lang/rust/pull/96150#issuecomment-1126599107 and the discussion after that. Furthermore, the PR also contains two commits to silence `unused_macro_rules` when a macro has an invalid rule, and to add a test that `unused_macros` does not behave badly in the same situation. r? `@petrochenkov` as I've talked to them about this
2022-06-11Rollup merge of #97812 - TaKO8Ki:suggest-to-swap-struct-and-trait, r=estebankDylan DPC-1/+41
Suggest to swap a struct and a trait in trait impls closes #89590
2022-06-10Rollup merge of #97927 - cjgillot:issue-97836, r=petrochenkovYuki Okushi-1/+6
Do not introduce bindings for types and consts in HRTB. Fixes https://github.com/rust-lang/rust/issues/97836 r? `@petrochenkov`
2022-06-09Never regard macro rules with compile_error! invocations as unusedest31-4/+4
The very point of compile_error! is to never be reached, and one of the use cases of the macro, currently also listed as examples in the documentation of compile_error, is to create nicer errors for wrong macro invocations. Thus, we shuuld never warn about unused macro arms that contain invocations of compile_error.
2022-06-09Do not introduce bindings for types and consts in HRTB.Camille GILLOT-1/+6
2022-06-09move suggestions to its own methodTakayuki Maeda-19/+31
2022-06-07Don't suggest adding let in certain if conditionsMichael Goulet-7/+15
2022-06-07Filter out intrinsics if we have other import candidates to suggestMichael Goulet-1/+13
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-07suggest swapping a struct and a traitTakayuki Maeda-1/+29
fmt
2022-06-06Rollup merge of #97312 - cjgillot:no-path-in-scope, r=compiler-errorsDylan DPC-97/+8
Compute lifetimes in scope at diagnostic time The set of available lifetimes is currently computed during lifetime resolution on HIR. It is only used for one diagnostic. In this PR, HIR lifetime resolution just reports whether elided lifetimes are well-defined at the place of use. The diagnostic code is responsible for building a list of lifetime names if elision is not allowed. This will allow to remove lifetime resolution on HIR eventually.
2022-06-06Rollup merge of #97683 - cjgillot:no-apit-hrtb, r=nagisaMatthias Krüger-7/+64
Fail gracefully when encountering an HRTB in APIT. Fixes https://github.com/rust-lang/rust/issues/96954 ~The first commit will be merged as part of https://github.com/rust-lang/rust/pull/97415~
2022-06-05Auto merge of #97697 - WaffleLapkin:no_ref_vec, r=WaffleLapkinbors-6/+6
Replace `&Vec<_>`s with `&[_]`s It's generally preferable to use `&[_]` since it's one less indirection and it can be created from types other that `Vec`. I've left `&Vec` in some locals where it doesn't really matter, in cases where `TypeFoldable` is expected (`TypeFoldable: Clone` so slice can't implement it) and in cases where it's `&TypeAliasThatIsActiallyVec`. Nothing important, really, I was just a little annoyed by `visit_generic_param_vec` :D r? `@compiler-errors`
2022-06-05Rename `visit_generic_param{_slice => s}`Maybe Waffle-5/+5
2022-06-05Auto merge of #97391 - Urgau:cfg_accessible, r=petrochenkovbors-8/+15
Handle more cases in cfg_accessible This PR tries to handle more cases in the cfg_accessible implementation by only emitting a "not sure" error only if we have partially resolved a path. This PR also adds many tests for the "not sure" cases and for private items. r? `@petrochenkov`
2022-06-04Rollup merge of #97609 - Elliot-Roberts:unused-trait-refactor, r=cjgillotMatthias Krüger-2/+2
Iterate over `maybe_unused_trait_imports` when checking dead trait imports Closes #96873 r? `@cjgillot` Some questions, if you have time: - Is there a way to shorten the `rustc_data_structures::fx::FxIndexSet` path in the query declaration? I wasn't sure where to put a `use`. - Was returning by reference from the query the right choice here? - How would I go about evaluating the importance of the `is_dummy()` call in `check_crate`? I don't see failing tests when I comment it out. Should I just try to determine whether dummy spans can ever be put into `maybe_unused_trait_imports`? - Am I doing anything silly with the various ID types? - Is that `let-else` with `unreachable!()` bad? (i.e is there a better idiom? Would `panic!("<explanation>")` be better?) - If I want to evaluate the perf of using a `Vec` as mentioned in #96873, is the best way to use the CI or is it feasible locally? Thanks :)
2022-06-04Iterate over `maybe_unused_trait_imports` when checking dead trait importsElliot Roberts-2/+2
2022-06-04Completely remove LifetimeScopeForPath.Camille GILLOT-83/+5
2022-06-04Compute lifetimes in scope at diagnostic time.Camille GILLOT-22/+11
2022-06-03Fully stabilize NLLJack Huey-1/+1
2022-06-03Fail gracefully when encountering an HRTB in APIT.Camille GILLOT-7/+64
2022-06-03Replace `&Vec<_>`s with `&[_]`sMaybe Waffle-6/+6
2022-06-03Compute `is_late_bound` in a separate query.Camille GILLOT-68/+24
The computation is actually much simpler, and can be done by directly fetching the HIR for the `FnDecl` and its generics.
2022-06-03Manipulate lifetimes by LocalDefId for region resolution.Camille GILLOT-89/+87