Commit Graph

1228 Commits

Author SHA1 Message Date
Camille GILLOT
cb1e7d9676 Only ban duplication across parameters. 2022-10-27 19:04:48 +00:00
Byron Zhong
20a8427a11 Remove redundant braces 2022-10-27 01:41:24 -05:00
Byron Zhong
c0472a5450 Fix E0433 diagnostics ignoring typo suggestions and outputing wrong message 2022-10-27 00:49:39 -05:00
Vadim Petrochenkov
34eb73c72d privacy: Rename "accessibility levels" to "effective visibilities"
And a couple of other naming tweaks

Related to https://github.com/rust-lang/rust/issues/48054
2022-10-26 16:34:53 +04:00
Dylan DPC
c956351f97
Rollup merge of #103520 - petrochenkov:resout, r=cjgillot
rustc_middle: Rearrange resolver outputs structures slightly

Addresses https://github.com/rust-lang/rust/pull/98106#discussion_r898427061.
I also haven't seen the motivation for moving `cstore` from its old place, so I moved it back in this PR.
r? ```@cjgillot```
2022-10-26 11:29:56 +05:30
Byron Zhong
775328c290 Modify check to output 'you might have meant' for indirect reference 2022-10-25 22:08:41 -05:00
Byron Zhong
0b936d2da7 Add check to only output 'you might have meant' when the candidate name is in the same crate 2022-10-25 22:08:41 -05:00
Byron Zhong
be61f0237b Add Span in TypoSuggestion and TypoCandidate 2022-10-25 22:08:41 -05:00
bors
a5406feb1c Auto merge of #103158 - Bryanskiy:resolve_perf, r=petrochenkov
Perf improvements for effective visibility calculating

related to https://github.com/rust-lang/rust/pull/102026
r? `@petrochenkov`
2022-10-26 02:30:18 +00:00
yukang
32a2f0dddb suggest calling the method of the same name when method not found 2022-10-26 00:45:29 +08:00
Bryanskiy
a9447bb9d0 Perf improvements for effective visibility calculating 2022-10-25 15:15:18 +03:00
Vadim Petrochenkov
919673ea03 rustc_middle: Rearrange resolver outputs structures slightly 2022-10-25 15:42:29 +04:00
Yuki Okushi
e47d222a94
Rollup merge of #103350 - clubby789:refer-to-assoc-method, r=wesleywiser
Change terminology for assoc method suggestions when they are not called

Fixes #103325

```@rustbot``` label +A-diagnostics
2022-10-25 08:01:27 +09:00
Aaron Hill
7d82cadd97
Make PROC_MACRO_DERIVE_RESOLUTION_FALLBACK a hard error 2022-10-24 13:40:07 -05:00
Michael Howell
3df030d441
Rollup merge of #103140 - chenyukang:yukang/fix-103112, r=estebank
Add diagnostic for calling a function with the same name with unresolved Macro

Fixes #103112
2022-10-23 14:48:15 -07:00
Camille GILLOT
47704bbcc0 Do not consider repeated lifetime params for elision. 2022-10-23 19:36:19 +00:00
Dylan DPC
0b3e018137
Rollup merge of #103249 - petrochenkov:revaddids, r=oli-obk
resolve: Revert "Set effective visibilities for imports more precisely"

In theory the change was correct, but in practice the use of import items in HIR is limited and hacky, and it expects that (effective) visibilities for all (up to) 3 IDs of the import are set to the value reflecting (effective) visibility of the whole syntactic `use` item rather than its individual components.

Fixes https://github.com/rust-lang/rust/issues/102352
r? `@oli-obk`
2022-10-23 15:20:18 +05:30
Dylan DPC
518d5ebc81
Rollup merge of #101908 - chenyukang:fix-101880, r=estebank
Suggest let for assignment, and some code refactor

Fixes #101880
2022-10-23 15:20:16 +05:30
clubby789
717bf35366 Different suggestions for when associated functions are referred to 2022-10-21 14:38:44 +01:00
Dylan DPC
41a1cfdbaf
Rollup merge of #103111 - cjgillot:shadow-label, r=estebank
Account for hygiene in typo suggestions, and use them to point to shadowed names

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

r? `@estebank`
2022-10-21 17:29:59 +05:30
Matthias Krüger
7ee4b218a8
Rollup merge of #103221 - TaKO8Ki:fix-103202, r=oli-obk
Fix `SelfVisitor::is_self_ty` ICE

Fixes #103202
2022-10-20 22:42:38 +02:00
yukang
eb68e27e4c fix rust-lang#101880: suggest let for assignment, and some code refactor 2022-10-20 22:54:02 +08:00
bors
53728ff751 Auto merge of #103185 - chenyukang:yukang/fix-span-next-point, r=davidtwco
Fix the bug of next_point in source_map

There is a bug in `next_point`, the new span won't move to next position when be called in the first time.

For this reason, our current code is working like this:
1. When we really want to move to the next position, we called two times of `next_point`
2. Some code which use `next_point` actually done the same thing with `shrink_to_hi`

This fix make sure when `next_point` is called, span will move with the width at least 1, and also work correctly in the scenario of multiple bytes.

Ref: https://github.com/rust-lang/rust/pull/103140#discussion_r997710998

r? `@davidtwco`
2022-10-20 10:40:09 +00:00
Takayuki Maeda
9a9e2fe15f check if impl_self is Some 2022-10-20 14:10:52 +09:00
yukang
f90bf50d47 fix span for suggestion 2022-10-20 11:55:30 +08:00
yukang
1225c3f6b8 fix #103112, add diagnostic for calling a function with the same name when a Macro is not found 2022-10-20 11:55:30 +08:00
Vadim Petrochenkov
ba4834c092 resolve: Revert "Set effective visibilities for imports more precisely" 2022-10-19 18:42:47 +04:00
Dylan DPC
32159e3fa4
Rollup merge of #103216 - cjgillot:issue-103210, r=jackh726
Consider patterns in fn params in an `Elided(Infer)` lifetime rib.

Fixes https://github.com/rust-lang/rust/issues/103210
2022-10-19 14:05:54 +05:30
Takayuki Maeda
0b2716415f fix SelfVisitor::is_self_ty ICE 2022-10-19 11:17:46 +09:00
Camille GILLOT
9c3bf4de55 Consider patterns in fn params in an Elided(Infer) lifetime rib. 2022-10-18 21:25:38 +00:00
yukang
0af255a5aa Fix the bug of next_point in span 2022-10-18 02:59:38 +08:00
bors
1536ab1b38 Auto merge of #103096 - petrochenkov:indresdoc, r=cjgillot
resolve: Shadow erroneous glob imports with erroneous single imports

If such shadowing doesn't happen we end up in a weird state that may cause ICEs.
(In non-erroneous cases single imports always shadow glob imports too.)

Fixes https://github.com/rust-lang/rust/issues/100047
Fixes https://github.com/rust-lang/rust/issues/100241
2022-10-17 02:06:25 +00:00
bors
b8b5caee04 Auto merge of #102026 - Bryanskiy:resolve_update, r=petrochenkov
Populate effective visibilities in 'rustc_resolve'

Next part of RFC https://github.com/rust-lang/rust/issues/48054.
previous: https://github.com/rust-lang/rust/pull/101713

`@rustbot` author
r? `@petrochenkov`
2022-10-16 20:34:38 +00:00
Bryanskiy
496ccd982c Populate effective visibilities in 'rustc_resolve' 2022-10-16 21:47:14 +03:00
Camille GILLOT
4bbb163b5d Point to shadowed name when it exists. 2022-10-16 09:03:21 +00:00
Camille GILLOT
6d947e6d48 Account for hygiene when suggesting typos. 2022-10-16 08:56:39 +00:00
Vadim Petrochenkov
f767f2297d resolve: Shadow erroneous glob imports with erroneous single imports 2022-10-16 00:10:16 +04:00
Dylan DPC
39ff2a60d6
Rollup merge of #102884 - petrochenkov:liferib, r=cjgillot
resolve: Some cleanup, asserts and tests for lifetime ribs

Follow up to https://github.com/rust-lang/rust/pull/98279 and friends.
r? ``@cjgillot``
2022-10-15 15:45:31 +05:30
Dylan DPC
77064b7f0a
Rollup merge of #103018 - Rageking8:more-dupe-word-typos, r=TaKO8Ki
More dupe word typos

I only picked those changes (from the regex search) that I am pretty certain doesn't change meaning and is just a typo fix. Do correct me if any fix is undesirable and I can revert those. Thanks.
2022-10-14 16:19:15 +05:30
Rageking8
7122abaddf more dupe word typos 2022-10-14 12:57:56 +08:00
Dylan DPC
48f950c527
Rollup merge of #102956 - TaKO8Ki:fix-102946, r=fee1-dead
Use `full_res` instead of `expect_full_res`

Fixes #102946
Fixes #102978
2022-10-13 18:19:21 +05:30
Vadim Petrochenkov
f634106591 resolve: Regroup lifetime rib kinds to account for their purpose 2022-10-13 13:32:24 +04:00
Vadim Petrochenkov
e94ec30dc4 resolve: Remove redundant item lifetime ribs
and cleanup lifetime rib walking loops
2022-10-13 13:32:24 +04:00
Vadim Petrochenkov
e8a6e60c5d resolve: Add some asserts for unexpected lifetime rib combinations 2022-10-13 13:32:24 +04:00
Takayuki Maeda
b11dddd1c1 fix #102946 2022-10-12 19:03:46 +09:00
Dylan DPC
252ce10bb0
Rollup merge of #102913 - SparrowLii:import-candidate, r=compiler-errors
unify `IsPattern` and `IsImport` enum in `show_candidates`

Follow-up of #102876
A binding cannot appear in both pattern and import at the same time, so it makes sense to unify them
r? `@compiler-errors`
2022-10-12 11:11:26 +05:30
SparrowLii
a7f58af9fe unify IsPattern and IsImport enum 2022-10-12 08:46:52 +08:00
Matthias Krüger
cb67283392
Rollup merge of #102889 - petrochenkov:partres, r=cjgillot
rustc_hir: Less error-prone methods for accessing `PartialRes` resolution
2022-10-11 18:59:50 +02:00
Matthias Krüger
6d58ff7fe6
Rollup merge of #100387 - cjgillot:hygiene-trait-impl, r=petrochenkov
Check uniqueness of impl items by trait item when applicable.

When checking uniqueness of item names in impl blocks, we currently use the same definition of hygiene as for toplevel items.  This means that a plain item and one generated by a macro 2.0 do not collide.

This hygiene rule does not match with how impl items resolve to associated trait items. As a consequence, we misdiagnose the trait impls.

This PR proposes to consider that trait impl items are uses of the corresponding trait items during resolution, instead of checking for duplicates later. An error is emitted when a trait impl item is used twice.

There should be no stable breakage, since macros 2.0 are still unstable.

r? ``@petrochenkov``
cc ``@RalfJung``

Fixes https://github.com/rust-lang/rust/issues/71614.
2022-10-11 18:59:45 +02:00
Yuki Okushi
98764c0c72
Rollup merge of #102859 - cjgillot:collect-lifetimes, r=oli-obk
Move lifetime resolution module to rustc_hir_analysis.

Now that lifetime resolution has been removed from it, this file has nothing to do in `rustc_resolve`.  It's purpose is to compute Debruijn indices for lifetimes, so let's put it in type collection.
2022-10-11 18:37:55 +09:00
Camille GILLOT
152cd63226 Report duplicate definitions in trait impls during resolution. 2022-10-11 06:24:51 +00:00
Vadim Petrochenkov
1a8f177772 rustc_hir: Less error-prone methods for accessing PartialRes resolution 2022-10-11 09:04:52 +04:00
Matthias Krüger
0bd1cba98b
Rollup merge of #102876 - SparrowLii:import-candidate, r=fee1-dead
suggest candidates for unresolved import

Currently we prompt suggestion of candidates(help notes of `use xxx::yyy`) for names which cannot be resolved, but we don't do that for import statements themselves that couldn't be resolved. It seems reasonable to add candidate help information for these statements as well.
Fixes #102711
2022-10-10 20:47:34 +02:00
Camille GILLOT
a474ec50b7 Move lifetime resolution module to rustc_hir_analysis. 2022-10-10 17:40:52 +00:00
Dylan DPC
81b9d0b1d1
Rollup merge of #102868 - compiler-errors:rename-assoc-tyalias-to-ty, r=TaKO8Ki
Rename `AssocItemKind::TyAlias` to `AssocItemKind::Type`

Thanks `@camsteffen` for catching this in ast too, cc https://github.com/rust-lang/rust/pull/102829#issuecomment-1272649247
2022-10-10 13:43:43 +05:30
SparrowLii
0571b0af65 suggest candidates for unresolved import 2022-10-10 11:14:32 +08:00
Michael Goulet
d3bd6beb97 Rename AssocItemKind::TyAlias to AssocItemKind::Type 2022-10-10 02:31:37 +00:00
Yuki Okushi
0db05f16c8
Rollup merge of #102323 - Stoozy:master, r=cjgillot
Trying to suggest additional lifetime parameter

``@cjgillot`` This is what I have so far for #100615
2022-10-10 10:23:04 +09:00
Yuki Okushi
24424d0acb
Rollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8Ki
rename `ImplItemKind::TyAlias` to `ImplItemKind::Type`

The naming of this variant seems inconsistent given that this is not really a "type alias", and the associated type variant for `TraitItemKind` is just called `Type`.
2022-10-10 00:09:42 +09:00
Michael Goulet
70f3c79c50 ImplItemKind::TyAlias => ImplItemKind::Type 2022-10-09 07:09:57 +00:00
bors
4bd30785eb Auto merge of #102726 - matthiaskrgr:rollup-2ghn38b, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #102672 (rustdoc: remove unused CSS class `in-band`)
 - #102693 (Revert "Use getentropy when possible on all Apple platforms")
 - #102694 (Suggest calling method if fn does not exist)
 - #102708 (Suggest `==` to wrong assign expr)
 - #102710 (Add test for issue 82633)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-06 05:58:27 +00:00
bors
0152393048 Auto merge of #99324 - reez12g:issue-99144, r=jyn514
Enable doctests in compiler/ crates

Helps with https://github.com/rust-lang/rust/issues/99144
2022-10-06 03:01:57 +00:00
Michael Goulet
66c8c5ad1d Delay function resolution error until typeck 2022-10-05 06:42:35 +00:00
stoozy
2657f9d5da Removed unnecessary for loop 2022-10-01 13:55:26 -04:00
Matthias Krüger
05b9f0e360
Rollup merge of #102483 - spastorino:create-defs-on-lowering, r=cjgillot
create def ids for impl traits during ast lowering

r? `@cjgillot`
2022-09-30 23:38:25 +02:00
Santiago Pastorino
b2bef02bcd
create def ids for impl traits during ast lowering 2022-09-30 15:12:01 -03:00
bors
1bb8d276c9 Auto merge of #101887 - nnethercote:shrink-Res, r=spastorino
Shrink `hir::def::Res`

r? `@spastorino`
2022-09-29 22:45:24 +00:00
stoozy
ef930a2200 Emitting error regardless of new param suggestion 2022-09-29 04:06:02 -04:00
reez12g
9a4c5abe45 Remove from compiler/ crates 2022-09-29 16:49:04 +09:00
Yuki Okushi
852a152206
Rollup merge of #102085 - chenyukang:code-refactor, r=cjgillot
Code refactoring smart_resolve_report_errors

`smart_resolve_report_errors` 4ecfdfac51/compiler/rustc_resolve/src/late/diagnostics.rs (L143)
is almost 600 lines of code, we should do some code refactoring.
2022-09-29 11:42:03 +09:00
Nicholas Nethercote
f07d4efc45 Shrink hir::def::Res.
`Res::SelfTy` currently has two `Option`s. When the second one is `Some`
the first one is never consulted. So we can split it into two variants,
`Res::SelfTyParam` and `Res::SelfTyAlias`, reducing the size of `Res`
from 24 bytes to 12. This then shrinks `hir::Path` and
`hir::PathSegment`, which are the HIR types that take up the most space.
2022-09-29 08:44:52 +10:00
Nicholas Nethercote
5f29a13a5b Change the "dummy self type".
Because this is the only occurrence of a `Res::SelfTy` with `None` and
`None` fields, and the next commit will rely on those not being present.
2022-09-29 06:57:53 +10:00
stoozy
e7cb6ad8ce Proper span for new generic param suggestion 2022-09-28 00:33:52 -04:00
Camille GILLOT
337a73da6e Do not overwrite binders for another HirId. 2022-09-27 18:58:37 +02:00
stoozy
24c8e27a1d Properly formatting the multipart suggestion 2022-09-27 11:06:51 -04:00
lcnr
1fc86a63f4 rustc_typeck to rustc_hir_analysis 2022-09-27 10:37:23 +02:00
stoozy
365457bd25 Using multipart suggestion 2022-09-26 22:17:47 -04:00
stoozy
887515af33 Trying to suggest additional lifetime parameter 2022-09-26 13:10:24 -04:00
Pietro Albini
3975d55d98
remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
Michael Goulet
730ead8047 Only generate closure def id for async fns with body 2022-09-25 23:03:15 +00:00
yukang
db0877f653 trivial fix on fallback 2022-09-26 00:53:55 +08:00
yukang
fdda7e0a33 more code refactor on smart_resolve_report_errors 2022-09-26 00:40:57 +08:00
Matthias Krüger
11b4510202
Rollup merge of #102161 - compiler-errors:issue-102138, r=tmandry
Resolve async fn signature even without body (e.g., in trait)

Fixes #102138

This "bail if no body" behavior was introduced in #69539 to fix #69401, but that ICE does not reproduce any more. The error message changes a bit, but that's all, and I don't think it's a particularly diagnostic bad regression.
2022-09-25 09:32:08 +02:00
bors
d0ece44cfa Auto merge of #102040 - TaKO8Ki:separate-definitions-and-hir-owners, r=cjgillot
Separate definitions and HIR owners in the type system

Fixes #83158

r? `@cjgillot`
2022-09-24 22:42:07 +00:00
Michael Goulet
3d7e9a7b27 Only record extra lifetime params for async trait fn with no body 2022-09-24 19:26:54 +00:00
Michael Goulet
59c4a92baf Resolve async fn signature even without body (in trait) 2022-09-24 19:26:54 +00:00
Takayuki Maeda
8fe936099a separate definitions and HIR owners
fix a ui test

use `into`

fix clippy ui test

fix a run-make-fulldeps test

implement `IntoQueryParam<DefId>` for `OwnerId`

use `OwnerId` for more queries

change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`
2022-09-24 23:21:19 +09:00
Matthias Krüger
eb628e8670
Rollup merge of #102109 - petrochenkov:addids, r=oli-obk
resolve: Set effective visibilities for imports more precisely

Instead of setting them for all primary and additional IDs of the import, only set them for the binding's true ID.
2022-09-24 14:29:53 +02:00
Vadim Petrochenkov
4ddff03917 resolve: Set effective visibilities for imports more precisely
Instead of setting them for all primary and additional IDs of the import, only set them for the binding's true ID.
2022-09-22 15:00:24 +03:00
Frank Steffahn
696472a586 Fix a typo in error message 2022-09-22 01:28:45 +02:00
yukang
7adfb44b95 add trivial comments 2022-09-21 23:21:41 +08:00
yukang
f9ef7e2835 code refactoring smart_resolve_report_errors 2022-09-21 12:17:59 +08:00
Deadbeef
a052f2cce1 Add the #[derive_const] attribute 2022-09-20 11:57:58 +00:00
Matthias Krüger
a6b34cd928
Rollup merge of #101713 - Bryanskiy:AccessLevels, r=petrochenkov
change AccessLevels representation

Part of RFC (https://github.com/rust-lang/rust/issues/48054). This patch implements effective visibility table with basic methods and change AccessLevels table representation according to it.

r? ``@petrochenkov``
2022-09-17 23:30:49 +02:00
est31
173eb6f407 Only enable the let_else feature on bootstrap
On later stages, the feature is already stable.

Result of running:

rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-15 21:06:45 +02:00
Bryanskiy
d7b9221405 change AccessLevels representation 2022-09-14 18:11:00 +03:00
bors
a0d1df4a5d Auto merge of #101709 - nnethercote:simplify-visitors-more, r=cjgillot
Simplify visitors more

A successor to #100392.

r? `@cjgillot`
2022-09-14 05:21:14 +00:00
Nicholas Nethercote
7e3fd33a66 Remove unused argument from visit_poly_trait_ref. 2022-09-12 13:51:10 +10:00
Nicholas Nethercote
925363f13d Remove unused span argument from walk_fn. 2022-09-12 13:24:27 +10:00
Nicholas Nethercote
6568ef338e Remove path_span argument to the visit_path_segment methods.
The `visit_path_segment` method of both the AST and HIR visitors has a
`path_span` argument that isn't necessary. This commit removes it.

There are two very small and inconsequential functional changes.

- One call to `NodeCollector::insert` now is passed a path segment
  identifier span instead of a full path span. This span is only used in
a panic message printed in the case of an internal compiler bug.

- Likewise, one call to `LifetimeCollectVisitor::record_elided_anchor`
  now uses a path segment identifier span instead of a full path span.
  This span is used to make some `'_` lifetimes.
2022-09-12 13:24:25 +10:00
KaDiWa
66211d83f9
Avoid Iterator::last 2022-09-11 17:23:00 +02:00
Camille GILLOT
05812df603 Handle generic parameters. 2022-09-09 01:31:46 +00:00
Michael Goulet
5be30f9d79 Make async fn in traits work 2022-09-09 01:31:45 +00:00
Michael Goulet
d34cb98fb0 Lower RPITIT to ImplTraitPlaceholder item 2022-09-09 01:31:44 +00:00
Michael Goulet
78b962a4f3 RPITIT placeholder items 2022-09-09 01:31:44 +00:00
Dylan DPC
720a82dd52
Rollup merge of #101545 - TaKO8Ki:remove-unnecessary-partialord-ord, r=oli-obk
Remove unnecessary `PartialOrd` and `Ord`
2022-09-08 20:48:38 +05:30
Dylan DPC
12b810063d
Rollup merge of #101498 - petrochenkov:visparam, r=cjgillot
rustc: Parameterize `ty::Visibility` over used ID

It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
2022-09-08 11:55:09 +05:30
Takayuki Maeda
bdc865d8f7 remove unnecessary PartialOrd and Ord 2022-09-08 06:15:33 +09:00
Santiago Pastorino
e3a738a942
Add instrument and debug calls 2022-09-07 10:46:14 -03:00
Vadim Petrochenkov
d8d3b83e3a rustc: Parameterize ty::Visibility over used ID
It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
2022-09-07 13:35:41 +04:00
bors
6c358c67d4 Auto merge of #101241 - camsteffen:refactor-binding-annotations, r=cjgillot
`BindingAnnotation` refactor

* `ast::BindingMode` is deleted and replaced with `hir::BindingAnnotation` (which is moved to `ast`)
* `BindingAnnotation` is changed from an enum to a tuple struct e.g. `BindingAnnotation(ByRef::No, Mutability::Mut)`
* Associated constants added for convenience `BindingAnnotation::{NONE, REF, MUT, REF_MUT}`

One goal is to make it more clear that `BindingAnnotation` merely represents syntax `ref mut` and not the actual binding mode. This was especially confusing since we had `ast::BindingMode`->`hir::BindingAnnotation`->`thir::BindingMode`.

I wish there were more symmetry between `ByRef` and `Mutability` (variant) naming (maybe `Mutable::Yes`?), and I also don't love how long the name `BindingAnnotation` is, but this seems like the best compromise. Ideas welcome.
2022-09-06 03:16:29 +00:00
Yuki Okushi
0d8a1f4cbf
Rollup merge of #101447 - cjgillot:no-remap-resolver, r=spastorino
Remove generics_def_id_map from the resolver.

This is internal state for lowering.  This does not belong in the resolver.

r? ``@spastorino``
2022-09-06 08:36:10 +09:00
Camille GILLOT
037ab1d183 Remove generics_def_id_map from the resolver. 2022-09-05 13:32:13 +02:00
Dylan DPC
e4534fe6fe
Rollup merge of #101391 - matthiaskrgr:perf0309, r=oli-obk
more clippy::perf fixes
2022-09-05 14:15:52 +05:30
Matthias Krüger
6f4726541e more clippy::perf fixes 2022-09-03 22:57:22 +02:00
Camille GILLOT
e7164267a2 Do not call object_lifetime_default on lifetime params. 2022-09-03 21:11:42 +02:00
Cameron Steffen
02ba216e3c Refactor and re-use BindingAnnotation 2022-09-02 12:55:05 -05:00
Guillaume Gomez
1aaf9aec95
Rollup merge of #100147 - Bryanskiy:private-in-public, r=petrochenkov
optimization of access level table construction

Refactoring which was mentioned in #87487
2022-09-02 11:34:48 +02:00
bors
2e35f954ad Auto merge of #98960 - cjgillot:entry-kind, r=estebank
Remove EntryKind from metadata.

This PR continues the refactor of metadata emission to be more systematic, iterating on definitions and filtering based on each definition's `DefKind`. This allows to remove the large `EntryKind` enum, replaced by linear tables in metadata.
2022-09-01 19:31:14 +00:00
Oli Scherer
ee3c835018 Always import all tracing macros for the entire crate instead of piecemeal by module 2022-09-01 14:54:27 +00:00
Oli Scherer
d3b22c7267 Directly use the instrument macro instead of its full path 2022-09-01 14:53:46 +00:00
bors
b32223fec1 Auto merge of #100707 - dzvon:fix-typo, r=davidtwco
Fix a bunch of typo

This PR will fix some typos detected by [typos].

I only picked the ones I was sure were spelling errors to fix, mostly in
the comments.

[typos]: https://github.com/crate-ci/typos
2022-09-01 05:39:58 +00:00
Bryanskiy
10804672c2 access_levels.rs refactor 2022-08-31 14:23:01 +03:00
Dezhi Wu
b1430fb7ca Fix a bunch of typo
This PR will fix some typos detected by [typos].

I only picked the ones I was sure were spelling errors to fix, mostly in
the comments.

[typos]: https://github.com/crate-ci/typos
2022-08-31 18:24:55 +08:00
Donough Liu
3f66efde75 Fix uintended diagnostic caused by drain(..) 2022-08-31 04:12:46 +01:00
Camille GILLOT
b94d421d08 Remove fn_has_self_parameter table. 2022-08-30 19:06:30 +02:00
bors
0631ea5d73 Auto merge of #101183 - Dylan-DPC:rollup-6kewixv, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #95376 (Add `vec::Drain{,Filter}::keep_rest`)
 - #100092 (Fall back when relating two opaques by substs in MIR typeck)
 - #101019 (Suggest returning closure as `impl Fn`)
 - #101022 (Erase late bound regions before comparing types in `suggest_dereferences`)
 - #101101 (interpret: make read-pointer-as-bytes a CTFE-only error with extra information)
 - #101123 (Remove `register_attr` feature)
 - #101175 (Don't --bless in pre-push hook)
 - #101176 (rustdoc: remove unused CSS selectors for `.table-display`)
 - #101180 (Add another MaybeUninit array test with const)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-30 08:29:42 +00:00
Dylan DPC
c18292f6a3
Rollup merge of #101123 - JohnTitor:rm-register-attr, r=TaKO8Ki
Remove `register_attr` feature

Closes #66080

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-08-30 11:26:52 +05:30
bors
a0d07093f8 Auto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrum
Revert let_chains stabilization

This is the revert against master, the beta revert was already done in #100538.

Bumps the stage0 compiler which already has it reverted.
2022-08-30 05:48:22 +00:00
Nilstrieb
d1ef8180f9 Revert let_chains stabilization
This reverts commit 3266460749.

This is the revert against master, the beta revert was already done in #100538.
2022-08-29 19:34:11 +02:00
Dylan DPC
5555e13a6e
Rollup merge of #99821 - cjgillot:ast-lifetimes-2, r=compiler-errors
Remove separate indexing of early-bound regions

~Based on https://github.com/rust-lang/rust/pull/99728.~

This PR copies some modifications from https://github.com/rust-lang/rust/pull/97839 around object lifetime defaults.
These modifications allow to stop counting generic parameters during lifetime resolution, and rely on the indexing given by `rustc_typeck::collect`.
2022-08-29 16:49:39 +05:30
bors
ce36e88256 Auto merge of #100497 - kadiwa4:remove_clone_into_iter, r=cjgillot
Avoid cloning a collection only to iterate over it

`@rustbot` label: +C-cleanup
2022-08-28 18:31:08 +00:00
Yuki Okushi
76dd5c58a0
Remove register_attr feature
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-08-28 21:23:23 +09:00
Vadim Petrochenkov
fc3f3c304b rustc_middle: Remove Visibility::Invisible 2022-08-27 22:34:18 +03:00
Michael Goulet
54744601bf
Rollup merge of #100817 - vincenzopalazzo:macros/bool_spelling_sugg, r=davidtwco
sugg: suggest the usage of boolean value when there is a typo in the keyword

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

This adds a new suggestion when there is a well-known typo

With the following program

```rust
fn main() {
    let x = True;
}
```

Now we have the following suggestion

```
error[E0425]: cannot find value `True` in this scope
 --> test.rs:2:13
  |
2 |     let x = True;
  |             ^^^^ not found in this scope
  |
help: you may want to use a bool value instead
  |
2 |     let x = true;
  |             ~~~~

error: aborting due to previous error
```

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-08-26 15:56:26 -07:00
Matthias Krüger
1c0f60f904
Rollup merge of #100901 - TaKO8Ki:make-some-methods-private, r=sanxiyn
Make some methods private
2022-08-24 18:20:12 +02:00
Vincenzo Palazzo
69715c9033 sugg: suggest the usage of boolean value when there is a typo in the keyword
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-08-22 22:53:40 +00:00
Camille GILLOT
dff428013d Mark suggestion as MaybeIncorrect. 2022-08-23 00:09:58 +02:00
Camille GILLOT
da9ccc2c98 Remove FnItemRibKind. 2022-08-23 00:08:42 +02:00
Camille GILLOT
613dc2204d Improve local generic parameter suggestions. 2022-08-23 00:08:42 +02:00
Camille GILLOT
d7d701a9dc Create specific ConstantHasGenerics for ConstantItemRibKind. 2022-08-23 00:08:42 +02:00
Takayuki Maeda
000dc80221 make some methods private 2022-08-22 18:12:18 +09:00
Dylan DPC
769ad70129
Rollup merge of #100592 - cjgillot:debug-import-kind, r=TaKO8Ki
Manually implement Debug for ImportKind.

This avoids crashing due to an infinite loop when running with `RUSTC_LOG=rustc_resolve`.
2022-08-19 12:26:44 +05:30
Matthias Krüger
b295639f14
Rollup merge of #100643 - TaKO8Ki:point-at-type-parameter-shadowing-another-type, r=estebank
Point at a type parameter shadowing another type

This patch fixes a part of #97459.
2022-08-18 05:10:46 +02:00
Takayuki Maeda
1886aef035 point at a type parameter shadowing another type 2022-08-17 04:53:06 +09:00
Camille Gillot
611221d8ae
Update compiler/rustc_resolve/src/imports.rs 2022-08-15 20:51:32 +02:00
Camille GILLOT
4a5c46fb02 Manually implement Debug for ImportKind. 2022-08-15 18:29:43 +02:00
Michael Goulet
e248c7f9ae
Rollup merge of #100367 - fmease:fix-100365, r=compiler-errors
Suggest the path separator when a dot is used on a trait

Fixes #100365.

`@rustbot` label A-diagnostics
r? diagnostics
2022-08-13 21:06:49 -07:00
KaDiWa
4eebcb9910
avoid cloning and then iterating 2022-08-13 16:16:52 +02:00
Mark Rousskov
154a09dd91 Adjust cfgs 2022-08-12 16:28:15 -04:00
León Orell Valerian Liehr
0fb4ef6769 Suggest path separator when a dot is used on a trait 2022-08-11 23:09:39 +02:00
Matthias Krüger
8237efc52d
Rollup merge of #100392 - nnethercote:simplify-visitors, r=cjgillot
Simplify visitors

By removing some unused arguments.

r? `@cjgillot`
2022-08-11 22:53:08 +02:00
Dylan DPC
b5f5bdce87
Rollup merge of #100351 - compiler-errors:diagnostic-convention, r=fee1-dead
Use `&mut Diagnostic` instead of `&mut DiagnosticBuilder` unless needed

This seems to be the established convention (02ff9e0) when `DiagnosticBuilder` was first added. I am guilty of introducing some of these.
2022-08-11 22:47:03 +05:30
Nicholas Nethercote
232bd80130 Simplify rustc_ast::visit::Visitor::visit_poly_trait_ref.
It is passed an argument that is never used.
2022-08-11 11:10:01 +10:00
Camille GILLOT
9701845287 Do not consider method call receiver as an argument in AST. 2022-08-10 18:34:54 +02:00
Michael Goulet
a2b6744af0 Use &mut Diagnostic instead of &mut DiagnosticBuilder unless needed 2022-08-10 03:45:42 +00:00
Dylan DPC
fac84e8bb6
Rollup merge of #100228 - luqmana:suggestion-ice, r=estebank
Don't ICE while suggesting updating item path.

When an item isn't found, we may suggest an appropriate import to `use`. Along with that, we also suggest updating the path to work with the `use`. Unfortunately, if the code in question originates from a macro, the span used to indicate which part of the path needs updating may not be suitable and cause an ICE (*). Since, such code is not adjustable directly by the user without modifying the macro, just skip the suggestion in such cases.

(*) The ICE happens because the emitter want to indicate to the user what code to delete by referencing a certain span. But in this case, said span has `lo == hi == 0` which means it thinks it's a dummy span. Adding a space before the proc macro attribute is enough to stop it from ICE'ing but even then the suggestion doesn't really make any sense:
```
help: if you import `DataStore`, refer to it directly
  |
1 -  #[dbstruct::dbstruct]
1 +  #[dbstruct::dbstruct]
```

Since suggestions are best-effort, I just gated this one on `can_be_used_for_suggestions` which catches cases like this.

Fixes #100199
2022-08-09 17:34:55 +05:30
Camille GILLOT
f6af4efec5 Use start_point instead of next_point to point to elided lifetime ampersand. 2022-08-07 14:35:11 +02:00
Luqman Aden
fc83a0cb57 Don't ICE while suggesting updating item path.
When an item isn't found, we may suggest an appropriate import to
`use`. Along with that, we also suggest updating the path to work
with the `use`. Unfortunately, if the code in question originates
from a macro, the span used to indicate which part of the path
needs updating may not be suitable and cause an ICE. Since, such
code is not adjustable directly by the user without modifying the
macro, just skip the suggestion in such cases.
2022-08-07 04:03:28 -07:00
Santiago Pastorino
c0923c8934
Add docs to generics_def_id_map 2022-08-04 11:27:03 -03:00
Santiago Pastorino
1d6cebfd6b
Implement def_id based remapping 2022-08-04 11:26:57 -03:00
bors
6f18f0a9d4 Auto merge of #99953 - cjgillot:in-path-always, r=petrochenkov
Always create elided lifetimes, even if inferred.

`PathSource` gives the context in which a path is encountered.  The same `PathSource` is used for the full path and the `QSelf` part.

Therefore, we can only rely on `PathSource` to know whether typechecking will be able to infer the lifetimes, not whether we need to insert them at all.

Fixes https://github.com/rust-lang/rust/issues/99949
2022-08-04 10:21:40 +00:00
Camille GILLOT
c95ff1d52b Assert index sanity. 2022-08-03 18:44:19 +02:00
Camille GILLOT
a424090252 Simplify debugging. 2022-08-03 18:44:19 +02:00
Camille GILLOT
48bae9360f Use DefIdTree instead of open-coding it. 2022-08-03 18:44:18 +02:00
Camille GILLOT
421bb6ac62 Remove index from Region::EarlyBound. 2022-08-03 18:44:18 +02:00
Camille GILLOT
99e2d33315 Compute object_lifetime_default per parameter. 2022-08-03 18:42:04 +02:00
Camille GILLOT
236ccce79e Create a specific ObjectLifetimeDefault enum. 2022-08-03 18:42:03 +02:00
Camille GILLOT
39bc74e8b8 Make object_lifetime_defaults a cross-crate query. 2022-08-03 18:32:21 +02:00
Camille GILLOT
ec3f3074a1 Always create elided lifetimes, even if inferred. 2022-07-30 17:58:26 +02:00
Camille GILLOT
6733bc3066 Remove guess_head_span. 2022-07-28 23:14:04 +02:00
Takayuki Maeda
089471b129 change the type of note field to Option<String> 2022-07-28 18:17:55 +09:00
Guillaume Gomez
c37ee1a7e0
Rollup merge of #99728 - cjgillot:ast-lifetimes-anon-clean, r=petrochenkov
Clean up HIR-based lifetime resolution

Based on https://github.com/rust-lang/rust/pull/97313.

Fixes #98932.

r? `@petrochenkov`
2022-07-27 17:55:07 +02:00
Camille GILLOT
4b2f06b8a9 Pacify tidy. 2022-07-26 19:00:31 +02:00
Camille GILLOT
556b02704f Stop creating anonymous late lifetimes. 2022-07-26 19:00:31 +02:00
Camille GILLOT
ad1b1819eb Remove resolve_elided_lifetimes. 2022-07-26 19:00:31 +02:00
Camille GILLOT
30565e5871 Stop resolving lifetime elision on HIR. 2022-07-26 19:00:31 +02:00
Camille GILLOT
267d3620a5 Move fn parameter ribs outwards. 2022-07-26 19:00:31 +02:00
Camille GILLOT
10be0dd8df Replace LifetimeRes::Anonymous by LifetimeRes::Infer. 2022-07-26 19:00:31 +02:00
Camille GILLOT
ab63591f00 Remove the distinction between LifetimeName::Implicit and LifetimeName::Underscore. 2022-07-26 19:00:31 +02:00
Camille GILLOT
a2254d5d7c Do not produce extra lifetime parameters when not needed. 2022-07-26 19:00:30 +02:00
Matthias Krüger
ddb6a46316
Rollup merge of #99729 - cjgillot:rm-unused-tuple, r=michaelwoerister
Remove unused tuple fields

Found by https://github.com/rust-lang/rust/pull/95977
2022-07-26 16:57:50 +02:00
Yuki Okushi
85afb90788
Rollup merge of #99718 - TaKO8Ki:avoid-&str-symbol-to-string-conversions, r=michaelwoerister
Avoid `&str`/`Symbol` to `String` conversions

follow-up to #99342 and #98668
2022-07-26 13:12:23 +09:00
bors
6dbae3ad19 Auto merge of #97313 - cjgillot:ast-lifetimes-anon, r=petrochenkov
Resolve function lifetime elision on the AST

~Based on https://github.com/rust-lang/rust/pull/97720~

Lifetime elision for functions is purely syntactic in nature, so can be resolved on the AST.
This PR replicates the elision logic and diagnostics on the AST, and replaces HIR-based resolution by a `delay_span_bug`.

This refactor allows for more consistent diagnostics, which don't have to guess the original code from HIR.

r? `@petrochenkov`
2022-07-25 20:02:55 +00:00
Camille GILLOT
9450f822fb Unused tuple fields in rustc_resolve. 2022-07-25 19:45:26 +02:00
Camille GILLOT
3148ea31eb Update file description. 2022-07-25 19:19:23 +02:00
Camille GILLOT
3c5048d2ec Report elision failures on the AST. 2022-07-25 19:19:23 +02:00
Takayuki Maeda
051e98b7bf avoid &str/Symbol to String conversions 2022-07-25 22:40:00 +09:00
bors
7f93d4aa0d Auto merge of #98770 - klensy:no-string-dupes-ugly, r=cjgillot
rmeta: avoid embedding `StabilityLevel::Unstable` reason multiple times into .rmeta\.rlib files

Avoids bloating size of some rmeta\rlib files by not placing default string for `StabilityLevel::Unstable` reason multiple times, affects only stdlib\rustc artifacts. For stdlib cuts about 3% (diff of total size for patched\unpatched *.rmeta files of stage1-std) of file size, depending on crates.

fixes #88180
2022-07-25 05:27:17 +00:00
Jordan McQueen
e0c9be539a Use span_bug in case of unexpected rib kind
Extremely minor QOL change to improve the ICE output in case this
default match case is encountered (an unexpected rib kind).
2022-07-23 13:26:45 +09:00
klensy
b38c94857d avoid embedding StabilityLevel::Unstable reason string into metadata multiple times 2022-07-21 22:53:02 +03:00
Matthias Krüger
230b775719
Rollup merge of #99528 - matthiaskrgr:2022_07_perf, r=estebank
couple of clippy::perf fixes
2022-07-21 18:42:07 +02:00
Camille GILLOT
bfd0435fd7 Introduce AnonymousLifetimeRib::Elided and use it for implied 'static. 2022-07-20 22:12:12 +02:00
Matthias Krüger
4b21ad26df
Rollup merge of #99508 - TaKO8Ki:avoid-symbol-to-string-conversion-in-BuiltinLintDiagnostics, r=compiler-errors
Avoid `Symbol` to `String` conversions

follow-up to #99342
2022-07-20 18:58:20 +02:00
David Wood
224aec213d middle: add implies_by to #[unstable]
If part of a feature is stabilized and a new feature is added for the
remaining parts, then the `implied_by` attribute can be used to indicate
which now-stable feature previously contained a item. If the now-stable
feature is still active (if the user has only just updated rustc, for
example) then there will not be an stability error for uses of the item
from the implied feature.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-20 14:53:01 +01:00
Matthias Krüger
611bbcb044 clippy::perf fixes 2022-07-20 11:48:11 +02:00
Takayuki Maeda
56e7777755 avoid &str to String conversions 2022-07-20 18:19:57 +09:00
Matthias Krüger
4815f94c51
Rollup merge of #99401 - TaKO8Ki:avoid-symbol-to-&str-conversions, r=nnethercote
Avoid `Symbol` to `&str` conversions

`Symbol::as_str` is a slowish operation, so this patch removes some usages of it.
2022-07-19 13:30:46 +02:00
bors
96c2df810b Auto merge of #98120 - TaKO8Ki:box-diagnostic-metadata-field, r=estebank
[Experiment] Box `diagnostic_metadata` field

closes #97954

r? `@estebank`
2022-07-19 03:02:30 +00:00
Takayuki Maeda
a22934bea1 avoid Symbol to &str conversions 2022-07-18 14:25:34 +09:00
Caio
3266460749 Stabilize let_chains 2022-07-16 20:17:58 -03:00
Dylan DPC
e5a86d7358
Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot
Implement `for<>` lifetime binder for closures

This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following:

```rust
let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) };
//       ^^^^^^^^^^^--- new!
```

cc ``@Aaron1011`` ``@cjgillot``
2022-07-14 14:14:21 +05:30
Dylan DPC
f5e9cb53ab
Rollup merge of #97720 - cjgillot:all-fresh, r=petrochenkov
Always create elided lifetime parameters for functions

Anonymous and elided lifetimes in functions are sometimes (async fns) --and sometimes not (regular fns)-- desugared to implicit generic parameters.

This difference of treatment makes it some downstream analyses more complicated to handle.  This step is a pre-requisite to perform lifetime elision resolution on AST.

There is currently an inconsistency in the treatment of argument-position impl-trait for functions and async fns:
```rust
trait Foo<'a> {}
fn foo(t: impl Foo<'_>) {} //~ ERROR missing lifetime specifier
async fn async_foo(t: impl Foo<'_>) {} //~ OK
fn bar(t: impl Iterator<Item = &'_ u8>) {} //~ ERROR missing lifetime specifier
async fn async_bar(t: impl Iterator<Item = &'_ u8>) {} //~ OK
```

The current implementation reports "missing lifetime specifier" on `foo`, but **accepts it** in `async_foo`.
This PR **proposes to accept** the anonymous lifetime in both cases as an extra generic lifetime parameter.
This change would be insta-stable, so let's ping t-lang.
Anonymous lifetimes in GAT bindings keep being forbidden:
```rust
fn foo(t: impl Foo<Assoc<'_> = Bar<'_>>) {}
                         ^^        ^^
                       forbidden   ok
```
I started a discussion here: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Anonymous.20lifetimes.20in.20universal.20impl-trait/near/284968606

r? ``@petrochenkov``
2022-07-14 14:14:19 +05:30
Camille GILLOT
5a20834884 Add feature gate. 2022-07-13 14:17:09 +02:00
Camille GILLOT
031b2c53cd Always use CreateParameter mode for function definitions. 2022-07-13 14:14:37 +02:00
Takayuki Maeda
f65bf0b2bb avoid &str to String conversions 2022-07-13 13:24:38 +09:00
Maybe Waffle
df4fee9841 Add an indirection for closures in hir::ExprKind
This helps bring `hir::Expr` size down, `Closure` was the biggest
variant, especially after `for<>` additions.
2022-07-12 21:00:13 +04:00
Maybe Waffle
3ebb852956 Add LifetimeBinderKind::Closure 2022-07-12 21:00:13 +04:00
Maybe Waffle
0c284843ba make for<> in closures a possible place to suggest adding named lifetime 2022-07-12 21:00:13 +04:00
Maybe Waffle
c2dbd62c7c Lower closure binders to hir & properly check them 2022-07-12 21:00:03 +04:00
Maybe Waffle
40ae7b5b8e Parse closure binders
This is first step in implementing RFC 3216.
- Parse `for<'a>` before closures in ast
  - Error in lowering
- Add `closure_lifetime_binder` feature
2022-07-12 16:25:16 +04:00
bors
38b72154de Auto merge of #98637 - cjgillot:bare-trait-anon-lt, r=petrochenkov
Create fresh lifetime parameters for bare fn trait too

The current code fails to account for the equivalence between `dyn FnMut(&mut u8)` and bare `FnMut(&mut u8)`, and treated them differently.

This PR introduces a special case for `Fn` traits, which are always fully resolved.

Fixes #98616
Fixes #98726
This will require a beta-backport, as beta contains that bug.

r? `@petrochenkov`
2022-07-11 17:09:37 +00:00
Dylan DPC
9fc297a2ae
Rollup merge of #99140 - TaKO8Ki:implement-is-accessible-span, r=fee1-dead
Implement `SourceMap::is_span_accessible`

This patch adds `SourceMap::is_span_accessible` and replaces `span_to_snippet(span).is_ok()` and `span_to_snippet(span).is_err()` with it. This removes a `&str` to `String` conversion.
2022-07-11 15:19:32 +05:30
Takayuki Maeda
018155c3a2 rename a method 2022-07-11 16:51:19 +09:00
Takayuki Maeda
12d11e9a35 implement is_accessible_span 2022-07-11 11:36:15 +09:00
Matthias Krüger
86af7135ae
Rollup merge of #99103 - TaKO8Ki:avoid-&str-to-string-conversions, r=oli-obk
Avoid some `&str` to `String` conversions

This patch removes some `&str` to `String` conversions.
2022-07-10 11:52:17 +02:00
Takayuki Maeda
bda83e6543 avoid some &str to String conversions 2022-07-10 03:18:56 +09:00
Dylan DPC
d75a5723db
Rollup merge of #99008 - obeis:issue-98974, r=compiler-errors
Adding suggestion for E0530

Closes #98974
2022-07-09 11:28:06 +05:30
Obei Sideg
1b32eb34b3 Update ui test for the new E0530 suggestion 2022-07-08 14:54:11 +03:00
Obei Sideg
c2436d54d0 Check if E0530 is rustc_resolve::late::PatternSource::Match to emit suggestion 2022-07-08 14:06:50 +03:00
Obei Sideg
ea46e7a47e Check if E0530 is tuple variant or tuple struct to emit suggestion 2022-07-08 13:20:05 +03:00
Obei Sideg
51504dbf01 Adding suggestion for E0530 2022-07-07 21:00:01 +03:00
Deadbeef
2f0ccdfbba suggest adding a derive for #[default] applied to variants 2022-07-07 04:57:01 +00:00
bors
3dcb616888 Auto merge of #98959 - cjgillot:late-bound-order, r=michaelwoerister
Return a FxIndexSet in is_late_bound query.

This return value is iterated upon by borrowck, hence the need to preserve
a deterministic iteration order.

Fixes https://github.com/rust-lang/rust/issues/98890
Affects https://github.com/rust-lang/rust/issues/96655

I don't know if this supersedes https://github.com/rust-lang/rust/pull/98924 or fixes an unrelated bug.

r? `@michaelwoerister`
This may deserve a backport.
2022-07-06 17:38:48 +00:00
ClementTsang
503c669927 fix typo in note about multiple inaccessible type aliases
Mainly intended as a small typo fix ("aliass" -> "aliases") for
the case where a type cannot be found in scope, and there are
multiple inaccessible type aliases that match the missing type.

In general this change would use the correct plural form in
this scenario for words that end with 's'.
2022-07-05 21:21:12 -04:00
Camille GILLOT
2a7abed87f Return a FxIndexSet in is_late_bound query.
This return value is iterated upon by borrowck, hence the need to preserve
a deterministic iteration order.
2022-07-05 21:54:40 +02:00
Takayuki Maeda
eb80407d79 suggest #[derive(Default)] to enums with #[default] 2022-07-04 20:46:59 +09:00
bors
ada8c80bed Auto merge of #98673 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum
Bump bootstrap compiler

r? `@Mark-Simulacrum`
2022-07-03 06:55:50 +00:00
bors
5f98537eb7 Auto merge of #98569 - nnethercote:finalize_resolutions_id, r=cjgillot
Avoid unnecessary work in `finalize_resolutions_in`.

If `module.opt_def_id()` returns `None`, we can skip most of the work.

r? `@lqd`
2022-07-02 23:38:08 +00:00
Camille GILLOT
21a12e8ab7 Handle fresh lifetimes on bare trait objects. 2022-07-02 09:21:55 +02:00
Pietro Albini
6b2d3d5f3c
update cfg(bootstrap)s 2022-07-01 15:48:23 +02:00
Matthias Krüger
6ee667374e
Rollup merge of #98677 - lyming2007:issue-98492-fix, r=lcnr
For diagnostic information of Boolean, remind it as use the type: 'bool'

Fixes #98492.

It helps programmers coming from other languages
	modified:   compiler/rustc_resolve/src/late/diagnostics.rs
2022-06-30 19:55:53 +02:00
Yiming Lei
15d3ea504a For diagnostic information of Boolean, remind it as use the type: 'bool'
It helps programmers coming from other languages
	modified:   compiler/rustc_resolve/src/late/diagnostics.rs

	modified:   src/test/ui/lint/recommend-literal.rs
	modified:   src/test/ui/lint/recommend-literal.stderr

	modified:   compiler/rustc_resolve/src/late/diagnostics.rs
	modified:   src/test/ui/lint/recommend-literal.rs
	modified:   src/test/ui/lint/recommend-literal.stderr

	modified:   compiler/rustc_resolve/src/late/diagnostics.rs
	modified:   src/test/ui/lint/recommend-literal.rs
	modified:   src/test/ui/lint/recommend-literal.stderr
2022-06-30 08:34:10 -07:00
Matthias Krüger
d34c4ca9be
Rollup merge of #98668 - TaKO8Ki:avoid-many-&str-to-string-conversions, r=Dylan-DPC
Avoid some `&str` to `String` conversions with `MultiSpan::push_span_label`

This patch removes some`&str` to `String` conversions with `MultiSpan::push_span_label`.
2022-06-29 20:35:07 +02:00
Takayuki Maeda
6212e6b339 avoid many &str to String conversions with MultiSpan::push_span_label 2022-06-29 21:16:43 +09:00
Nicholas Nethercote
0e475b5d5e Avoid unnecessary work in finalize_resolutions_in.
If `module.opt_def_id()` returns `None`, we can skip most of the work.
2022-06-29 09:20:32 +10:00
Nicholas Nethercote
7c40661ddb Update smallvec to 1.8.1.
This pulls in https://github.com/servo/rust-smallvec/pull/282, which
gives some small wins for rustc.
2022-06-27 08:48:55 +10:00
Yuki Okushi
5e98e55668
Rollup merge of #98419 - WaffleLapkin:remove_excess_rib, r=compiler-errors
Remove excess rib while resolving closures

I've mentioned this on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.60ClosureOrAsyncRibKind.60.20weirdness/near/286982959), in `rustc_resolve`, while resolving closures we add an excess `ClosureOrAsyncRibKind`. It's excess because we later add another one in `visit_fn`.

I couldn't find a way in which removing this will break anything, all test seem to pass, etc.

r? ``@compiler-errors``
cc ``@davidtwco``
2022-06-24 16:43:49 +09:00
Michael Goulet
3b68700d0c
Rollup merge of #98269 - compiler-errors:provide-more-segment-res, r=petrochenkov
Provide a `PathSegment.res` in more cases

I find that in many cases, the `res` associated with a `PathSegment` is `Res::Err` even though the path was fully resolved. A few diagnostics use this `res` and their error messages suffer because of the lack of resolved segment.

This fixes it a bit, but it's obviously not complete and I'm not exactly sure if it's correct.
2022-06-23 14:39:07 -07:00
Maybe Waffle
9730221b9d Remove excess rib while resolving closures 2022-06-23 12:21:23 +04:00
bors
10f4ce324b Auto merge of #98279 - cjgillot:all-fresh-nofn, r=petrochenkov
Create elided lifetime parameters for function-like types

Split from https://github.com/rust-lang/rust/pull/97720

This PR refactor lifetime generic parameters in bare function types and parenthesized traits to introduce the additional required lifetimes as fresh parameters in a `for<>` bound.

This PR does the same to lifetimes appearing in closure signatures, and as-if introducing `for<>` bounds on closures (without the associated change in semantics).

r? `@petrochenkov`
2022-06-22 10:48:58 +00:00
Camille GILLOT
7437136f0e Use CreateParameter mode for closures too. 2022-06-21 21:13:43 +02:00
Camille GILLOT
32af719b07 Always create parameters for functions-like types. 2022-06-21 21:13:41 +02:00
Santiago Pastorino
5ed1495041
This comment is out dated and misleading
Arms are about TAIT and RPIT, as the variants clearly show.
2022-06-21 12:43:58 -03:00
Michael Goulet
f924e74fb1 Provide a segment res in more cases 2022-06-20 21:27:42 -07:00
Matthias Krüger
3e5800b8d3
Rollup merge of #98267 - compiler-errors:suggest-wildcard-arm, r=oli-obk
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 🌹)

Fixes #94866
2022-06-20 20:13:10 +02:00
Michael Goulet
047de83e02 Don't suggest adding Self as a type parameter 2022-06-19 19:44:00 -07:00
Michael Goulet
018c319b21 Mention what item is using an invalid Self type 2022-06-19 19:43:40 -07:00
Michael Goulet
52c9906c4b Use Span::eq_ctxt method instead of .ctxt() == .ctxt() 2022-06-19 16:46:59 -07:00
Camille GILLOT
bc6a2c11ee Leave the responsibility to create Fresh lifetimes to lowering. 2022-06-19 22:32:43 +02:00