Commit Graph

13397 Commits

Author SHA1 Message Date
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
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
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
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
Jacob Pratt
49c82f31a8
Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
bors
e6a4afc3af Auto merge of #95418 - cjgillot:more-disk, r=davidtwco
Cache more queries on disk

One of the principles of incremental compilation is to allow saving results on disk to avoid recomputing them.
This PR investigates persisting a lot of queries whose result are to be saved into metadata.
Some of the queries are cheap reads from HIR, but we may also want to get rid of these reads for incremental lowering.
2022-05-20 20:49:55 +00:00
Tshepang Lekhonkhobe
bb8a1205c6 typo 2022-05-20 22:02:20 +02:00
Niko Matsakis
bf21a81b15
Update compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs 2022-05-20 15:54:22 -04:00
bors
536020c5f9 Auto merge of #97224 - matthiaskrgr:rollup-it5nw68, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #97109 (Fix misleading `cannot infer type for type parameter` error)
 - #97187 (Reverse condition in Vec::retain_mut doctest)
 - #97201 (Fix typo)
 - #97203 (Minor tweaks to rustc book summary formatting.)
 - #97208 (Do not emit the lint `unused_attributes` for *inherent* `#[doc(hidden)]` associated items)
 - #97215 (Add complexity estimation of iterating over HashSet and HashMap)
 - #97220 (Add regression test for#81827)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-20 18:21:26 +00:00
Matthias Krüger
2941434d1b
Rollup merge of #97208 - fmease:fix-issue-97205, r=oli-obk
Do not emit the lint `unused_attributes` for *inherent* `#[doc(hidden)]` associated items

Fixes #97205 (embarrassing oversight from #96008).

`@rustbot` label A-lint
2022-05-20 19:54:43 +02:00
Matthias Krüger
76f662c963
Rollup merge of #97109 - TaKO8Ki:fix-misleading-cannot-infer-type-for-type-parameter-error, r=oli-obk
Fix misleading `cannot infer type for type parameter` error

closes #93198
2022-05-20 19:54:39 +02:00
Camille GILLOT
cd90406090 Remove quadratic behaviour from -Zunpretty=hir-tree. 2022-05-20 19:34:31 +02:00
bors
b5caa5a842 Auto merge of #96833 - cjgillot:ast-lifetimes-single, r=petrochenkov
Lint single-use lifetimes during AST resolution

This PR rewrites `single_use_lifetime` and `unused_lifetime` lints to be based on the AST.
We have more information at our disposal, so we can reduce the amount of false positives.

Remaining false positive: single-use lifetimes in argument-position impl-trait.
I'm waiting for https://github.com/rust-lang/rust/issues/96529 to be fixed to have a clean and proper solution here.

Closes https://github.com/rust-lang/rust/issues/54079
Closes https://github.com/rust-lang/rust/issues/55057
Closes https://github.com/rust-lang/rust/issues/55058
Closes https://github.com/rust-lang/rust/issues/60554
Closes https://github.com/rust-lang/rust/issues/69952

r? `@petrochenkov`
2022-05-20 15:40:33 +00:00
Takayuki Maeda
3d0f9fb544 report ambiguous type parameters when their parents are impl or fn
fix ci error

emit err for `impl_item`
2022-05-20 23:04:44 +09:00
bors
22ee39504a Auto merge of #97211 - GuillaumeGomez:rollup-jul7x7e, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #96565 (rustdoc: show implementations on `#[fundamental]` wrappers)
 - #97179 (Add new lint to enforce whitespace after keywords)
 - #97185 (interpret/validity: separately control checking numbers for being init and non-ptr)
 - #97188 (Remove unneeded null pointer asserts in ptr2int casts)
 - #97189 (Update .mailmap)
 - #97192 (Say "last" instead of "rightmost" in the documentation for `std::str:rfind`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-20 13:18:37 +00:00
Guillaume Gomez
9098f05b26
Rollup merge of #97188 - carbotaniuman:remove-null-assert, r=RalfJung
Remove unneeded null pointer asserts in ptr2int casts

This removes an assert that a pointer with address 0 has no provenance. This change is needed to support permissive provenance work in Miri, and seems justified by `ptr.with_addr(0)` working and a discussion on Zulip regarding LLVM semantics.

r? `@RalfJung`
2022-05-20 14:03:04 +02:00
Guillaume Gomez
706aa59efa
Rollup merge of #97185 - RalfJung:number-validity, r=oli-obk
interpret/validity: separately control checking numbers for being init and non-ptr

This lets Miri control this in a more fine-grained way.

r? `@oli-obk`
2022-05-20 14:03:03 +02:00
Camille GILLOT
563916d698 Lint single-use-lifetimes on the AST. 2022-05-20 12:26:37 +02:00
Camille GILLOT
db8a9274a9 Introduce BareFnTy::decl_span and fix generics span. 2022-05-20 12:26:37 +02:00
Camille GILLOT
5953c57f27 Introduce LifetimeCtxt. 2022-05-20 12:25:05 +02:00
lcnr
4a82bc9ea0 bool to custom enum 2022-05-20 11:50:07 +02:00
lcnr
ced65022da update error message 2022-05-20 11:50:07 +02:00