about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2023-02-23Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, ↵bors-2/+2
r=compiler-errors,davidtwco,estebank,oli-obk diagnostics: if AssocFn has self argument, describe as method Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods. For anyone not sure why this is being done, see the Reference definitions of these terms in <https://doc.rust-lang.org/1.67.1/reference/items/associated-items.html#methods> > Associated functions whose first parameter is named `self` are called methods and may be invoked using the [method call operator](https://doc.rust-lang.org/1.67.1/reference/expressions/method-call-expr.html), for example, `x.foo()`, as well as the usual function call notation. In particular, while this means it's technically correct for rustc to refer to a method as an associated function (and there are a few cases where it'll still do so), rustc *must never* use the term "method" to refer to an associated function that does not have a `self` parameter.
2023-02-22Rollup merge of #108353 - petrochenkov:rmir, r=cjgillotMatthias Krüger-103/+87
resolve: Remove `ImportResolver` It's a trivial wrapper over `Resolver` that doesn't bring any benefits
2023-02-22resolve: Remove `ImportResolver`Vadim Petrochenkov-103/+87
It's a trivial wrapper over `Resolver` that doesn't bring any benefits
2023-02-22diagnostics: if AssocFn has self argument, describe as methodMichael Howell-2/+2
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods.
2023-02-22Auto merge of #103042 - davidtwco:translation-distributed-ftl, r=oli-obkbors-8/+13
errors: generate typed identifiers in each crate Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. There are advantages and disadvantages to this change.. #### Advantages - Changing a diagnostic now only recompiles the crate for that diagnostic and those crates that depend on it, rather than `rustc_error_messages` and all crates thereafter. - This approach can be used to support first-party crates that want to supply translatable diagnostics (e.g. `rust-lang/thorin` in https://github.com/rust-lang/rust/pull/102612#discussion_r985372582, cc `@JhonnyBillM)` - We can extend this a little so that tools built using rustc internals (like clippy or rustdoc) can add their own diagnostic resources (much more easily than those resources needing to be available to `rustc_error_messages`) #### Disadvantages - Crates can only refer to the diagnostic messages defined in the current crate (or those from dependencies), rather than all diagnostic messages. - `rustc_driver` (or some other crate we create for this purpose) has to directly depend on *everything* that has error messages. - It already transitively depended on all these crates. #### Pending work - [x] I don't know how to make `rustc_codegen_gcc`'s translated diagnostics work with this approach - because `rustc_driver` can't depend on that crate and so can't get its resources to provide to the diagnostic emission. I don't really know how the alternative codegen backends are actually wired up to the compiler at all. - [x] Update `triagebot.toml` to track the moved FTL files. r? `@compiler-errors` cc #100717
2023-02-22errors: generate typed identifiers in each crateDavid Wood-8/+13
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-21Use a lock-free datastructure for `source_span`Oli Scherer-1/+1
2023-02-21Use `source_span` query instead of passing the untracked vec aroundOli Scherer-23/+14
2023-02-21Auto merge of #105462 - oli-obk:feeding_full, r=cjgillot,petrochenkovbors-298/+308
give the resolver access to TyCtxt The resolver is now created after TyCtxt is created. Then macro expansion and name resolution are run and the results fed into queries just like before this PR. Since the resolver had (before this PR) mutable access to the `CStore` and the source span table, these two datastructures are now behind a `RwLock`. To ensure that these are not mutated anymore after the resolver is done, a read lock to them is leaked right after the resolver finishes. ### PRs split out of this one and leading up to it: * https://github.com/rust-lang/rust/pull/105423 * https://github.com/rust-lang/rust/pull/105357 * https://github.com/rust-lang/rust/pull/105603 * https://github.com/rust-lang/rust/pull/106776 * https://github.com/rust-lang/rust/pull/106810 * https://github.com/rust-lang/rust/pull/106812 * https://github.com/rust-lang/rust/pull/108032
2023-02-20Remove `ResolverTree`Oli Scherer-25/+4
2023-02-20Remove IntoDefIdTreeOli Scherer-12/+7
2023-02-20Remove some unnecessary tcx-passingOli Scherer-0/+4
2023-02-20Stop passing in values that one can also get from the tcx lazilyOli Scherer-15/+5
2023-02-20Remove definitions field that is only needed for one methodOli Scherer-2/+4
2023-02-20Stuff a TyCtxt into the ResolverOli Scherer-39/+31
2023-02-20Remove a redundant function argumentOli Scherer-6/+1
2023-02-20Run the resolver after TyCtxt constructionOli Scherer-17/+10
2023-02-20Make untracked.source_span lockable so that resolution can still write to it ↵Oli Scherer-8/+8
when using TyCtxt
2023-02-20Make untracked.cstore lockable so that resolution can still write to it when ↵Oli Scherer-14/+20
using TyCtxt
2023-02-20Rollup merge of #108259 - fee1-dead-contrib:fixme-2, r=TaKO8KiMatthias Krüger-3/+3
remove FIXME that doesn't require fixing
2023-02-20Rollup merge of #108200 - jhpratt:restricted-damerau-levenshtein-distance, ↵Matthias Krüger-5/+5
r=tmiasko Use restricted Damerau-Levenshtein distance for diagnostics This replaces the existing Levenshtein algorithm with the Damerau-Levenshtein algorithm. This means that "ab" to "ba" is one change (a transposition) instead of two (a deletion and insertion). More specifically, this is a _restricted_ implementation, in that "ca" to "abc" cannot be performed as "ca" → "ac" → "abc", as there is an insertion in the middle of a transposition. I believe that errors like that are sufficiently rare that it's not worth taking into account. This was first brought up [on IRLO](https://internals.rust-lang.org/t/18227) when it was noticed that the diagnostic for `prinltn!` (transposed L and T) was `print!` and not `println!`. Only a single existing UI test was effected, with the result being an objective improvement. ~~I have left the method name and various other references to the Levenshtein algorithm untouched, as the exact manner in which the edit distance is calculated should not be relevant to the caller.~~ r? ``@estebank`` ``@rustbot`` label +A-diagnostics +C-enhancement
2023-02-20Prepare crate loader for LockGuardOli Scherer-10/+11
2023-02-20Prepare for adding a `TyCtxt` to `Resolver`Oli Scherer-194/+247
2023-02-20remove FIXME that doesn't require fixingDeadbeef-3/+3
2023-02-19Rollup merge of #108129 - ↵Guillaume Gomez-0/+1
GuillaumeGomez:correctly-handle-links-starting-with-whitespace, r=petrochenkov Correctly handle links starting with whitespace Part of https://github.com/rust-lang/rust/issues/107995. I just got this issue, wrote a fix and then saw the issue. So here's the PR. ^^' r? `@petrochenkov`
2023-02-19Rollup merge of #107951 - petrochenkov:procmacdoc, r=jackh726Dylan DPC-1/+6
resolve: Fix doc links referring to other crates when documenting proc macro crates directly Fixes https://github.com/rust-lang/rust/issues/107950
2023-02-19Make public API, docs algorithm-agnosticJacob Pratt-5/+5
2023-02-18Correctly handle if a link starts with a whitespaceGuillaume Gomez-0/+1
2023-02-18doc links: Filter away autolinks in both rustc and rustdocVadim Petrochenkov-2/+19
2023-02-18rustdoc: Cleanup broken link callbacksVadim Petrochenkov-13/+10
2023-02-17Rollup merge of #107489 - compiler-errors:non_lifetime_binders, r=cjgillotMatthias Krüger-2/+8
Implement partial support for non-lifetime binders This implements support for non-lifetime binders. It's pretty useless currently, but I wanted to put this up so the implementation can be discussed. Specifically, this piggybacks off of the late-bound lifetime collection code in `rustc_hir_typeck::collect::lifetimes`. This seems like a necessary step given the fact we don't resolve late-bound regions until this point, and binders are sometimes merged. Q: I'm not sure if I should go along this route, or try to modify the earlier nameres code to compute the right bound var indices for type and const binders eagerly... If so, I'll need to rename all these queries to something more appropriate (I've done this for `resolve_lifetime::Region` -> `resolve_lifetime::ResolvedArg`) cc rust-lang/types-team#81 r? `@ghost`
2023-02-16Rollup merge of #108099 - matthiaskrgr:str_to_char, r=GuillaumeGomezMatthias Krüger-1/+1
use chars instead of strings where applicable
2023-02-16`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`Maybe Waffle-5/+3
2023-02-16Make things actually workMichael Goulet-1/+7
2023-02-16Rename some region-specific stuffMichael Goulet-2/+2
2023-02-15use chars instead of strings where applicableMatthias Krüger-1/+1
2023-02-15Auto merge of #108006 - cjgillot:def-impl, r=oli-obkbors-1/+1
Avoid accessing HIR when it can be avoided Experiment to see if it helps some incremental cases. Will be rebased once https://github.com/rust-lang/rust/pull/107942 gets merged. r? `@ghost`
2023-02-14Add `of_trait` to DefKind::Impl.Camille GILLOT-1/+1
2023-02-14Separate the lifetime of the session and the arena in the resolverOli Scherer-66/+69
2023-02-13resolve: Fix doc links referring to other crates when documenting proc macro ↵Vadim Petrochenkov-1/+6
crates directly
2023-02-13rustc_resolve: Remove `Resolver::clone_output`Vadim Petrochenkov-48/+1
And remove `Clone` impls and `Lrc`s that are no longer necessary
2023-02-13rustdoc: Eliminate remaining uses of resolverVadim Petrochenkov-51/+40
2023-02-11Auto merge of #94857 - petrochenkov:doclink2, r=oli-obkbors-34/+570
Resolve documentation links in rustc and store the results in metadata This PR implements MCP https://github.com/rust-lang/compiler-team/issues/584. Doc links are now resolved in rustc and stored into metadata, so rustdoc simply retrieves them through a query (local or extern), Code that is no longer used is removed, and some code that no longer needs to be public is privatized. The removed code includes resolver cloning, so this PR fixes https://github.com/rust-lang/rust/issues/83761.
2023-02-10Auto merge of #107652 - estebank:re_error, r=oli-obkbors-1/+0
Introduce `ReError` CC #69314 r? `@nagisa`
2023-02-10Skip doc link resolution for some crate types and non-exported itemsVadim Petrochenkov-14/+65
2023-02-10Stop resolving doc links on `mod` items twiceVadim Petrochenkov-2/+16
2023-02-10Resolve documentation links in rustc and store the results in metadataVadim Petrochenkov-31/+502
This commit implements MCP https://github.com/rust-lang/compiler-team/issues/584 It also removes code that is no longer used, and that includes code cloning resolver, so issue #83761 is fixed.
2023-02-09Introduce `ReError`Esteban Küber-1/+0
CC #69314
2023-02-03unused-lifetimes: don't warn about lifetimes originating from expanded codeMatthias Krüger-12/+16
previously, we would warn like this: ```` warning: lifetime parameter `'s` never used --> /tmp/unusedlif/code.rs:6:62 | 5 | #[derive(Clone)] | - help: elide the unused lifetime 6 | struct ShimMethod4<T: Trait2 + 'static>(pub &'static dyn for<'s> Fn(&'s mut T::As)); | ^^ | = note: requested on the command line with `-W unused-lifetimes` ```` Fixes #104432
2023-02-02Rename `rust_2015` => `is_rust_2015`Maybe Waffle-10/+13