Commit graph

13420 commits

Author SHA1 Message Date
Yuki Okushi
896a59d8db
Rollup merge of #97266 - est31:unknown_lints_cfg_attr, r=lcnr
Make weird name lints trigger behind cfg_attr

The weird name lints (`unknown_lints`, `renamed_and_removed_lints`), the lints that lint the linting, were previously not firing for lint level declarations behind `cfg_attr`, as they were only running before expansion.

Now, this will give a `unknown_lints` warning:

```Rust
#[cfg_attr(all(), allow(this_lint_does_not_exist))]
fn foo() {}
```

Lint level declarations behind a `cfg_attr` whose condition is not applying are still ignored. So this still won't give a warning:

```Rust
#[cfg_attr(any(), allow(this_lint_does_not_exist))]
fn foo() {}
```

Furthermore, this PR also makes the weird name lints respect level delcarations for *them* that were hidden by `cfg_attr`, making them consistent to other lints. So this will now not issue a warning:

```Rust
#[cfg_attr(all(), allow(unknown_lints))]
mod foo {
    #[allow(does_not_exist)]
    fn foo() {
    }
}
```

Fixes #97094
2022-05-25 07:08:42 +09:00
bors
fa70b89d19 Auto merge of #97356 - Dylan-DPC:rollup-bhceawj, r=Dylan-DPC
Rollup of 4 pull requests

Successful merges:

 - #97288 (Lifetime variance fixes for rustdoc)
 - #97298 (Parse expression after `else` as a condition if followed by `{`)
 - #97308 (Stabilize `cell_filter_map`)
 - #97321 (explain how to turn integers into fn ptrs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-24 16:23:32 +00:00
est31
2a8b60f915 Emit weird lint name lints after expansion
Previously, we were emitting weird name lints (for renamed or unknown lints)
before expansion, most importantly before cfg expansion.
This meant that the weird name lints would not fire
for lint attributes hidden inside cfg_attr. The same applied
for lint level specifications of those lints.

By moving the lints for the lint names to the post-expansion
phase, these issues are resolved.
2022-05-24 17:27:34 +02:00
Dylan DPC
0531521dbb
Rollup merge of #97298 - compiler-errors:if-else-stmt-braces, r=davidtwco
Parse expression after `else` as a condition if followed by `{`

Fixes #49361.

Two things:
1. This wording needs help. I can never find a natural/intuitive phrasing when I write diagnostics 😅
2. Do we even want to show the "wrap in braces" case? I would assume most of the time the "add an `if`" case is the right one.
2022-05-24 15:58:24 +02:00
Dylan DPC
3569a426b5
Rollup merge of #97288 - compiler-errors:tcxify-rustdoc, r=Dylan-DPC
Lifetime variance fixes for rustdoc

#97287 migrates rustc to a `Ty` type that is invariant over its lifetime `'tcx`, so I need to fix a bunch of places that assume that `Ty<'a>` and `Ty<'b>` can be unified by shortening both to some common lifetime.

This is doable, since everything is already `'tcx`, so all this PR does is be a bit more explicit that elided lifetimes are actually `'tcx`.

Split out from #97287 so the rustdoc team can review independently.
2022-05-24 15:58:24 +02:00
bors
ee9726cb10 Auto merge of #97291 - compiler-errors:lazy-is-actually-3-types-in-a-trenchcoat, r=cjgillot
Split out the various responsibilities of `rustc_metadata::Lazy`

`Lazy<T>` actually acts like three different types -- a pointer in the crate metadata to a single value, a pointer to a list/array of values, and an indexable pointer of a list of values (a table).

We currently overload `Lazy<T>` to work differently than `Lazy<[T]>` and the same for `Lazy<Table<I, T>>`. All is well with some helper adapter traits such as [`LazyQueryDecodable`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/decoder/trait.LazyQueryDecodable.html) and [`EncodeContentsForLazy`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/encoder/trait.EncodeContentsForLazy.html).

Well, changes in #97287 that make `Lazy` work with the now invariant lifetime `'tcx` make these adapters fall apart because of coherence reasons. So we split out these three types and rework some of the helper traits so it's both 1. more clear to understand, and 2. compatible with the changes later in that PR.

Split out from #97287 so it can be reviewed separately, since this PR stands on its own.
2022-05-24 13:42:33 +00:00
bors
b2eba058e6 Auto merge of #97121 - pvdrz:do-subdiagnostics-later, r=davidtwco
Avoid double binding of subdiagnostics inside `#[derive(SessionDiagnostic)]`

r? `@davidtwco`
2022-05-24 10:25:13 +00:00
bors
43d9f3859e Auto merge of #96098 - JakobDegen:always-return-place, r=oli-obk
Refactor call terminator to always include destination place

In #71117 people seemed to agree that call terminators should always have a destination place, even if the call was guaranteed to diverge. This implements that. Unsurprisingly, the diff touches a lot of code, but thankfully I had to do almost nothing interesting. The only interesting thing came up in const prop, where the stack frame having no return place was also used to indicate that the layout could not be computed (or similar). I replaced this with a ZST allocation, which should continue to do the right things.

cc `@RalfJung` `@eddyb` who were involved in the original conversation

r? rust-lang/mir-opt
2022-05-24 07:13:26 +00:00
Michael Goulet
9be37b2d3f Parse expression after else as a condition if followed by { 2022-05-23 21:09:35 -07:00
Yuki Okushi
1b59db45d4
Rollup merge of #97336 - tshepang:typo, r=cjgillot
typo
2022-05-24 12:18:33 +09:00
Yuki Okushi
8d9f258faa
Rollup merge of #97240 - TaKO8Ki:improve-errors-about-typos-on-variables, r=compiler-errors
Typo suggestion for a variable with a name similar to struct fields

closes #97133
2022-05-24 12:18:30 +09:00
Michael Goulet
2b5e592b7a Fix iterator implementation, add some inlines 2022-05-23 19:50:29 -07:00
Michael Goulet
14e5816f1b refine comments, disambiguate len for array and tables 2022-05-23 19:39:10 -07:00
Michael Goulet
ca5e60b7fb split out the various responsibilities of Lazy 2022-05-23 19:39:10 -07:00
Jakob Degen
09b0936db2 Refactor call terminator to always hold a destination place 2022-05-23 17:49:04 -04:00
Tshepang Lekhonkhobe
b96e5c6463 typo 2022-05-23 22:51:34 +02:00
Dylan DPC
f4bf64c3f0
Rollup merge of #97292 - compiler-errors:tcxify-rustc, r=davidtwco
Lifetime variance fixes for rustc

#97287 migrates rustc to a `Ty` type that is invariant over its lifetime `'tcx`, so I need to fix a bunch of places that assume that `Ty<'a>` and `Ty<'b>` can be unified by shortening both to some common lifetime.

This is doable, since many lifetimes are already `'tcx`, so all this PR does is be a bit more explicit that elided lifetimes are actually `'tcx`.

Split out from #97287 so the compiler team can review independently.
2022-05-23 15:11:04 +02:00
est31
cd251fb48e Fix typo 2022-05-23 14:07:40 +02:00
Takayuki Maeda
39caed08ae add typo suggestions for all AssocSuggestion variants 2022-05-23 19:58:20 +09:00
bors
32c8c5df06 Auto merge of #97195 - notriddle:notriddle/cleanup, r=GuillaumeGomez
rustdoc: shrink GenericArgs/PathSegment with boxed slices

This PR also contains a few cleanup bits and pieces, but one of them is a broken intra-doc link, and the other is removing an unused Hash impl. The last commit is the one that matters.
2022-05-23 10:46:50 +00:00
Dylan DPC
b5ff4ad02c
Rollup merge of #97303 - compiler-errors:arg-typos, r=jackh726
Fix some typos in arg checking algorithm

Fixes #97197

Also fixes a typo where if we're missing args A, B, C, we actually say A, B, B
2022-05-23 07:43:52 +02:00
Dylan DPC
b73f1c77a7
Rollup merge of #97254 - jhpratt:remove-crate-vis, r=cjgillot
Remove feature: `crate` visibility modifier

FCP completed in #53120.
2022-05-23 07:43:50 +02:00
Michael Goulet
21a7b4cb97 Fix some typos in arg checking algorithm 2022-05-22 22:07:09 -07:00
Michael Goulet
1784634a39 Lifetime variance fixes for rustc 2022-05-22 14:29:32 -07:00
Michael Goulet
b2a95cb582 Lifetime variance fixes for rustdoc 2022-05-22 14:22:40 -07:00
bors
b2eed72a6f Auto merge of #97281 - est31:remove_box, r=compiler-errors
Remove box syntax from rustc_mir_dataflow and rustc_mir_transform

Continuation of #87781, inspired by #97239. The usages that this PR removes have not appeared from nothing, instead the usage in `rustc_mir_dataflow` and `rustc_mir_transform` was from #80522 which split up `rustc_mir`, and which was filed before I filed #87781, so it was using the state from before my PR. But it was merged after my PR was merged, so the `box_syntax` uses were able to survive here. Outside of this introduction due to the code being outside of the master branch at the point of merging of my PR, there was only one other introduction of box syntax, in #95159. That box syntax was removed again though in #95555. Outside of that, `box_syntax` has not made its reoccurrance in compiler crates.
2022-05-22 19:16:17 +00:00
est31
99603ef074 Remove box syntax from rustc_mir_dataflow and rustc_mir_transform 2022-05-22 17:19:44 +02:00
Jack Huey
683a9c8391 Do leak check after function ptr coercion 2022-05-22 11:18:36 -04:00
bors
4bb4dc4672 Auto merge of #97251 - petrochenkov:eqtokens, r=nnethercote
rustc_parse: Move AST -> TokenStream conversion logic to rustc_ast

In the past falling back to reparsing pretty-printed strings was common, so some of this logic had to live in `rustc_parse`, but now the reparsing fallback is only used in two corner cases so we can move this logic to `rustc_ast` which makes many things simpler.

It also helps to fix `MacArgs::inner_tokens` for `MacArgs::Eq` with non-literal expressions, which is done in the second commit.
r? `@nnethercote`
2022-05-22 11:51:25 +00:00
Vadim Petrochenkov
09b4c7c89d rustc_ast: Support MacArgs::inner_tokens for arbitrary expressions 2022-05-22 12:01:07 +03:00
Vadim Petrochenkov
8e8fb4f49e rustc_parse: Move AST -> TokenStream conversion logic to rustc_ast 2022-05-22 12:01:07 +03:00
bors
653463731a Auto merge of #95563 - dingxiangfei2009:dxf-rfc66-refactor, r=nikomatsakis
Move the extended lifetime resolution into typeck context

Related to #15023

This PR is based on the [idea](https://github.com/rust-lang/rust/issues/15023#issuecomment-1070931433) of #15023 by `@nikomatsakis.`

This PR specifically proposes to
- Delay the resolution of scopes of rvalues to a later stage, so that enough type information is available to refine those scopes based on relationships of lifetimes.
- Highlight relevant parts that would help future reviews on the next installments of works to fully implement a solution to RFC 66.
2022-05-22 09:00:30 +00:00
Ding Xiang Fei
6044fbe462
factor out the rvalue lifetime rule
remove region_scope_tree from RegionCtxt

Apply suggestions from code review

Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-05-22 16:46:50 +08:00
bors
acfd327fd4 Auto merge of #97177 - oli-obk:const-stability, r=davidtwco
Implement proper stability check for const impl Trait, fall back to unstable const when undeclared

Continuation of #93960

`@jhpratt` it looks to me like the test was simply not testing for the failure you were looking for? Your checks actually do the right thing for const traits?
2022-05-22 06:47:36 +00:00
Yuki Okushi
97e1ab0005
Rollup merge of #97259 - jyn514:fix-typo, r=JohnTitor
Fix typo in Mir phase docs
2022-05-22 11:53:09 +09:00
Yuki Okushi
6ef4911b99
Rollup merge of #97236 - cjgillot:recover-lifetime-res, r=jackh726
Recover when resolution did not resolve lifetimes.

This can happen for items inside a foreign fn's body, which are not visited at all.

Fixes https://github.com/rust-lang/rust/issues/97193
Fixes https://github.com/rust-lang/rust/issues/97194
2022-05-22 11:53:07 +09:00
bors
e52e7115c7 Auto merge of #96515 - lcnr:user-types-in-pat, r=nikomatsakis
correctly deal with user type ascriptions in pat

supersedes #93856

`thir::PatKind::AscribeUserType` previously resulted in `CanonicalUserTypeAnnotations` where the inferred type already had a subtyping relation according to `variance` to the `user_ty`.

The bug can pretty much be summarized as follows:

- during mir building
  - `user_ty -> inferred_ty`: considers variance
  - `StatementKind::AscribeUserType`: `inferred_ty` is the type of the place, so no variance needed
- during mir borrowck
  - `user_ty -> inferred_ty`: does not consider variance
  - `StatementKind::AscribeUserType`: applies variance

This mostly worked fine. The lifetimes in `inferred_ty` were only bound by its relation to `user_ty` and to the `place` of `StatementKind::AscribeUserType`, so it doesn't matter where exactly the subtyping happens.

It does however matter when having higher ranked subtying. At this point the place where the subtyping happens is forced, causing this mismatch between building and borrowck to result in unintended errors.

cc #96514 which is pretty much the same issue

r? `@nikomatsakis`
2022-05-21 23:34:30 +00:00
Joshua Nelson
0c92d1c7f3 Fix typo in Mir phase docs 2022-05-21 16:21:44 -05:00
Jacob Pratt
7b987e34c0
Merge crate and restricted visibilities 2022-05-21 17:02:55 -04:00
Jacob Pratt
8cece636b2
Remove feature: crate visibility modifier 2022-05-21 14:22:06 -04:00
Michael Howell
98b98ac11e Fix broken intra-doc link 2022-05-21 07:53:45 -07:00
Guillaume Gomez
85dfd065b1
Rollup merge of #97232 - tshepang:typo, r=Dylan-DPC
typo
2022-05-21 11:39:52 +02:00
Guillaume Gomez
54e36ef1b3
Rollup merge of #97223 - cjgillot:linear-hir-tree, r=jackh726
Remove quadratic behaviour from -Zunpretty=hir-tree.

Closes https://github.com/rust-lang/rust/issues/97115
2022-05-21 11:39:51 +02:00
Camille GILLOT
075429f76b Recover when resolution did not resolve lifetimes. 2022-05-21 09:39:41 +02:00
bors
4f372b14de Auto merge of #97239 - jhpratt:remove-crate-vis, r=joshtriplett
Remove `crate` visibility modifier

FCP to remove this syntax is just about complete in #53120. Once it completes, this should be merged ASAP to avoid merge conflicts.

The first two commits remove usage of the feature in this repository, while the last removes the feature itself.
2022-05-21 06:38:49 +00:00
lcnr
db11c1939c update mir user type printing and apparently fix an ICE 2022-05-21 08:13:17 +02:00
lcnr
39a03779f8 correctly deal with user type ascriptions in pat 2022-05-21 08:13:17 +02:00
bors
3b64fe953c Auto merge of #96923 - eholk:fix-fake-read, r=nikomatsakis
Drop Tracking: Implement `fake_read` callback

This PR updates drop tracking's use of `ExprUseVisitor` so that we treat `fake_read` events as borrows. Without doing this, we were not handling match expressions correctly, which showed up as a breakage in the `addassign-yield.rs` test. We did not previously notice this because we still had rather large temporary scopes that we held borrows for, which changed in #94309.

This PR also includes a variant of the `addassign-yield.rs` test case to make sure we continue to have correct behavior here with drop tracking.

r? `@nikomatsakis`
2022-05-21 04:21:38 +00:00
Takayuki Maeda
42e9f2daf3 typo suggestion for a variable with a name similar to struct fields 2022-05-21 12:55:37 +09:00
Jacob Pratt
49c82f31a8
Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00