Commit Graph

1460 Commits

Author SHA1 Message Date
Michael Goulet
6641b49cdd
Rollup merge of #111460 - clubby789:lowercase-box-self, r=compiler-errors
Improve suggestion for `self: Box<self>`

Fixes #110642
2023-05-11 17:43:09 -07:00
clubby789
3851a4bb91 Improve error for self: Box<self> 2023-05-11 13:21:10 +01:00
Bryanskiy
670f5b134e Populate effective visibilities in rustc_privacy 2023-05-11 14:51:01 +03:00
Camille GILLOT
a2fe9935ea Only warn single-use lifetime when the binders match. 2023-05-10 19:49:02 +00:00
bohan
7c1bc0353b refactor(resolve): clean up the early error return caused by non-call 2023-05-10 22:35:01 +08:00
Boxy
73b3ce26ec improve diagnostics and bless tests 2023-05-05 21:42:54 +01:00
Boxy
442617c046 misc nameres changes for anon consts 2023-05-05 21:31:35 +01:00
Matthias Krüger
8d66f01ab5
Rollup merge of #110982 - cjgillot:elided-self-const, r=petrochenkov
Do not recurse into const generic args when resolving self lifetime elision.

Fixes https://github.com/rust-lang/rust/issues/110899

r? `@petrochenkov`
2023-05-04 19:18:20 +02:00
Matthias Krüger
50754578f6
Rollup merge of #111070 - WaffleLapkin:break_ribs, r=lcnr
Don't suffix `RibKind` variants

This PR
- Removes `use RibKind::*`
- Renames `RibKind::{SomethingRibKind => Something}`

It seems unnecessary to have "RibKind" in the end of all variants, if we can just use it as a normal enum. Additionally previously it was weird that `MacroDefinition` is the only unsuffixed variant.
2023-05-04 08:09:06 +02:00
Matthias Krüger
1187ce7213
Rollup merge of #111020 - cjgillot:validate-self-ctor, r=petrochenkov
Validate resolution for SelfCtor too.

Fixes https://github.com/rust-lang/rust/issues/89868

r? `@petrochenkov`
2023-05-04 08:09:04 +02:00
Dylan DPC
0228994cdf
Rollup merge of #110908 - petrochenkov:notagain4, r=compiler-errors
resolve: One more attempt to simplify `module_children`

If the next step is performed and `fn module_children_local` is merged with the `module_children` query, then it causes perf regressions, regardless of whether query result feeding is [used](https://perf.rust-lang.org/compare.html?start=43a78029b4f4d92978b8fde0a677ea300b113c41&end=2eb5bcc5068b9d92f74bcb1797da664865d6981d&stat=instructions:u) or [not](https://perf.rust-lang.org/compare.html?start=2fce2290865f012391b8f3e581c3852a248031fa&end=2a33d6cd99481d1712037a79e7d66a8aefadbf72&stat=instructions:u).
2023-05-04 00:17:24 +05:30
Camille GILLOT
8972a23f48 Do not recurse into const generic args when resolving self lifetime elision. 2023-05-03 18:07:53 +00:00
Camille GILLOT
83453408a0 Validate resolution for SelfCtor too. 2023-05-03 17:55:27 +00:00
Nicholas Nethercote
6b62f37402 Restrict From<S> for {D,Subd}iagnosticMessage.
Currently a `{D,Subd}iagnosticMessage` can be created from any type that
impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static,
str>`, which are reasonable. It also includes `&String`, which is pretty
weird, and results in many places making unnecessary allocations for
patterns like this:
```
self.fatal(&format!(...))
```
This creates a string with `format!`, takes a reference, passes the
reference to `fatal`, which does an `into()`, which clones the
reference, doing a second allocation. Two allocations for a single
string, bleh.

This commit changes the `From` impls so that you can only create a
`{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static,
str>`. This requires changing all the places that currently create one
from a `&String`. Most of these are of the `&format!(...)` form
described above; each one removes an unnecessary static `&`, plus an
allocation when executed. There are also a few places where the existing
use of `&String` was more reasonable; these now just use `clone()` at
the call site.

As well as making the code nicer and more efficient, this is a step
towards possibly using `Cow<'static, str>` in
`{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing
the `From<&'a str>` impls to `From<&'static str>`, which is doable, but
I'm not yet sure if it's worthwhile.
2023-05-03 08:44:39 +10:00
Vadim Petrochenkov
ef77dd232d resolve: One more attempt to simplify module_children 2023-05-02 17:21:08 +03:00
Maybe Waffle
0fa59204e5 Remove "RibKind" suffix from RibKind variants 2023-05-01 15:54:48 +00:00
Maybe Waffle
6197e4d209 Don't use RibKind::* 2023-05-01 15:52:23 +00:00
yukang
f54489978d fix tests 2023-05-01 16:15:17 +08:00
yukang
1b08eaca20 clean up debug code 2023-05-01 16:15:17 +08:00
yukang
10512b2932 remove current_type_ascription from DiagnosticMetadata 2023-05-01 16:15:17 +08:00
yukang
f65b875e83 remove type_ascription_path_suggestions in parser 2023-05-01 16:15:16 +08:00
yukang
9569a0129c Remove more diagnostics for ascription in resolve 2023-05-01 16:15:16 +08:00
Nilstrieb
c63b6a437e Rip it out
My type ascription
Oh rip it out
Ah
If you think we live too much then
You can sacrifice diagnostics
Don't mix your garbage
Into my syntax
So many weird hacks keep diagnostics alive
Yet I don't even step outside
So many bad diagnostics keep tyasc alive
Yet tyasc doesn't even bother to survive!
2023-05-01 16:15:13 +08:00
Matthias Krüger
a656a2019a
Rollup merge of #110984 - cjgillot:const-infer-lifetime, r=compiler-errors
Do not resolve anonymous lifetimes in consts to be static.

Fixes https://github.com/rust-lang/rust/issues/110931
2023-04-30 01:14:59 +02:00
Camille GILLOT
63028ac3a1 Do not force anonymous lifetimes in consts to be static. 2023-04-29 10:32:31 +00:00
Michael Goulet
4e05cfb5ff Don't duplicate anonymous lifetimes for async fn in traits 2023-04-28 20:21:03 +00:00
clubby789
0138513635 Fix static string lints 2023-04-25 18:59:55 +01:00
Maybe Waffle
e496fbec92 Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
Matthias Krüger
0f271619e4
Rollup merge of #110255 - clubby789:proc-macro-test-help, r=jackh726
Suggest using integration tests for test crate using own proc-macro

cc #110247
2023-04-24 07:53:23 +02:00
bors
fec9adcdbc Auto merge of #110648 - Dylan-DPC:rollup-em3ovcq, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #110333 (rustc_metadata: Split `children` into multiple tables)
 - #110501 (rustdoc: fix ICE from rustc_resolve and librustdoc parse divergence)
 - #110608 (Specialize some `io::Read` and `io::Write` methods for `VecDeque<u8>` and `&[u8]`)
 - #110632 (Panic instead of truncating if the incremental on-disk cache is too big)
 - #110633 (More `mem::take` in `library`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-21 19:43:11 +00:00
Dylan DPC
fbc905e16a
Rollup merge of #110501 - notriddle:notriddle/ice-110495, r=petrochenkov
rustdoc: fix ICE from rustc_resolve and librustdoc parse divergence

Fixes #110495
2023-04-21 20:35:28 +05:30
Vadim Petrochenkov
53c71b6ab3 resolve: Remove module_children_untracked 2023-04-19 16:35:08 +03:00
bors
d7f9e81650 Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco
Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`

Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-19 08:26:47 +00:00
bors
c609da59d9 Auto merge of #109772 - petrochenkov:slimchild, r=cjgillot
rustc_metadata: Remove `Span` from `ModChild`

It can be decoded on demand from regular `def_span` tables.

Partially mitigates perf regressions from https://github.com/rust-lang/rust/pull/109500.
2023-04-18 20:16:56 +00:00
Michael Howell
df8a48fc8a rustdoc: fix ICE from rustc_resolve and librustdoc parse divergence 2023-04-18 12:22:13 -07:00
Nilstrieb
b5d3d970fa Add rustc_fluent_macro to decouple fluent from rustc_macros
Fluent, with all the icu4x it brings in, takes quite some time to
compile. `fluent_messages!` is only needed in further downstream rustc
crates, but is blocking more upstream crates like `rustc_index`. By
splitting it out, we allow `rustc_macros` to be compiled earlier, which
speeds up `x check compiler` by about 5 seconds (and even more after the
needless dependency on `serde_json` is removed from
`rustc_data_structures`).
2023-04-18 18:56:22 +00:00
Vadim Petrochenkov
ec8f68859a rustc_metadata: Remove Span from ModChild
It can be decoded on demand from regular `def_span` tables.

Partially mitigates perf regressions from #109500.
2023-04-18 17:25:04 +03:00
Josh Soref
e09d0d2a29 Spelling - compiler
* account
* achieved
* advising
* always
* ambiguous
* analysis
* annotations
* appropriate
* build
* candidates
* cascading
* category
* character
* clarification
* compound
* conceptually
* constituent
* consts
* convenience
* corresponds
* debruijn
* debug
* debugable
* debuggable
* deterministic
* discriminant
* display
* documentation
* doesn't
* ellipsis
* erroneous
* evaluability
* evaluate
* evaluation
* explicitly
* fallible
* fulfill
* getting
* has
* highlighting
* illustrative
* imported
* incompatible
* infringing
* initialized
* into
* intrinsic
* introduced
* javascript
* liveness
* metadata
* monomorphization
* nonexistent
* nontrivial
* obligation
* obligations
* offset
* opaque
* opportunities
* opt-in
* outlive
* overlapping
* paragraph
* parentheses
* poisson
* precisely
* predecessors
* predicates
* preexisting
* propagated
* really
* reentrant
* referent
* responsibility
* rustonomicon
* shortcircuit
* simplifiable
* simplifications
* specify
* stabilized
* structurally
* suggestibility
* translatable
* transmuting
* two
* unclosed
* uninhabited
* visibility
* volatile
* workaround

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-17 16:09:18 -04:00
clubby789
f7581d8d21 Suggest using integration tests for proc-macros 2023-04-17 13:01:03 +01:00
Matthias Krüger
1795bf8222
Rollup merge of #110404 - matthiaskrgr:mapmap, r=Nilstrieb
fix clippy::toplevel_ref_arg and ::manual_map

r? ``@Nilstrieb``
2023-04-17 08:09:40 +02:00
Matthias Krüger
543f8bc38c fix clippy::toplevel_ref_arg and ::manual_map 2023-04-16 13:28:13 +02:00
Matthias Krüger
bcc15bba95 use matches! macro in more places 2023-04-16 12:08:30 +02:00
bors
7a78c4ffd5 Auto merge of #110160 - petrochenkov:notagain2, r=cjgillot
resolve: Pre-compute non-reexport module children

Instead of repeating the same logic by walking HIR during metadata encoding.

The only difference is that we are no longer encoding `macro_rules` items, but we never currently need them as a part of this list. They can be encoded separately if this need ever arises.

`module_reexports` is also un-querified, because I don't see any reasons to make it a query, only overhead.
2023-04-14 01:14:36 +00:00
Matthias Krüger
a34bcd70b2
Rollup merge of #110203 - compiler-errors:rtn-dots, r=eholk
Remove `..` from return type notation

`@nikomatsakis` and I decided that using `..` in the return-type notation syntax is probably overkill.

r? `@eholk` since you reviewed the last one

Since this is piggybacking now totally off of a pre-existing syntax (parenthesized generics), let me know if you need any explanation of the logic here, since it's a bit more complicated now.
2023-04-12 20:56:22 +02:00
Matthias Krüger
331e7c3659
Rollup merge of #110153 - DaniPopes:compiler-typos, r=Nilstrieb
Fix typos in compiler

I ran [`typos -w compiler`](https://github.com/crate-ci/typos) to fix typos in the `compiler` directory.

Refs #110150
2023-04-12 20:56:21 +02:00
Vadim Petrochenkov
7c40a6fb34 resolve: Pre-compute non-reexport module children
Instead of repeating the same logic by walking HIR during metadata encoding.

The only difference is that we are no longer encoding `macro_rules` items, but we never currently need them as a part of this list.
They can be encoded separately if this need ever arises.

`module_reexports` is also un-querified, because I don't see any reasons to make it a query, only overhead.
2023-04-12 15:22:03 +03:00
Michael Goulet
24cbf81b85 Remove .. from return type notation 2023-04-10 22:19:46 +00:00
bors
194a0bb5d6 Auto merge of #109638 - NotStirred:suggest/non-derive, r=davidtwco
Add suggestion to remove `derive()` if invoked macro is non-derive

Adds to the existing `expected derive macro, found {}` error message:
```
help: remove the surrounding "derive()":
  --> $DIR/macro-path-prelude-fail-4.rs:1:3
   |
LL | #[derive(inline)]
   |   ^^^^^^^      ^
```

This suggestion will either fix the issue, in the case that the macro was valid, or provide a better error message if not

Not ready for merge yet, as the highlighted span is only valid for trivial formatting. Is there a nice way to get the parent span of the macro path within `smart_resolve_macro_path`?

Closes #109589
2023-04-10 21:50:46 +00:00
DaniPopes
677357d32b
Fix typos in compiler 2023-04-10 22:02:52 +02:00
Dylan DPC
97921abc06
Rollup merge of #110124 - Nilstrieb:📎-told-me-so, r=compiler-errors
Some clippy fixes in the compiler

Best reviewed commit-by-commit 📎.
2023-04-10 14:13:16 +05:30
Matthias Krüger
3dfda2c72f
Rollup merge of #109985 - blyxyas:is_test_crate, r=compiler-errors
Add little `is_test_crate` function

Ok, this is quite a story.
I'm mainly a Clippy contributor, so I was fixing [this Clippy issue](https://github.com/rust-lang/rust-clippy/pull/10584) about a lint having to ignore test modules but that wasn't ignoring test files (integration test, `test/` dirs and such).

As test **files** don't tend to have an inner `#[cfg(test)]` module inside them, I tried everything, looking for filenames, looking for item's parents in the HIR Map, doing black magic...

I even asked [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.E2.9C.94.20Checking.20if.20file.20is.20integration.20test), and jyn answered something about `--cfg test`. Aha! That's something that I might be looking for, so I started looking at `rustc_driver_impl` flag parsing and configuration and all that.

Then, I stumbled on [this function right here](2e486be8d2/compiler/rustc_driver_impl/src/lib.rs (L174-L181)), and noticed the argument `config: Config`. That's a hint.

So [Config](https://doc.rust-lang.org/beta/nightly-rustc/rustc_interface/interface/struct.Config.html) has the field `opts: Options`, and [`Options`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_session/options/struct.Options.html) has the field `test`.

This journey has been ~7 or 8 hours in 3 days, it's a very hard thing to find, so this PR adds a mini-function to check if the current crate is a testing one. So that no one has to travel through the same as me, and can just search for `is_test_crate` in the documentation.
2023-04-09 23:40:04 +02:00
Nilstrieb
9fc1555f74 Remove turbofish 2023-04-09 23:32:04 +02:00
Nilstrieb
f058d05fc2 Some simple clippy::perf fixes 2023-04-09 21:59:28 +02:00
blyxyas
2c976765b8
Migrate sess.opts.tests uses to sess.is_test_crate() 2023-04-09 21:37:31 +02:00
bors
7201301df6 Auto merge of #109500 - petrochenkov:modchainld, r=oli-obk
resolve: Preserve reexport chains in `ModChild`ren

This may be potentially useful for
- avoiding uses of `hir::ItemKind::Use` (which usually lead to correctness issues)
- preserving documentation comments on all reexports, including those from other crates
- preserving and checking stability/deprecation info on reexports
- all kinds of diagnostics

The second commit then migrates some hacky logic from rustdoc to `module_reexports` to make it simpler and more correct.
Ideally rustdoc should use `module_reexports` immediately at the top level, so `hir::ItemKind::Use`s are never used.
The second commit also fixes issues with https://github.com/rust-lang/rust/pull/109330 and therefore
Fixes https://github.com/rust-lang/rust/issues/109631
Fixes https://github.com/rust-lang/rust/issues/109614
Fixes https://github.com/rust-lang/rust/issues/109424
2023-04-09 13:05:56 +00:00
bors
56e0626836 Auto merge of #110041 - fmease:diag-sugg-adding-const-param, r=compiler-errors
Suggest defining const parameter when appropriate

Helps a bit with #91119.
Following #105523's lead, I use placeholder `/* Type */` instead of `_` in the suggestion.
It should be easier for newcomers to parse.

`@rustbot` label A-diagnostics
r? diagnostics
2023-04-09 10:54:04 +00:00
Vadim Petrochenkov
d11b9165ee resolve: Preserve reexport chains in ModChildren
This may be potentially useful for
- avoiding uses of `hir::ItemKind::Use`
- preserving documentation comments on all reexports
- preserving and checking stability/deprecation info on reexports
- all kinds of diagnostics
2023-04-08 13:29:15 +03:00
Tom Martin
668a62984a
Change type and field name to be clearer 2023-04-07 08:44:19 +01:00
Tom Martin
18388c9f73
Rewrite added diagnostics as translatable
Start messages with lowercase
2023-04-07 08:33:56 +01:00
León Orell Valerian Liehr
f2acafe9e2 suggest adding const param 2023-04-07 09:11:53 +02:00
Michael Goulet
d5b1ef1c3f Use smart-resolve when checking for trait in RHS of UFCS 2023-04-07 05:33:52 +00:00
Matthias Krüger
e70818983b
Rollup merge of #110013 - compiler-errors:non-exhaustive-privacy-reason, r=WaffleLapkin
Label `non_exhaustive` attribute on privacy errors from non-local items

Label when an ADT is `non_exhaustive` and we get a privacy error, help with confusion in a case like this:

```rust
#[non_exhaustive]
pub struct Foo;

// other crate
let x = Foo;
//~^ ERROR unit struct `Foo` is private
```
2023-04-07 00:00:25 +02:00
Tom Martin
be4416923d
Collapse if statements, change message to lowercase 2023-04-06 18:02:52 +01:00
Michael Goulet
8ed2dc0bce Make span a bit better 2023-04-06 16:52:17 +00:00
Michael Goulet
00d54c879b Label non_exhaustive on privacy errors 2023-04-06 16:49:43 +00:00
bors
8c7ad16e82 Auto merge of #109986 - JohnTitor:rollup-3aax38t, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #109909 (Deny `use`ing tool paths)
 - #109921 (Don't ICE when encountering `dyn*` in statics or consts)
 - #109922 (Disable `has_thread_local` on OpenHarmony)
 - #109926 (write threads info into log only when debugging)
 - #109968 (Add regression test for #80409)
 - #109969 (Add regression test for #86351)
 - #109973 (rustdoc: Improve logo display very small screen)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-05 23:10:09 +00:00
Yuki Okushi
ea920901e9
Rollup merge of #109909 - clubby789:import-tool-mod, r=petrochenkov
Deny `use`ing tool paths

Fixes #109853
Fixes #109147
2023-04-06 07:18:29 +09:00
bors
2eaeb1eee1 Auto merge of #109437 - petrochenkov:effvisopt, r=davidtwco
resolve: Restore some effective visibility optimizations

Something similar was previously removed as a part of https://github.com/rust-lang/rust/pull/104602.
So we can see [bitmaps-3.1.0](https://github.com/rust-lang/rustc-perf/tree/master/collector/compile-benchmarks/bitmaps-3.1.0), [match-stress](https://github.com/rust-lang/rustc-perf/tree/master/collector/compile-benchmarks/match-stress) and [unused-warnings](https://github.com/rust-lang/rustc-perf/tree/master/collector/compile-benchmarks/unused-warnings) in regressions there, and in improvements in this PR.
After this PR all table changes should also be "locally correct" after every update.
2023-04-05 20:50:33 +00:00
Oli Scherer
373807a95c Rename ast::Static to ast::StaticItem to match ast::ConstItem 2023-04-04 15:34:40 +00:00
Oli Scherer
4bebdd7104 box a bunch of large types 2023-04-04 13:58:50 +00:00
clubby789
ebde2ab363 Deny useing tool paths 2023-04-04 14:10:13 +01:00
Oli Scherer
ec74653652 Split out ast::ItemKind::Const into its own struct 2023-04-04 09:44:50 +00:00
Oli Scherer
e3828777a6 rust-analyzer guided tuple field to named field 2023-04-04 09:44:50 +00:00
Oli Scherer
b08a557f80 rust-analyzer guided enum variant structification 2023-04-04 09:44:45 +00:00
bors
35d06f9c74 Auto merge of #109599 - notriddle:notriddle/use-redundant-glob, r=petrochenkov
diagnostics: account for glob shadowing when linting redundant imports

Fixes #92904
2023-04-04 06:41:27 +00:00
Tom Martin
56207b8faf
Skip help messages if macro span is from macro 2023-04-02 19:01:52 +01:00
Matthias Krüger
73bd953dea slighty simplify a few boolean expressions (clippy::nonminimal_bool) 2023-04-01 23:55:22 +02:00
Matthias Krüger
ac229c2819 fix clippy::iter_kv_map 2023-04-01 23:44:16 +02:00
Michael Howell
000e94e67d diagnostics: account for glob shadowing when linting redundant imports
Co-Authored-By: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2023-04-01 11:11:21 -07:00
bors
5e1d3299a2 Auto merge of #109824 - GuillaumeGomez:rollup-i5r4uts, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #109104 (rustdoc: Fix invalid suggestions on ambiguous intra doc links v2)
 - #109443 (Move `doc(primitive)` future incompat warning to `invalid_doc_attributes`)
 - #109680 (Fix subslice capture in closure)
 - #109798 (fluent_messages macro: don't emit the OS error in a note)
 - #109805 (Source map cleanups)
 - #109818 (rustdoc: Add GUI test for jump to collapsed item)
 - #109820 (rustdoc-search: update docs for comma in `?` help popover)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-31 20:38:06 +00:00
Guillaume Gomez
6c93c63771
Rollup merge of #109443 - GuillaumeGomez:doc-primitive-hard-error, r=notriddle
Move `doc(primitive)` future incompat warning to `invalid_doc_attributes`

Fixes #88070.

It's been a while since this was turned into a "future incompatible lint" so I think we can now turn it into a hard error without problem.

r? `@jyn514`
2023-03-31 22:32:49 +02:00
bors
7402519c63 Auto merge of #109010 - compiler-errors:rtn, r=eholk
Initial support for return type notation (RTN)

See: https://smallcultfollowing.com/babysteps/blog/2023/02/13/return-type-notation-send-bounds-part-2/

1. Only supports `T: Trait<method(): Send>` style bounds, not `<T as Trait>::method(): Send`. Checking validity and injecting an implicit binder for all of the late-bound method generics is harder to do for the latter.
    * I'd add this in a follow-up.
3. ~Doesn't support RTN in general type position, i.e. no `let x: <T as Trait>::method() = ...`~
    * I don't think we actually want this.
5. Doesn't add syntax for "eliding" the function args -- i.e. for now, we write `method(): Send` instead of `method(..): Send`.
    * May be a hazard if we try to add it in the future. I'll probably add it in a follow-up later, with a structured suggestion to change `method()` to `method(..)` once we add it.
7. ~I'm not in love with the feature gate name 😺~
    * I renamed it to `return_type_notation` ✔️

Follow-up PRs will probably add support for `where T::method(): Send` bounds. I'm not sure if we ever want to support return-type-notation in arbitrary type positions. I may also make the bounds require `..` in the args list later.

r? `@ghost`
2023-03-31 18:04:12 +00:00
Vadim Petrochenkov
60c6dc07de resolve: Restore some effective visibility optimizations
Something similar was previously removed as a part of #104602, but after this PR all table changes should also be "locally correct" after every update.
2023-03-31 17:07:59 +04:00
Guillaume Gomez
f6035fb0fa Update doc(primitive) in rustc_resolve 2023-03-31 00:04:24 +02:00
Tom Martin
ed84d1d905
Fix typo 2023-03-30 21:53:56 +01:00
Tom Martin
10c36445ff
Update non-derive macro error message to match suggestion
It's now split between two errors, one to remove the invalid derive macro
and one suggesting adding a new non-derive macro
2023-03-30 21:43:32 +01:00
Vadim Petrochenkov
b3bfeaf765 effvis: Stop considering crate root its own parent
It helped to reuse `update_def` for the crate root, but it created confusion and caused some mistakes when I implemented #109500
2023-03-28 22:18:02 +04:00
Vadim Petrochenkov
ede21e8932 effvis: Merge two similar code paths 2023-03-28 22:12:45 +04:00
Michael Goulet
8b592db27a Add (..) syntax for RTN 2023-03-28 01:14:28 +00:00
Guillaume Gomez
b1e8be783f
Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errors
Remove the `NodeId` of `ast::ExprKind::Async`

This is a followup to https://github.com/rust-lang/rust/pull/104833#pullrequestreview-1314537416.

In my original attempt, I was using `LoweringContext::expr`, which was not correct as it creates a fresh `DefId`.
It now uses the correct `DefId` for the wrapping `Expr`, and also makes forwarding `#[track_caller]` attributes more explicit.
2023-03-27 18:56:19 +02:00
Tom Martin
42f2be8a8c
Add suggestion to remove derive() if invoked macro is non-derive 2023-03-26 16:01:25 +01:00
bors
8be3c2bda6 Auto merge of #107932 - petrochenkov:onlyexport, r=jyn514
rustdoc: Skip doc link resolution for non-exported items
2023-03-24 21:10:51 +00:00
Matthias Krüger
4d21d302a1
Rollup merge of #109536 - petrochenkov:qcstore3, r=cjgillot
resolve: Rename some cstore methods to match queries and add comments

about costs associated with replacing them with query calls.

Supersedes https://github.com/rust-lang/rust/pull/108346.
r? `@cjgillot`
2023-03-24 01:22:07 +01:00
Matthias Krüger
3961ef5bc8
Rollup merge of #109487 - GuillaumeGomez:move-useless-reexport-check, r=petrochenkov
Move useless_anynous_reexport lint into unused_imports

As mentioned in https://github.com/rust-lang/rust/pull/109003, this check should have been merged with `unused_imports` in the start.

r? `@petrochenkov`
2023-03-23 19:55:46 +01:00
Matthias Krüger
bacf059f57
Rollup merge of #107880 - jieyouxu:issue-107563, r=petrochenkov
Lint ambiguous glob re-exports

Attempts to fix #107563.

We currently already emit errors for ambiguous re-exports when two names are re-exported *specifically*, i.e. not from glob exports. This PR attempts to emit deny-by-default lints for ambiguous glob re-exports.
2023-03-23 19:55:43 +01:00
Vadim Petrochenkov
71927ad083 resolve: Rename some cstore methods to match queries and add comments
about costs associated with replacing them with query calls.
2023-03-23 20:44:02 +04:00
bors
df7fd9995f Auto merge of #108221 - petrochenkov:cratecfg, r=michaelwoerister
rustc_interface: Add a new query `pre_configure`

It partially expands crate attributes before the main expansion pass (without modifying the crate), and the produced preliminary crate attribute list is used for querying a few attributes that are required very early.

Crate-level cfg attributes on the crate itself are then expanded normally during the main expansion pass, like attributes on any other nodes.
This is a continuation of https://github.com/rust-lang/rust/pull/92473 and one more step to very unstable crate-level proc macro attributes maybe actually working.

Previously crate attributes were pre-configured simultaneously with feature extraction, and then written directly into `ast::Crate`.
2023-03-23 15:17:59 +00:00
bors
99c49d95cd Auto merge of #109517 - matthiaskrgr:rollup-m3orqzd, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #108541 (Suppress `opaque_hidden_inferred_bound` for nested RPITs)
 - #109137 (resolve: Querify most cstore access methods (subset 2))
 - #109380 (add `known-bug` test for unsoundness issue)
 - #109462 (Make alias-eq have a relation direction (and rename it to alias-relate))
 - #109475 (Simpler checked shifts in MIR building)
 - #109504 (Stabilize `arc_into_inner` and `rc_into_inner`.)
 - #109506 (make param bound vars visibly bound vars with -Zverbose)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-23 12:35:05 +00:00
Vadim Petrochenkov
bec4eab3f9 rustdoc: Skip doc link resolution for non-exported items 2023-03-23 16:19:59 +04:00
Vadim Petrochenkov
aca1b1e0b3 rustc_interface: Add a new query pre_configure
It partially expands crate attributes before the main expansion pass (without modifying the crate), and the produced preliminary crate attribute list is used for querying a few attributes that are required very early.

Crate-level cfg attributes are then expanded normally during the main expansion pass, like attributes on any other nodes.
2023-03-23 14:22:48 +04:00
Matthias Krüger
3e33fb9f12
Rollup merge of #109137 - petrochenkov:qcstore2, r=cjgillot
resolve: Querify most cstore access methods (subset 2)

These changes are less likely to cause perf regressions than the rest of https://github.com/rust-lang/rust/pull/108346.
2023-03-23 08:35:34 +01:00
bors
84dd6dfd9d Auto merge of #109503 - matthiaskrgr:rollup-cnp7kdd, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #108954 (rustdoc: handle generics better when matching notable traits)
 - #109203 (refactor/feat: refactor identifier parsing a bit)
 - #109213 (Eagerly intern and check CrateNum/StableCrateId collisions)
 - #109358 (rustc: Remove unused `Session` argument from some attribute functions)
 - #109359 (Update stdarch)
 - #109378 (Remove Ty::is_region_ptr)
 - #109423 (Use region-erased self type during IAT selection)
 - #109447 (new solver cleanup + implement coherence)
 - #109501 (make link clickable)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-23 07:01:03 +00:00
Matthias Krüger
577d85f92f
Rollup merge of #109358 - petrochenkov:nosess, r=cjgillot
rustc: Remove unused `Session` argument from some attribute functions

(One auxiliary test file containing one of these functions was unused, so I removed it instead of updating.)
2023-03-22 22:44:41 +01:00
bors
8859fde21f Auto merge of #109497 - matthiaskrgr:rollup-6txuxm0, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #109373 (Set LLVM `LLVM_UNREACHABLE_OPTIMIZE` to `OFF`)
 - #109392 (Custom MIR: Allow optional RET type annotation)
 - #109394 (adapt tests/codegen/vec-shrink-panik for LLVM 17)
 - #109412 (rustdoc: Add GUI test for "Auto-hide item contents for large items" setting)
 - #109452 (Ignore the vendor directory for tidy tests.)
 - #109457 (Remove comment about reusing rib allocations)
 - #109461 (rustdoc: remove redundant `.content` prefix from span/a colors)
 - #109477 (`HirId` to `LocalDefId` cleanup)
 - #109489 (More general captures)
 - #109494 (Do not feed param_env for RPITITs impl side)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-22 21:35:02 +00:00
Matthias Krüger
9629156fc7
Rollup merge of #109489 - est31:generalize_captures, r=WaffleLapkin
More general captures

This avoids repetition of the binding.
2023-03-22 20:08:04 +01:00
Matthias Krüger
3712bfff1b
Rollup merge of #109457 - Veykril:ribstack, r=petrochenkov
Remove comment about reusing rib allocations

Perf indicates this to not be worth the complexity

cc #4948
2023-03-22 20:08:03 +01:00
Dylan DPC
af3bd22783
Rollup merge of #109312 - petrochenkov:docice5, r=GuillaumeGomez
rustdoc: Cleanup parent module tracking for doc links

Keep ids of the documented items themselves, not their parent modules. Parent modules can be retreived from those ids when necessary.

Fixes https://github.com/rust-lang/rust/issues/108501.
That issue could be fixed in a more local way, but this refactoring is something that I wanted to do since https://github.com/rust-lang/rust/pull/93805 anyway.
2023-03-23 00:00:33 +05:30
Guillaume Gomez
825f0888cc Move useless_anynous_reexport lint into unused_imports 2023-03-22 16:05:20 +01:00
est31
edd7d4a9f7 More general captures
This avoids repetition
2023-03-22 15:39:24 +01:00
Lukas Wirth
204807d8a9 Remove comment about re-using Rib allocations 2023-03-22 12:09:19 +01:00
Vadim Petrochenkov
67a2c5bec8 rustc: Remove unused Session argument from some attribute functions 2023-03-22 13:55:55 +04:00
Vadim Petrochenkov
d3a5541939 rustdoc: Cleanup parent module tracking for doc links
Keep ids of the documented items themselves, not their parent modules.
Parent modules can be retreived from those ids when necessary.
2023-03-21 17:36:57 +04:00
许杰友 Jieyou Xu (Joe)
1f67949f0e
Lint ambiguous glob re-exports 2023-03-20 03:22:31 +08:00
Arpad Borsos
c8ead2e693
Remove the NodeId of ast::ExprKind::Async 2023-03-19 19:01:31 +01:00
bohan
1775722410 fix: modify the condition that resolve_imports stops 2023-03-19 20:18:45 +08:00
Matthias Krüger
0d4a56cc21
Rollup merge of #109257 - petrochenkov:bindebug, r=WaffleLapkin
resolve: Improve debug impls for `NameBinding`

Print at least the Some/None/Ok/Err status of the nested bindings if not the bindings themselves.
Noticed while reviewing https://github.com/rust-lang/rust/pull/108729.
2023-03-18 00:05:55 +01:00
Matthias Krüger
dfd2b6493a
Rollup merge of #109222 - chenyukang:yukang/fix-109143, r=petrochenkov
Do not ICE for unexpected lifetime with ConstGeneric rib

Fixes #109143
r? ````@petrochenkov````

Combining this test with the previous test will affect the previous diagnostics, so I added a separate test case.
2023-03-18 00:05:53 +01:00
Vadim Petrochenkov
2a5208011d resolve: Improve debug impls for NameBinding
Print at least the Some/None/Ok/Err status of the nested bindings if not the bindings themselves.
2023-03-17 13:34:15 +04:00
yukang
827a990255 Do not ICE for unexpected lifetime with ConstGeneric rib 2023-03-17 07:36:18 +08:00
Vadim Petrochenkov
18b59f5d6d resolve: Minor cleanup to Resolver::get_module 2023-03-16 17:22:18 +04:00
Vadim Petrochenkov
52c73975b4 resolve: Use item_name and opt_parent in Resolver::get_module
This is a cleanup that doesn't introduce new query calls, but this way `def_key` is decoded twice which may matter for performance or may not
2023-03-16 17:22:18 +04:00
Vadim Petrochenkov
d99e01fa7e resolve: Remove item_attrs_untracked 2023-03-16 17:22:18 +04:00
Vadim Petrochenkov
f28f77f2d9 resolve: Remove item_generics_num_lifetimes 2023-03-16 17:22:18 +04:00
Ezra Shaw
bd1732240b
error-msg: impl better suggestion for E0532 2023-03-15 22:19:54 +13:00
Vadim Petrochenkov
4a61922ef0 metadata/resolve: Minor refactoring to "tcx -> cstore" conversions 2023-03-13 17:31:55 +04:00
Vadim Petrochenkov
b3ee735993 resolve: Remove struct_field_names_untracked 2023-03-13 17:31:55 +04:00
Vadim Petrochenkov
2a716f3563 resolve: Centralize retrieval of items span and item name 2023-03-13 17:31:54 +04:00
Vadim Petrochenkov
c7f424b80a resolve: Remove fn_has_self_parameter_untracked 2023-03-13 17:31:54 +04:00
Vadim Petrochenkov
c05b7bd7d0 resolve: Remove struct_field_visibilities_untracked 2023-03-13 17:31:54 +04:00
Vadim Petrochenkov
901f1c9c62 resolve: Partially remove item_attrs_untracked 2023-03-13 17:31:54 +04:00
Vadim Petrochenkov
17127f3e78 resolve: Remove visibility_untracked 2023-03-13 17:31:54 +04:00
est31
7e2ecb3cd8 Simplify message paths
This makes it easier to open the messages file while developing on features.

The commit was the result of automatted changes:

for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done

for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
2023-03-11 22:51:57 +01:00
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