Commit graph

535 commits

Author SHA1 Message Date
Lamb
3a77bb86ff Compute most of Public/Exported access level in rustc_resolve
Mak DefId to AccessLevel map in resolve for export

hir_id to accesslevel in resolve and applied in privacy
using local def id
removing tracing probes
making function not recursive and adding comments

Move most of Exported/Public res to rustc_resolve

moving public/export res to resolve

fix missing stability attributes in core, std and alloc

move code to access_levels.rs

return for some kinds instead of going through them

Export correctness, macro changes, comments

add comment for import binding

add comment for import binding

renmae to access level visitor, remove comments, move fn as closure, remove new_key

fmt

fix rebase

fix rebase

fmt

fmt

fix: move macro def to rustc_resolve

fix: reachable AccessLevel for enum variants

fmt

fix: missing stability attributes for other architectures

allow unreachable pub in rustfmt

fix: missing impl access level + renaming export to reexport

Missing impl access level was found thanks to a test in clippy
2022-01-09 21:33:14 +00:00
bors
f7bb8e3677 Auto merge of #92690 - matthiaskrgr:rollup-rw0oz05, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #92055 (Add release notes for 1.58)
 - #92490 (Move crate drop-down to search results page)
 - #92510 (Don't resolve blocks in foreign functions)
 - #92573 (expand: Refactor InvocationCollector visitor for better code reuse)
 - #92608 (rustdoc: Introduce a resolver cache for sharing data between early doc link resolution and later passes)
 - #92657 (Implemented const casts of raw pointers)
 - #92671 (Make `Atomic*::from_mut` return `&mut Atomic*`)
 - #92673 (Remove useless collapse toggle on "all items" page)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-09 12:43:37 +00:00
Matthias Krüger
464a0813d1
Rollup merge of #92510 - inquisitivecrystal:foreign-block, r=cjgillot
Don't resolve blocks in foreign functions

Although it is an error for a foreign function to have a block, it is still possible at the level of the AST. #74204 made AST lowering skip over blocks belonging to foreign functions, since they're invalid. However, resolve still treated these blocks normally, resulting in a mismatch between the HIR and resolve, which could cause an ICE under certain circumstances. This PR changes resolve to skip over blocks belonging to foreign functions, as AST lowering does.

Fixes #91370.

r? ``@cjgillot``
2022-01-09 13:38:30 +01:00
Vadim Petrochenkov
4b03fd910c rustc_middle: Rename Export to ModChild and add some comments
Also rename `module_exports`/`export_map` to `module_reexports`/`reexport_map` for clarity.
2022-01-09 09:22:07 +08:00
Vadim Petrochenkov
3051f6e9c4 rustc_metadata: Rename item_children(_untracked) to module_children(_untracked)
And `each_child_of_item` to `for_each_module_child`
2022-01-09 09:22:06 +08:00
Vadim Petrochenkov
4c6120c386 rustc_metadata: Make attribute decoding slightly faster and stricter
Rename `CStore::item_attrs` -> `CStore::item_attrs_untracked` top follow conventions
2022-01-06 12:13:41 +08:00
inquisitivecrystal
486585242e Do not resolve blocks in foreign functions 2022-01-05 15:22:22 -08:00
Vadim Petrochenkov
55595c5616 ast: Always keep a NodeId in ast::Crate
This makes it more uniform with other expanded nodes
2022-01-05 17:09:37 +08:00
Matthias Krüger
0335b7bca9
Rollup merge of #92402 - pr2502:while-let-typo, r=oli-obk
Suggest while let x = y when encountering while x = y

Extends #75931 to also detect where the `let` might be missing from `while let` expressions.
2022-01-03 14:44:18 +01:00
ametisf
874cd08e23 Suggest while let x = y when encountering while x = y
Extends #75931 to also detect where the `let` might be missing from `while let` expressions.
2021-12-29 13:23:19 +01:00
Matthias Krüger
f044c6c86c
Rollup merge of #92237 - compiler-errors:issue-92100, r=cjgillot
Visit expressions in-order when resolving pattern bindings

[edited:] Visit the pattern's sub-expressions before defining any bindings.

Otherwise, we might get into a case where a Lit/Range expression in a pattern has a qpath pointing to a Ident pattern that is defined after it, causing an ICE when lowering to HIR. I have a more detailed explanation in the issue linked.

Fixes #92100
2021-12-29 10:17:10 +01:00
Matthias Krüger
98c61b673e
Rollup merge of #92333 - compiler-errors:elided-lifetime-spans, r=cjgillot
Tighten span when suggesting lifetime on path

This is kind of a hack.

Really the issue here is that we want to suggest the segment's span if the path resolves to something defined outside of the macro, and the macro's span if it resolves to something defined within.. I'll look into seeing if we can do something like that.

Fixes #92324

r? `@cjgillot`
2021-12-28 13:59:25 +01:00
Michael Goulet
e37d012a06 Tighten span when suggesting lifetime on path 2021-12-27 23:34:52 -08:00
Matthias Krüger
a11414d62e
Rollup merge of #92161 - petrochenkov:misclean, r=cjgillot
resolve: Minor miscellaneous cleanups from #89059

`@bors` rollup=always
2021-12-27 21:42:27 +01:00
Michael Goulet
b1529a680a Visit patterns' literal expressions before binding new idents 2021-12-27 12:20:13 -08:00
Vadim Petrochenkov
337ced2ef0 rustc_metadata: Merge get_ctor_def_id and get_ctor_kind
Also avoid decoding the whole `ty::AssocItem` to get a `has_self` flag
2021-12-22 11:05:54 +08:00
Vadim Petrochenkov
1324100800 resolve: Minor miscellaneous cleanups from #89059 2021-12-21 20:26:41 +08:00
Matthias Krüger
790950a530
Rollup merge of #91770 - TaKO8Ki:suggest-adding-cfg-test, r=joshtriplett
Suggest adding a `#[cfg(test)]` to to a test module

closes #88138
2021-12-21 08:33:39 +01:00
bors
a41a6925ba Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk
Remove `SymbolStr`

This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences.

Best reviewed one commit at a time.

r? `@oli-obk`
2021-12-19 09:31:37 +00:00
Vadim Petrochenkov
0d61852cc5 hir: Do not introduce dummy type names for extern blocks in def paths
Use a separate nameless `DefPathData` variant instead
2021-12-18 16:30:17 +08:00
Takayuki Maeda
6f8ad6d83a suggest adding a #[cfg(test)] to test modules
remove a empty line

import `module_to_string`

use `contains("test")`

show a suggestion in case module starts_with/ends_with "test"

replace `parent` with `containing`
2021-12-16 11:48:58 +09:00
bors
9e1aff82e6 Auto merge of #89836 - pierwill:fix-85142-crate-hash, r=wesleywiser
Include rustc version in `rustc_span::StableCrateId`

`rustc_span::def_id::StableCrateId` is a hash of various data about a crate during compilation. This PR includes the version of `rustc` in the input when computing this hash. From a cursory reading of [RFC 2603](https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html), this appears to be acceptable within that design.

In order to pass the `mir-opt` and `ui` test suites, this adds new [normalization for hashes and symbol names in `compiletest`](https://github.com/rust-lang/rust/pull/89836/files#diff-03a0567fa80ca04ed5a55f9ac5c711b4f84659be2d0ac4a984196d581c04f76b). These are enabled by default, but we might prefer it to be configurable.

In the UI tests, I had to truncate a significant amount of error annotations in v0 symbols (and maybe some legacy) in order to get the normalization to work correctly. (See https://github.com/rust-lang/rust/issues/90116.)

Closes #85142.
2021-12-16 02:21:30 +00:00
Matthias Krüger
6b00227666
Rollup merge of #91888 - BoxyUwU:generic_arg_infer_aaaa, r=lcnr
Handle unordered const/ty generics for object lifetime defaults

*feel like I should have a PR description but cant think of what to put here*

r? ```@lcnr```
2021-12-15 08:36:23 +01:00
Nicholas Nethercote
b1c934ebb8 Remove unnecessary sigils around Ident::as_str() calls. 2021-12-15 17:32:42 +11:00
Nicholas Nethercote
056d48a2c9 Remove unnecessary sigils around Symbol::as_str() calls. 2021-12-15 17:32:14 +11:00
bors
195e931b02 Auto merge of #91945 - matthiaskrgr:rollup-jszf9zp, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #90939 (Tweak errors coming from `for`-loop, `?` and `.await` desugaring)
 - #91859 (Iterator::cycle() — document empty iterator special case)
 - #91868 (Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`)
 - #91870 (Revert setting a default for the MACOSX_DEPLOYMENT_TARGET env var for linking)
 - #91881 (Stabilize `iter::zip`)
 - #91882 (Remove `in_band_lifetimes` from `rustc_typeck`)
 - #91940 (Update cargo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-15 03:28:55 +00:00
Nicholas Nethercote
8cddcd39ba Remove SymbolStr.
By changing `as_str()` to take `&self` instead of `self`, we can just
return `&str`. We're still lying about lifetimes, but it's a smaller lie
than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-15 13:30:26 +11:00
PFPoitras
304ede6bcc Stabilize iter::zip. 2021-12-14 18:50:31 -04:00
Matthias Krüger
6a9491895f
Rollup merge of #91798 - bugadani:issue-91783, r=michaelwoerister
Avoid suggest adding `self` in visibility spec

Fixes #91783
2021-12-14 20:47:30 +01:00
Ellen
7175980ff5 awdawdawd 2021-12-14 03:32:58 +00:00
pierwill
7d7dfba350 Include rustc version in rustc_span::StableCrateId
Normalize symbol hashes in compiletest.

Remove DefId sorting
2021-12-13 10:24:05 -06:00
Dániel Buga
f3a08fd8e7 Avoid suggesting self in visibility spec
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2021-12-12 11:14:10 +01:00
Matthias Krüger
72b6a91fe7
Rollup merge of #91764 - cjgillot:elide-anyway, r=jackh726
Do not ICE when suggesting elided lifetimes on non-existent spans.

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

r? `@jackh726`
2021-12-11 23:31:52 +01:00
Camille GILLOT
9a68003742 Do not ICE when suggesting elided lifetimes on non-existent spans. 2021-12-11 11:08:46 +01:00
Camille GILLOT
8576ab45e4 Store impl_trait_fn inside OpaqueTyOrigin. 2021-12-07 21:30:45 +01:00
Esteban Kuber
962b2197a5 Annotate derived spans and move span suggestion code
* Annotate `derive`d spans from the user's code with the appropciate context
* Add `Span::can_be_used_for_suggestion` to query if the underlying span
  at the users' code
2021-12-03 18:41:40 +00:00
Esteban Kuber
e70105f971 Keep spans for generics in #[derive(_)] desugaring
Keep the spans for generics coming from a `derive`d Item, so that errors
and suggestions have better detail.

Fix #84003.
2021-12-03 18:41:39 +00:00
Matthias Krüger
d96ce3ea8e
Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbini
Bump stage0 compiler

r? `@pietroalbini` (or anyone else)
2021-12-02 15:52:03 +01:00
Matthias Krüger
87ca333210
Rollup merge of #91045 - mjptree:issue-90702-fix, r=petrochenkov
Issue 90702 fix: Stop treating some crate loading failures as fatal errors

Surface mulitple `extern crate` resolution errors at a time.

This is achieved by creating a dummy crate, instead of aborting directly after the resolution error. The `ExternCrateError` has been added to allow propagating the resolution error from `rustc_metadata` crate to the `rustc_resolve` with a minimal public surface. The `import_extern_crate` function is a block that was factored out from `build_reduced_graph_for_item` for better organization. The only added functionality made to it where the added error handling in the `process_extern_crate` call. The remaining bits in this function are the same as before.

Resolves #90702

r? `@petrochenkov`
2021-12-02 15:52:01 +01:00
bors
76938d64a4 Auto merge of #90446 - cjgillot:late-elided, r=jackh726
Lint elided lifetimes in path during lifetime resolution.

The lifetime elision lint is known to be brittle and can be redundant with later lifetime resolution errors. This PR aims to remove the redundancy by performing the lint after lifetime resolution.

This PR proposes to carry the information that an elision should be linted against by using a special `LifetimeName`. I am not certain this is the best solution, but it is certainly the easiest.

Fixes https://github.com/rust-lang/rust/issues/60199
Fixes https://github.com/rust-lang/rust/issues/55768
Fixes https://github.com/rust-lang/rust/issues/63110
Fixes https://github.com/rust-lang/rust/issues/71957
2021-12-01 23:22:43 +00:00
Michael
2ca9333011 Improve suggestion for extern crate self error message 2021-12-01 21:59:54 +00:00
Michael
62f4ce993e Stop treating extern crate loading failures as fatal errors 2021-12-01 21:04:13 +00:00
Michael
10b3a571d2 Factor out build reduced graph for extern crate 2021-12-01 21:04:12 +00:00
Matthias Krüger
519a842c50
Rollup merge of #91313 - petrochenkov:cratexp, r=Aaron1011
expand: Turn `ast::Crate` into a first class expansion target

And stop creating a fake `mod` item for the crate root when expanding a crate, thus addressing FIXMEs left in https://github.com/rust-lang/rust/pull/82238, and making a step towards a proper support for crate-level macro attributes (cc #54726).

I haven't added token collection support for the whole crate in this PR, maybe later.
r? `@Aaron1011`
2021-12-01 20:57:43 +01:00
Matthias Krüger
4f252f1a91
Rollup merge of #91404 - nnethercote:fix-bad-NodeId-limit-checking, r=dtolnay
Fix bad `NodeId` limit checking.

`Resolver::next_node_id` converts a `u32` to a `usize` (which is
possibly bigger), does a checked add, and then converts the result back
to a `u32`. The `usize` conversion completely subverts the checked add!

This commit removes the conversion to/from `usize`.
2021-12-01 10:50:23 +01:00
Matthias Krüger
c09c16c0df
Rollup merge of #91298 - FabianWolff:issue-91028-source-avail, r=cjgillot
Improve error message for `E0659` if the source is not available

Fixes #91028. The fix is similar to those in #89233 and #87088. With this change, instead of the dangling
```
note: `Option` could also refer to the enum defined here
```
I get
```
note: `Option` could also refer to an enum from prelude
```
If the standard library source code _is_ available, the output does not change.
2021-12-01 10:50:21 +01:00
Nicholas Nethercote
e7ee8230ce Fix bad NodeId limit checking.
`Resolver::next_node_id` converts a `u32` to a `usize` (which is
possibly bigger), does a checked add, and then converts the result back
to a `u32`. The `usize` conversion completely subverts the checked add!

This commit removes the conversion to/from `usize`.
2021-12-01 15:08:37 +11:00
Camille GILLOT
aa2450f41b Merge Implicit and ImplicitMissing. 2021-11-30 22:56:47 +01:00
Camille GILLOT
72dc29c260 Handle allow(elided_lifetimes_in_paths). 2021-11-30 22:55:07 +01:00
Camille GILLOT
5ea7ea8a57 Lint elided lifetimes in path during lifetime resolution. 2021-11-30 22:55:07 +01:00