Commit Graph

1228 Commits

Author SHA1 Message Date
bors
8a73f50d87 Auto merge of #109019 - matthiaskrgr:rollup-ihjntil, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #104363 (Make `unused_allocation` lint against `Box::new` too)
 - #106633 (Stabilize `nonzero_min_max`)
 - #106844 (allow negative numeric literals in `concat!`)
 - #108071 (Implement goal caching with the new solver)
 - #108542 (Force parentheses around `match` expression in binary expression)
 - #108690 (Place size limits on query keys and values)
 - #108708 (Prevent overflow through Arc::downgrade)
 - #108739 (Prevent the `start_bx` basic block in codegen from having two `Builder`s at the same time)
 - #108806 (Querify register_tools and post-expansion early lints)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-11 18:15:53 +00:00
Matthias Krüger
df50001c7d
Rollup merge of #108806 - cjgillot:query-lints, r=davidtwco
Querify register_tools and post-expansion early lints

The 2 extra queries correspond to code that happen before and after macro expansion, and don't need the resolver to exist.
2023-03-11 15:43:15 +01:00
Adrian Heine
c84c5e6439 rustdoc: Don't crash on crate references in blocks
This is a regression from #94857.
2023-03-10 17:49:13 +01:00
Maybe Waffle
775bacd1b8 Simplify sort_by calls 2023-03-07 18:13:41 +00:00
Camille GILLOT
c90fc105cb Querify early_lint_checks. 2023-03-06 11:26:29 +00:00
Camille GILLOT
b7e2b049f3 Querify registered_tools. 2023-03-06 10:56:23 +00:00
bors
0d439f8181 Auto merge of #108351 - petrochenkov:rmdit, r=cjgillot
rustc_middle: Remove trait `DefIdTree`

This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-05 10:37:02 +00:00
est31
6df5ae4fb0 Match unmatched backticks in comments in compiler/ 2023-03-03 08:39:00 +01:00
est31
ff2c609d66 Match unmatched backticks in compiler/ that are part of rustdoc 2023-03-03 08:39:00 +01:00
Vadim Petrochenkov
c83553da31 rustc_middle: Remove trait DefIdTree
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-02 23:46:44 +04:00
bors
5157d938c4 Auto merge of #108098 - notriddle:notriddle/rustdoc-tooltip-alloc, r=GuillaumeGomez
rustdoc: reduce allocations when generating tooltips

An attempt to reduce the perf regression in
https://github.com/rust-lang/rust/pull/108052#issuecomment-1430631861
2023-02-28 07:27:32 +00:00
Matthias Krüger
a184150247
Rollup merge of #108533 - notriddle:notriddle/resolver-def-descr, r=compiler-errors
diagnostics: avoid querying `associated_item` in the resolver

Fixes #108529

CC #108324
2023-02-27 18:48:51 +01:00
Matthias Krüger
660f184966
Rollup merge of #108363 - cjgillot:unused-crate, r=WaffleLapkin
Move the unused extern crate check back to the resolver.

It doesn't have anything to do in `rustc_hir_typeck`.
2023-02-27 18:48:49 +01:00
Michael Howell
f058bb0fcf diagnostics: avoid querying associated_item in the resolver
Fixes #108529
2023-02-27 09:22:51 -07:00
Camille GILLOT
40bde9902c Address review. 2023-02-25 13:43:21 +00:00
Michael Howell
49d995a4cf rustdoc: reduce allocations when generating tooltips
An attempt to reduce the perf regression in
https://github.com/rust-lang/rust/pull/108052#issuecomment-1430631861
2023-02-22 21:00:10 -07:00
bors
0978711950 Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, 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-23 00:19:12 +00:00
Camille GILLOT
f38f3af22a Remove some resolver outputs. 2023-02-22 20:48:39 +00:00
Camille GILLOT
958419d354 Move the unused extern crate check back to the resolver. 2023-02-22 20:48:27 +00:00
Matthias Krüger
9f5c401f67
Rollup merge of #108353 - petrochenkov:rmir, r=cjgillot
resolve: Remove `ImportResolver`

It's a trivial wrapper over `Resolver` that doesn't bring any benefits
2023-02-22 20:06:00 +01:00
Vadim Petrochenkov
d275114bda resolve: Remove ImportResolver
It's a trivial wrapper over `Resolver` that doesn't bring any benefits
2023-02-22 21:29:38 +04:00
Michael Howell
3d056c3125 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.
2023-02-22 08:40:33 -07:00
bors
b869e84e58 Auto merge of #103042 - davidtwco:translation-distributed-ftl, r=oli-obk
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-22 15:14:22 +00:00
David Wood
d1fcf61117 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.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22 09:15:53 +00:00
bors
bd4a96a12d Auto merge of #108300 - oli-obk:elsa, r=eholk
Use a lock-free datastructure for source_span

follow up to the perf regression in https://github.com/rust-lang/rust/pull/105462

The main regression is likely the CStore, but let's evaluate the perf impact of this on its own
2023-02-22 08:44:30 +00:00
Oli Scherer
decfb4d123 Use a lock-free datastructure for source_span 2023-02-21 08:38:24 +00:00
Oli Scherer
a04e78730e Use source_span query instead of passing the untracked vec around 2023-02-21 08:29:55 +00:00
bors
3fee48c161 Auto merge of #104754 - nnethercote:more-ThinVec-in-ast, r=the8472
Use `ThinVec` more in the AST

r? `@ghost`
2023-02-21 07:02:57 +00:00
bors
2deff71719 Auto merge of #105462 - oli-obk:feeding_full, r=cjgillot,petrochenkov
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-21 01:19:25 +00:00
Nicholas Nethercote
06228d6e93 Upgrade thin-vec from 0.2.9 to 0.2.12.
Because 0.2.10 added supports for `ThinVec::splice`, and 0.2.12 is the
latest release.
2023-02-21 11:51:55 +11:00
Oli Scherer
0847b79ada Remove ResolverTree 2023-02-20 15:28:59 +00:00
Oli Scherer
2a47113efa Remove IntoDefIdTree 2023-02-20 15:28:59 +00:00
Oli Scherer
1ab14ea7c2 Remove some unnecessary tcx-passing 2023-02-20 15:28:59 +00:00
Oli Scherer
acbcfaaf7b Stop passing in values that one can also get from the tcx lazily 2023-02-20 15:28:59 +00:00
Oli Scherer
1202fce40e Remove definitions field that is only needed for one method 2023-02-20 15:28:59 +00:00
Oli Scherer
4953d70e2f Stuff a TyCtxt into the Resolver 2023-02-20 15:28:59 +00:00
Oli Scherer
9fb91b8742 Remove a redundant function argument 2023-02-20 15:28:58 +00:00
Oli Scherer
8f132d8549 Run the resolver after TyCtxt construction 2023-02-20 15:28:58 +00:00
Oli Scherer
6924e3c374 Make untracked.source_span lockable so that resolution can still write to it when using TyCtxt 2023-02-20 15:28:58 +00:00
Oli Scherer
ade3dceb38 Make untracked.cstore lockable so that resolution can still write to it when using TyCtxt 2023-02-20 15:28:58 +00:00
Matthias Krüger
133afeb6e3
Rollup merge of #108259 - fee1-dead-contrib:fixme-2, r=TaKO8Ki
remove FIXME that doesn't require fixing
2023-02-20 14:32:55 +01:00
Matthias Krüger
226ce31edd
Rollup merge of #108200 - jhpratt:restricted-damerau-levenshtein-distance, 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-20 14:32:55 +01:00
Oli Scherer
e8e227aec8 Prepare crate loader for LockGuard 2023-02-20 10:49:42 +00:00
Oli Scherer
d191de63f0 Prepare for adding a TyCtxt to Resolver 2023-02-20 10:38:48 +00:00
Deadbeef
be599f3cbe remove FIXME that doesn't require fixing 2023-02-20 06:31:26 +00:00
Guillaume Gomez
bd63edc07a
Rollup merge of #108129 - 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-19 14:47:55 +01:00
Dylan DPC
4a0f088f7c
Rollup merge of #107951 - petrochenkov:procmacdoc, r=jackh726
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-19 13:03:41 +05:30
Jacob Pratt
378c4ab9ab
Make public API, docs algorithm-agnostic 2023-02-19 04:11:10 +00:00
Guillaume Gomez
fd62036caa Correctly handle if a link starts with a whitespace 2023-02-18 23:24:58 +01:00
Vadim Petrochenkov
97e73eea84 doc links: Filter away autolinks in both rustc and rustdoc 2023-02-18 15:15:57 +04:00