]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #99759 - bjorn3:remove_llvm_dead_code, r=nikic
Yuki Okushi [Wed, 27 Jul 2022 02:52:56 +0000 (11:52 +0900)]
Rollup merge of #99759 - bjorn3:remove_llvm_dead_code, r=nikic

Remove dead code from cg_llvm

Found while working on https://github.com/rust-lang/rust/pull/97485

2 years agoRollup merge of #99712 - davidtwco:translation-migrate-passes-2, r=compiler-errors
Yuki Okushi [Wed, 27 Jul 2022 02:52:55 +0000 (11:52 +0900)]
Rollup merge of #99712 - davidtwco:translation-migrate-passes-2, r=compiler-errors

passes: port more of `check_attr` module

Continues from #99213.

Port more diagnostics in `rustc_passes::check_attr` to using the diagnostic derive and translation machinery.

r? `@compiler-errors`

2 years agoRollup merge of #99700 - est31:rustdoc_layout_heading, r=GuillaumeGomez
Yuki Okushi [Wed, 27 Jul 2022 02:52:54 +0000 (11:52 +0900)]
Rollup merge of #99700 - est31:rustdoc_layout_heading, r=GuillaumeGomez

Add a clickable link to the layout section

The layout section (activated by `--show-type-layout`) is currently not linkable to (outside of chrome's link to text feature). This PR makes it linkable via `#layout`.

2 years agoRollup merge of #99698 - compiler-errors:no-doc-hidden, r=cjgillot
Yuki Okushi [Wed, 27 Jul 2022 02:52:53 +0000 (11:52 +0900)]
Rollup merge of #99698 - compiler-errors:no-doc-hidden, r=cjgillot

Prefer visibility map parents that are not `doc(hidden)` first

Far simpler approach to #98876.

This only fixes the case where the parent is `doc(hidden)`, not where the child is `doc(hidden)` since I don't know how to get the attrs on the import statement given a `ModChild`... I'll try to follow up with that, but this is a good first step.

2 years agoRollup merge of #98583 - joshtriplett:stabilize-windows-symlink-types, r=thomcc
Yuki Okushi [Wed, 27 Jul 2022 02:52:52 +0000 (11:52 +0900)]
Rollup merge of #98583 - joshtriplett:stabilize-windows-symlink-types, r=thomcc

Stabilize Windows `FileTypeExt` with `is_symlink_dir` and `is_symlink_file`

These calls allow detecting whether a symlink is a file or a directory,
a distinction Windows maintains, and one important to software that
wants to do further operations on the symlink (e.g. removing it).

2 years agoClarify safety comments
Ben Kimock [Wed, 27 Jul 2022 00:47:53 +0000 (20:47 -0400)]
Clarify safety comments

2 years agoAuto merge of #98553 - the8472:next_chunk_opt, r=Mark-Simulacrum
bors [Wed, 27 Jul 2022 01:12:30 +0000 (01:12 +0000)]
Auto merge of #98553 - the8472:next_chunk_opt, r=Mark-Simulacrum

Optimized vec::IntoIter::next_chunk impl

```
x86_64v1, default
test vec::bench_next_chunk                               ... bench:         696 ns/iter (+/- 22)
x86_64v1, pr
test vec::bench_next_chunk                               ... bench:         309 ns/iter (+/- 4)

znver2, default
test vec::bench_next_chunk                               ... bench:      17,272 ns/iter (+/- 117)
znver2, pr
test vec::bench_next_chunk                               ... bench:         211 ns/iter (+/- 3)
```

On znver2 the default impl seems to be slow due to different inlining decisions. It goes through `core::array::iter_next_chunk`
which has a deep call tree.

2 years agouse `pluralize!`
Takayuki Maeda [Wed, 27 Jul 2022 01:09:06 +0000 (10:09 +0900)]
use `pluralize!`

2 years agoAdd Buffer::consume_with to enable direct buffer access with one check
Ben Kimock [Wed, 27 Jul 2022 00:03:14 +0000 (20:03 -0400)]
Add Buffer::consume_with to enable direct buffer access with one check

2 years agoImplicitly set `--type=cargo` when using `--category=cargo`
Serial [Tue, 26 Jul 2022 23:32:34 +0000 (19:32 -0400)]
Implicitly set `--type=cargo` when using `--category=cargo`

2 years agoGive the user more information during creation
Serial [Tue, 26 Jul 2022 23:18:10 +0000 (19:18 -0400)]
Give the user more information during creation

2 years agoExplain how *mut [T] helps, and how we rely on the check in split_at_mut
Ben Kimock [Tue, 26 Jul 2022 22:37:00 +0000 (18:37 -0400)]
Explain how *mut [T] helps, and how we rely on the check in split_at_mut

2 years agorustdoc: remove Clean trait impl for ty::PolyTraitPredicate
Michael Howell [Tue, 26 Jul 2022 22:32:32 +0000 (15:32 -0700)]
rustdoc: remove Clean trait impl for ty::PolyTraitPredicate

2 years agorustdoc: remove Clean trait impls for ty::OutlivesPredicate
Michael Howell [Tue, 26 Jul 2022 22:28:20 +0000 (15:28 -0700)]
rustdoc: remove Clean trait impls for ty::OutlivesPredicate

2 years agorustdoc: remove Clean trait impl for ProjectionPredicate
Michael Howell [Tue, 26 Jul 2022 22:16:51 +0000 (15:16 -0700)]
rustdoc: remove Clean trait impl for ProjectionPredicate

2 years agorustdoc: remove Clean trait impl for ProjectionTy
Michael Howell [Tue, 26 Jul 2022 22:10:39 +0000 (15:10 -0700)]
rustdoc: remove Clean trait impl for ProjectionTy

2 years agoForce the Cow into a String
Jubilee Young [Tue, 26 Jul 2022 21:10:26 +0000 (14:10 -0700)]
Force the Cow into a String

2 years agoFix vectorcall
Daniel Paoliello [Tue, 19 Jul 2022 17:40:26 +0000 (10:40 -0700)]
Fix vectorcall

2 years agoUse String::from_utf8_lossy in CStr demo
Jubilee Young [Tue, 26 Jul 2022 20:26:05 +0000 (13:26 -0700)]
Use String::from_utf8_lossy in CStr demo

2 years agoUpdate cargo
Eric Huss [Tue, 26 Jul 2022 19:48:39 +0000 (12:48 -0700)]
Update cargo

2 years agoadd test for vec::IntoIter::next_chunk() impl
The 8472 [Tue, 26 Jul 2022 19:28:14 +0000 (21:28 +0200)]
add test for vec::IntoIter::next_chunk() impl

an adaption of the default impl's doctest

2 years agoAuto merge of #99574 - durin42:allocator-patch-redux, r=nikic
bors [Tue, 26 Jul 2022 19:35:57 +0000 (19:35 +0000)]
Auto merge of #99574 - durin42:allocator-patch-redux, r=nikic

codegen: use new {re,de,}allocator annotations in llvm

This obviates the patch that teaches LLVM internals about
_rust_{re,de}alloc functions by putting annotations directly in the IR
for the optimizer.

The sole test change is required to anchor FileCheck to the body of the
`box_uninitialized` method, so it doesn't see the `allocalign` on
`__rust_alloc` and get mad about the string `alloca` showing up. Since I
was there anyway, I added some checks on the attributes to prove the
right attributes got set.

r? `@nikic`

2 years agoFix display of item info and unify their height
Guillaume Gomez [Tue, 26 Jul 2022 19:34:56 +0000 (21:34 +0200)]
Fix display of item info and unify their height

2 years agorustdoc: do not allocate String when writing path full name
Michael Howell [Tue, 26 Jul 2022 19:23:59 +0000 (12:23 -0700)]
rustdoc: do not allocate String when writing path full name

No idea if this makes any perf difference, but it just seems like premature
pessimisation to use String when str will do.

2 years agoUpdate pulldown-cmark version
Guillaume Gomez [Tue, 26 Jul 2022 18:36:20 +0000 (20:36 +0200)]
Update pulldown-cmark version

2 years agoOptimized vec::IntoIter::next_chunk impl
The 8472 [Sun, 26 Jun 2022 20:53:25 +0000 (22:53 +0200)]
Optimized vec::IntoIter::next_chunk impl

```
test vec::bench_next_chunk                               ... bench:         696 ns/iter (+/- 22)
x86_64v1, pr
test vec::bench_next_chunk                               ... bench:         309 ns/iter (+/- 4)

znver2, default
test vec::bench_next_chunk                               ... bench:      17,272 ns/iter (+/- 117)
znver2, pr
test vec::bench_next_chunk                               ... bench:         211 ns/iter (+/- 3)
```

The znver2 default impl seems to be slow due to inlining decisions. It goes through `core::array::iter_next_chunk`
which has a deeper call tree.

2 years agoClippy fallout.
Camille GILLOT [Mon, 13 Jun 2022 09:53:31 +0000 (11:53 +0200)]
Clippy fallout.

2 years agoPacify tidy.
Camille GILLOT [Sun, 19 Jun 2022 14:35:16 +0000 (16:35 +0200)]
Pacify tidy.

2 years agoReplace LifetimeRes::Anonymous by LifetimeRes::Infer.
Camille GILLOT [Mon, 13 Jun 2022 06:22:06 +0000 (08:22 +0200)]
Replace LifetimeRes::Anonymous by LifetimeRes::Infer.

2 years agoClippy fallout.
Camille GILLOT [Mon, 13 Jun 2022 09:53:31 +0000 (11:53 +0200)]
Clippy fallout.

2 years agoStop creating anonymous late lifetimes.
Camille GILLOT [Tue, 24 May 2022 06:23:24 +0000 (08:23 +0200)]
Stop creating anonymous late lifetimes.

2 years agoRemove resolve_elided_lifetimes.
Camille GILLOT [Mon, 23 May 2022 15:03:14 +0000 (17:03 +0200)]
Remove resolve_elided_lifetimes.

2 years agoStop resolving lifetime elision on HIR.
Camille GILLOT [Mon, 23 May 2022 14:27:52 +0000 (16:27 +0200)]
Stop resolving lifetime elision on HIR.

2 years agoMove fn parameter ribs outwards.
Camille GILLOT [Sun, 22 May 2022 21:31:39 +0000 (23:31 +0200)]
Move fn parameter ribs outwards.

2 years agoCheck that we do not ICE when anonymous lifetimes appear in AnonConst.
Camille GILLOT [Wed, 6 Jul 2022 16:27:43 +0000 (18:27 +0200)]
Check that we do not ICE when anonymous lifetimes appear in AnonConst.

Fixes #98932.

2 years agoReplace LifetimeRes::Anonymous by LifetimeRes::Infer.
Camille GILLOT [Mon, 13 Jun 2022 06:22:06 +0000 (08:22 +0200)]
Replace LifetimeRes::Anonymous by LifetimeRes::Infer.

2 years agoRemove the distinction between LifetimeName::Implicit and LifetimeName::Underscore.
Camille GILLOT [Sun, 22 May 2022 08:22:20 +0000 (10:22 +0200)]
Remove the distinction between LifetimeName::Implicit and LifetimeName::Underscore.

2 years agoDo not produce extra lifetime parameters when not needed.
Camille GILLOT [Mon, 13 Jun 2022 05:36:45 +0000 (07:36 +0200)]
Do not produce extra lifetime parameters when not needed.

2 years agoMerge commit 'd3a2366ee877075c59b38bd8ced55f224fc7ef51' into sync_cg_clif-2022-07-26
bjorn3 [Tue, 26 Jul 2022 16:53:46 +0000 (18:53 +0200)]
Merge commit 'd3a2366ee877075c59b38bd8ced55f224fc7ef51' into sync_cg_clif-2022-07-26

2 years agoAuto merge of #99764 - matthiaskrgr:rollup-fawyb3m, r=matthiaskrgr
bors [Tue, 26 Jul 2022 16:47:36 +0000 (16:47 +0000)]
Auto merge of #99764 - matthiaskrgr:rollup-fawyb3m, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #99235 (rustdoc: Add support for `#[rustc_must_implement_one_of]`)
 - #99716 (remove useless mut from examples)
 - #99724 (Fix some broken link fragments.)
 - #99729 (Remove unused tuple fields)
 - #99757 (Make `transmute_copy` docs read better)
 - #99758 (remove useless `#[allow]` in a test)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoImplement some more llvm float compare intrinsic options
bjorn3 [Tue, 26 Jul 2022 16:27:14 +0000 (16:27 +0000)]
Implement some more llvm float compare intrinsic options

2 years agoOutline a bug! invocation
bjorn3 [Tue, 26 Jul 2022 16:26:35 +0000 (16:26 +0000)]
Outline a bug! invocation

This reduces the amount of llvm ir lines for intrinsic related code from
23801 to 20478.

2 years agoFully remove the intrinsic_match macro
bjorn3 [Tue, 26 Jul 2022 15:14:22 +0000 (15:14 +0000)]
Fully remove the intrinsic_match macro

2 years agoDon't build std for *-uefi targets
Nicholas Bishop [Tue, 26 Jul 2022 15:50:54 +0000 (11:50 -0400)]
Don't build std for *-uefi targets

https://github.com/rust-lang/rust/issues/97322

2 years agoHtmldocck: Substitute the doc channel when blessing
León Orell Valerian Liehr [Tue, 26 Jul 2022 15:38:13 +0000 (17:38 +0200)]
Htmldocck: Substitute the doc channel when blessing

2 years agoStart moving away from the intrinsic_match macro
bjorn3 [Tue, 26 Jul 2022 14:45:00 +0000 (14:45 +0000)]
Start moving away from the intrinsic_match macro

It isn't clear most people other than me and it blocks formatting by
rustfmt.

2 years agoRollup merge of #99758 - WaffleLapkin:remove_useless_allow, r=Dylan-DPC
Matthias Krüger [Tue, 26 Jul 2022 14:57:53 +0000 (16:57 +0200)]
Rollup merge of #99758 - WaffleLapkin:remove_useless_allow, r=Dylan-DPC

remove useless `#[allow]` in a test

The mentioned issue, https://github.com/rust-lang/rust/issues/54586 was fixed 4 years ago :)

2 years agoRollup merge of #99757 - asquared31415:patch-1, r=Dylan-DPC
Matthias Krüger [Tue, 26 Jul 2022 14:57:52 +0000 (16:57 +0200)]
Rollup merge of #99757 - asquared31415:patch-1, r=Dylan-DPC

Make `transmute_copy` docs read better

2 years agoRollup merge of #99729 - cjgillot:rm-unused-tuple, r=michaelwoerister
Matthias Krüger [Tue, 26 Jul 2022 14:57:50 +0000 (16:57 +0200)]
Rollup merge of #99729 - cjgillot:rm-unused-tuple, r=michaelwoerister

Remove unused tuple fields

Found by https://github.com/rust-lang/rust/pull/95977

2 years agoICE on RawPtrComparison check
Deadbeef [Tue, 26 Jul 2022 14:28:09 +0000 (14:28 +0000)]
ICE on RawPtrComparison check

2 years agoRollup merge of #99724 - ehuss:fix-broken-links-fragment, r=Dylan-DPC
Matthias Krüger [Tue, 26 Jul 2022 14:57:49 +0000 (16:57 +0200)]
Rollup merge of #99724 - ehuss:fix-broken-links-fragment, r=Dylan-DPC

Fix some broken link fragments.

An exception for link fragments starting with `-` was added in #49590. However, it is not clear what issues were encountered at the time. Perhaps those were fixed in the meantime.

This removes the exception, and fixes a couple of broken links that were skipped due to it.

2 years agoRollup merge of #99716 - sourcelliu:iomut, r=Mark-Simulacrum
Matthias Krüger [Tue, 26 Jul 2022 14:57:48 +0000 (16:57 +0200)]
Rollup merge of #99716 - sourcelliu:iomut, r=Mark-Simulacrum

remove useless mut from examples

remove useless mut from examples

2 years agoRollup merge of #99235 - WaffleLapkin:rustdoc_implement_support_for_must_implement...
Matthias Krüger [Tue, 26 Jul 2022 14:57:46 +0000 (16:57 +0200)]
Rollup merge of #99235 - WaffleLapkin:rustdoc_implement_support_for_must_implement, r=GuillaumeGomez

rustdoc: Add support for `#[rustc_must_implement_one_of]`

This PR adds support for `#[rustc_must_implement_one_of]` attribute added in #92164. There is a desire to eventually use this attribute of `Read`, so making it show up in docs is a good thing.

I "stole" the styling from cfg notes, not sure what would be a proper styling. Currently it looks like this:
![2022-07-14_15-00](https://user-images.githubusercontent.com/38225716/178968170-913c1dd5-8875-4a95-9848-b075a0bb8998.png)

<details><summary>Code to reproduce</summary>
<p>

```rust
#![feature(rustc_attrs)]

#[rustc_must_implement_one_of(a, b)]
pub trait Trait {
    fn req();
    fn a(){ Self::b() }
    fn b(){ Self::a() }
}
```

</p>
</details>

2 years agoFix diagnostics for unfulfilled obligations
Deadbeef [Tue, 26 Jul 2022 13:57:19 +0000 (13:57 +0000)]
Fix diagnostics for unfulfilled obligations

2 years agobless tests, remove nonexistent E0395
Deadbeef [Mon, 25 Jul 2022 08:17:00 +0000 (08:17 +0000)]
bless tests, remove nonexistent E0395

2 years agoAdd `Self: ~const Trait` to traits with `#[const_trait]`
Deadbeef [Mon, 25 Jul 2022 08:16:34 +0000 (08:16 +0000)]
Add `Self: ~const Trait` to traits with `#[const_trait]`

2 years agocodegen: use new {re,de,}allocator annotations in llvm
Augie Fackler [Mon, 21 Mar 2022 19:30:54 +0000 (15:30 -0400)]
codegen: use new {re,de,}allocator annotations in llvm

This obviates the patch that teaches LLVM internals about
_rust_{re,de}alloc functions by putting annotations directly in the IR
for the optimizer.

The sole test change is required to anchor FileCheck to the body of the
`box_uninitialized` method, so it doesn't see the `allocalign` on
`__rust_alloc` and get mad about the string `alloca` showing up. Since I
was there anyway, I added some checks on the attributes to prove the
right attributes got set.

While we're here, we also emit allocator attributes on
__rust_alloc_zeroed. This should allow LLVM to perform more
optimizations for zeroed blocks, and probably fixes #90032. [This
comment](https://github.com/rust-lang/rust/issues/24194#issuecomment-308791157)
mentions "weird UB-like behaviour with bitvec iterators in
rustc_data_structures" so we may need to back this change out if things
go wrong.

The new test cases require LLVM 15, so we copy them into LLVM
14-supporting versions, which we can delete when we drop LLVM 14.

2 years agoAuto merge of #99680 - workingjubilee:revert-revert-icf, r=Mark-Simulacrum
bors [Tue, 26 Jul 2022 13:31:31 +0000 (13:31 +0000)]
Auto merge of #99680 - workingjubilee:revert-revert-icf, r=Mark-Simulacrum

Revert "Revert "Use ICF (identical code folding) for building rustc""

This reverts commit rust-lang/rust@45575d23f316af7476ccd0a895234ac59c47a6be,
thereby enabling identical code folding again.

Closes #99440 (again).

2 years agoRewrite Windows `compat_fn` macro
Chris Denton [Thu, 21 Jul 2022 10:37:03 +0000 (11:37 +0100)]
Rewrite Windows `compat_fn` macro

This allows using most delay loaded functions before the init code initializes them. It also only preloads a select few functions, rather than all functions.

Co-Authored-By: Mark Rousskov <mark.simulacrum@gmail.com>
2 years agoRemove dead code from cg_llvm
bjorn3 [Tue, 26 Jul 2022 11:29:18 +0000 (11:29 +0000)]
Remove dead code from cg_llvm

2 years agoLib kind -l link-arg:
Daniil Belov [Tue, 19 Jul 2022 09:00:28 +0000 (12:00 +0300)]
Lib kind -l link-arg:
arbitrary link argument like -C link-arg, but respecting relative order to other `-l` options, unstable

2 years agoSimplify test
est31 [Tue, 26 Jul 2022 10:45:16 +0000 (12:45 +0200)]
Simplify test

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2 years agoAuto merge of #99753 - Dylan-DPC:rollup-k046940, r=Dylan-DPC
bors [Tue, 26 Jul 2022 10:35:25 +0000 (10:35 +0000)]
Auto merge of #99753 - Dylan-DPC:rollup-k046940, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #99618 (handle consts with param/infer in `const_eval_resolve` better)
 - #99666 (Restore `Opaque` behavior to coherence check)
 - #99692 (interpret, ptr_offset_from: refactor and test too-far-apart check)
 - #99739 (Remove erroneous E0133 code from an error message.)
 - #99748 (Use full type name instead of just saying `impl Trait` in "captures lifetime" error)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoremove useless `#[allow]` in a test
Maybe Waffle [Tue, 26 Jul 2022 10:27:01 +0000 (14:27 +0400)]
remove useless `#[allow]` in a test

2 years agoMake `transmute_copy` docs read better
asquared31415 [Tue, 26 Jul 2022 09:59:44 +0000 (05:59 -0400)]
Make `transmute_copy` docs read better

2 years agoMerge commit 'e36a20c24f35a4cee82bbdc600289104c9237c22' into ra-sync-and-pms-component
Amos Wenger [Tue, 26 Jul 2022 09:53:50 +0000 (11:53 +0200)]
Merge commit 'e36a20c24f35a4cee82bbdc600289104c9237c22' into ra-sync-and-pms-component

2 years agoRollup merge of #99748 - compiler-errors:better-impl-trait-printing, r=fee1-dead
Dylan DPC [Tue, 26 Jul 2022 08:57:00 +0000 (14:27 +0530)]
Rollup merge of #99748 - compiler-errors:better-impl-trait-printing, r=fee1-dead

Use full type name instead of just saying `impl Trait` in "captures lifetime" error

I think this is very useful, especially when there's >1 `impl Trait`, and it just means passing around a bit more info that we already have access to.

2 years agoRollup merge of #99739 - nnethercote:rm-E0133, r=Dylan-DPC
Dylan DPC [Tue, 26 Jul 2022 08:56:59 +0000 (14:26 +0530)]
Rollup merge of #99739 - nnethercote:rm-E0133, r=Dylan-DPC

Remove erroneous E0133 code from an error message.

This error message is about `derive` and `packed`, but E0133 is for
"Unsafe code was used outside of an unsafe function or block".

r? ``@estebank``

2 years agoRollup merge of #99692 - RalfJung:too-far, r=oli-obk
Dylan DPC [Tue, 26 Jul 2022 08:56:58 +0000 (14:26 +0530)]
Rollup merge of #99692 - RalfJung:too-far, r=oli-obk

interpret, ptr_offset_from: refactor and test too-far-apart check

We didn't have any tests for the "too far apart" message, and indeed that check mostly relied on the in-bounds check and was otherwise probably not entirely correct... so I rewrote that check, and it is before the in-bounds check so we can test it separately.

2 years agoRollup merge of #99666 - compiler-errors:issue-99663, r=lcnr
Dylan DPC [Tue, 26 Jul 2022 08:56:57 +0000 (14:26 +0530)]
Rollup merge of #99666 - compiler-errors:issue-99663, r=lcnr

Restore `Opaque` behavior to coherence check

Fixes #99663.

This broke in 84c3fcd2a0285c06a682c9b064640084e4c7271b. I'm not exactly certain that adding this behavior back is necessarily correct, but at least the UI test I provided may stimulate some thoughts.

I think delaying a bug here is certainly not correct in the case of opaques -- if we want to change coherence behavior for opaques, then we should at least be emitting a new error.

r? ``@lcnr``

2 years agoRollup merge of #99618 - compiler-errors:uhh-idk, r=lcnr
Dylan DPC [Tue, 26 Jul 2022 08:56:56 +0000 (14:26 +0530)]
Rollup merge of #99618 - compiler-errors:uhh-idk, r=lcnr

handle consts with param/infer in `const_eval_resolve` better

This PR addresses [this thread here](https://github.com/rust-lang/rust/pull/99449#discussion_r924141230). Was this the change you were looking for ``@lcnr?``

Interestingly, one test has begun to pass. Was that expected?

r? ``@lcnr``

2 years agoCheck that RPITs constrained by a recursive call in a closure are compatible
Michael Goulet [Sat, 9 Jul 2022 07:11:03 +0000 (07:11 +0000)]
Check that RPITs constrained by a recursive call in a closure are compatible

2 years agoRevert "Do not allow typeck children items to constrain outer RPITs"
Michael Goulet [Tue, 26 Jul 2022 07:37:54 +0000 (07:37 +0000)]
Revert "Do not allow typeck children items to constrain outer RPITs"

This reverts commit e8d9f38141a0ee8ac5484783e1fb5c218f9d2eee.

2 years agoRevert "use opaque_ty_origin_unchecked instead of destructuring HIR"
Michael Goulet [Tue, 26 Jul 2022 07:36:23 +0000 (07:36 +0000)]
Revert "use opaque_ty_origin_unchecked instead of destructuring HIR"

This reverts commit 5a4601fea56502e4f50df046c4205e678397599b.

2 years agoAuto merge of #12864 - Veykril:derive-helpers, r=Veykril
bors [Tue, 26 Jul 2022 07:34:11 +0000 (07:34 +0000)]
Auto merge of #12864 - Veykril:derive-helpers, r=Veykril

feat: Resolve derive helper attributes in IDE layer

![image](https://user-images.githubusercontent.com/3757771/180647125-98cae13b-a7b4-446b-8a64-fae014f982e2.png)

Also downmaps tokens inside deriver helpers to the derive expansion
![image](https://user-images.githubusercontent.com/3757771/180642110-699bdc73-e1f3-4692-94f2-21544f824ab9.png)

This does not handle the case where multiple derives make use of the same helper name though, unsure how to tackle that yet.

Partially addresses https://github.com/rust-lang/rust-analyzer/issues/10935

2 years agoAuto merge of #99677 - pietroalbini:pa-fix-97786-perf-regression, r=Mark-Simulacrum
bors [Tue, 26 Jul 2022 07:29:29 +0000 (07:29 +0000)]
Auto merge of #99677 - pietroalbini:pa-fix-97786-perf-regression, r=Mark-Simulacrum

Remove new allocations from `imported_source_files`

https://github.com/rust-lang/rust/pull/97786 introduced a [large performance regression](https://github.com/rust-lang/rust/pull/97786#issuecomment-1176552836). After some local investigation it turns out the allocations performed by my change were the cause of the perf regression. This PR refactors my change to remove those allocations.

2 years agoAllow name querying for derive helpers
Lukas Wirth [Sun, 24 Jul 2022 12:32:39 +0000 (14:32 +0200)]
Allow name querying for derive helpers

2 years agoRecord derive helper attributes, resolve them in IDE layer
Lukas Wirth [Sun, 24 Jul 2022 12:05:37 +0000 (14:05 +0200)]
Record derive helper attributes, resolve them in IDE layer

2 years agofeat: Downmap tokens inside derive helpers
Lukas Wirth [Sun, 24 Jul 2022 10:04:15 +0000 (12:04 +0200)]
feat: Downmap tokens inside derive helpers

2 years agoAllow try_to_raw_bytes on u8 array
Michael Goulet [Tue, 26 Jul 2022 07:05:31 +0000 (07:05 +0000)]
Allow try_to_raw_bytes on u8 array

2 years agoAddress nits, move substs replacement to separate function
Michael Goulet [Tue, 26 Jul 2022 00:43:29 +0000 (00:43 +0000)]
Address nits, move substs replacement to separate function

2 years agoAuto merge of #12858 - fasterthanlime:proc-macro-srv-bin, r=Veykril
bors [Tue, 26 Jul 2022 06:35:16 +0000 (06:35 +0000)]
Auto merge of #12858 - fasterthanlime:proc-macro-srv-bin, r=Veykril

Add `rust-analyzer-proc-macro-srv` binary, use it if found in sysroot

This adds a `bin` crate which simply runs `proc_macro_srv::cli::run()` (it does no CLI argument parsing, nothing).

The intent is to build that crate in Rust CI as part of the `dist::Rustc` component, then ship it in the sysroot: it would probably land in something like `~/.rustup/toolchains/nightly-2022-07-23-x86_64-unknown-linux-gnu/libexec/proc-macro-srv-cli`.

This makes https://github.com/rust-lang/rustup/pull/3022 less pressing. (Instead of teaching RA about rustup components, we simply teach it to look in the sysroot via `rustc --print sysroot`. If it can't find `proc-macro-srv-cli`, it falls back to its own `proc-macro` subcommand).

This is closely related to https://github.com/rust-lang/rust-analyzer/issues/12803 (but doesn't close it yet).

Things to address now:

  * [ ] What should the binary be named? What should the crate be named? We can pick different names with `[bin]` in the `Cargo.toml`

Things to address later:

  * Disable the "multi ABI compatibility scheme" when building that binary in Rust CI (that'll probably happen in `rust-lang/rust`)
  * Teaching RA to look in the sysroot

Things to address much, much later:

  * Is JSON a good fit here
  * Do we want to add versioning to future-proof it?
  * Other bikesheds

When built with `--features sysroot` on `nightly-2022-07-23-x86_64-unknown-linux-gnu`, the binary is 7.4MB. After stripping debuginfo, it's 2.6MB. When compressed to `.tar.xz`, it's 619KB.

In a Zulip discussion, `@jyn514` and `@Mark-Simulacrum` seemed to think that those sizes weren't a stopper for including the binary in the rustc component, even before we shrink it down further.

2 years agoUse real opaque type instead of just saying impl Trait
Michael Goulet [Tue, 26 Jul 2022 06:19:58 +0000 (06:19 +0000)]
Use real opaque type instead of just saying impl Trait

2 years agoUse Span::from_inner and make changes to precision inner span clearer
Preston From [Tue, 26 Jul 2022 05:23:33 +0000 (23:23 -0600)]
Use Span::from_inner and make changes to precision inner span clearer

2 years agoAuto merge of #99745 - JohnTitor:rollup-lvrie64, r=JohnTitor
bors [Tue, 26 Jul 2022 04:28:41 +0000 (04:28 +0000)]
Auto merge of #99745 - JohnTitor:rollup-lvrie64, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #98211 (Implement `fs::get_path` for FreeBSD.)
 - #99353 (Slightly improve mismatched GAT where clause error)
 - #99593 (Suggest removing the tuple struct field for the unwrapped value)
 - #99615 (Remove some explicit `self.infcx` for `FnCtxt`, which already derefs into `InferCtxt`)
 - #99711 (Remove reachable coverage without counters)
 - #99718 (Avoid `&str`/`Symbol` to `String` conversions)
 - #99720 (Sync rustc_codegen_cranelift)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #99720 - bjorn3:sync_cg_clif-2022-07-25, r=bjorn3
Yuki Okushi [Tue, 26 Jul 2022 04:12:24 +0000 (13:12 +0900)]
Rollup merge of #99720 - bjorn3:sync_cg_clif-2022-07-25, r=bjorn3

Sync rustc_codegen_cranelift

This time most of the changes are bugfixes. No exciting new features to report. Thanks `@matthiaskrgr` for reporting a bunch of crashes!

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler

2 years agoRollup merge of #99718 - TaKO8Ki:avoid-&str-symbol-to-string-conversions, r=michaelwo...
Yuki Okushi [Tue, 26 Jul 2022 04:12:23 +0000 (13:12 +0900)]
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

2 years agoRollup merge of #99711 - tmiasko:coverage, r=wesleywiser
Yuki Okushi [Tue, 26 Jul 2022 04:12:22 +0000 (13:12 +0900)]
Rollup merge of #99711 - tmiasko:coverage, r=wesleywiser

Remove reachable coverage without counters

Remove reachable coverage without counters to maintain invariant that
either there is no coverage at all or there is a live coverage counter
left that provides the function source hash.

The motivating example would be a following closure:

```rust
    let f = |x: bool| {
        debug_assert!(x);
    };
```

Which, with span changes from #93967, with disabled debug assertions,
after the final CFG simplifications but before removal of dead blocks,
gives rise to MIR:

```rust
fn main::{closure#0}(_1: &[closure@a.rs:2:13: 2:22], _2: bool) -> () {
    debug x => _2;
    let mut _0: ();

    bb0: {
        Coverage::Expression(4294967295) = 1 - 2;
        return;
    }

    ...
}
```

Which also makes the initial instrumentation quite suspect, although
this pull request doesn't attempt to address that aspect directly.

Fixes #98833.

r? ``@wesleywiser`` ``@richkadel``

2 years agoRollup merge of #99615 - compiler-errors:remove-some-explicit-infcx, r=lcnr
Yuki Okushi [Tue, 26 Jul 2022 04:12:21 +0000 (13:12 +0900)]
Rollup merge of #99615 - compiler-errors:remove-some-explicit-infcx, r=lcnr

Remove some explicit `self.infcx` for `FnCtxt`, which already derefs into `InferCtxt`

The use of `self.infcx.method_on_infcx` vs `self.method_on_infcx` when `self` is a `FnCtxt` is a bit inconsistent, so I'm moving some `self.infcx` usages I found to just use autoderef

2 years agoRollup merge of #99593 - TaKO8Ki:suggest-removing-tuple-struct-field, r=compiler...
Yuki Okushi [Tue, 26 Jul 2022 04:12:20 +0000 (13:12 +0900)]
Rollup merge of #99593 - TaKO8Ki:suggest-removing-tuple-struct-field, r=compiler-errors

Suggest removing the tuple struct field for the unwrapped value

fixes #99416

2 years agoRollup merge of #99353 - compiler-errors:gat-where-clause-mismatch, r=cjgillot
Yuki Okushi [Tue, 26 Jul 2022 04:12:19 +0000 (13:12 +0900)]
Rollup merge of #99353 - compiler-errors:gat-where-clause-mismatch, r=cjgillot

Slightly improve mismatched GAT where clause error

This makes the error reporting a bit more standardized between `where` on GATs and functions.

cc #99206 (`@BoxyUwU),` don't want to mark this as as "fixed" because they're still not perfect, but this is still an improvement IMO so I want to land it incrementally.

regarding "consider adding where clause to trait definition", we don't actually do that for methods as far as i can tell? i could file an issue to look into that maybe.

2 years agoRollup merge of #98211 - devnexen:get_path_freebsd, r=Mark-Simulacrum
Yuki Okushi [Tue, 26 Jul 2022 04:12:18 +0000 (13:12 +0900)]
Rollup merge of #98211 - devnexen:get_path_freebsd, r=Mark-Simulacrum

Implement `fs::get_path` for FreeBSD.

Using `F_KINFO` fcntl flag, the kf_structsize field
needs to be set beforehand for that effect.

2 years agoRemove erroneous E0133 code from an error message.
Nicholas Nethercote [Tue, 26 Jul 2022 00:31:06 +0000 (10:31 +1000)]
Remove erroneous E0133 code from an error message.

This error message is about `derive` and `packed`, but E0133 is for
"Unsafe code was used outside of an unsafe function or block".

2 years agoAdd `--type` flag to `dev new_lint`
Serial [Thu, 14 Jul 2022 19:58:38 +0000 (15:58 -0400)]
Add `--type` flag to `dev new_lint`

2 years agoUse impl generics when suggesting fix on copy impl
Michael Goulet [Tue, 26 Jul 2022 01:37:06 +0000 (01:37 +0000)]
Use impl generics when suggesting fix on copy impl

2 years agoAuto merge of #98989 - dpaoliello:rawdylibbin, r=michaelwoerister
bors [Tue, 26 Jul 2022 01:47:34 +0000 (01:47 +0000)]
Auto merge of #98989 - dpaoliello:rawdylibbin, r=michaelwoerister

Enable raw-dylib for bin crates

Fixes #93842

When `raw-dylib` is used in a `bin` crate, we need to collect all of the `raw-dylib` functions, generate the import library and add that to the linker command line.

I also changed the tests so that 1) the C++ dlls are created after the Rust dlls, thus there is no chance of accidentally using them in the Rust linking process and 2) disabled generating import libraries when building with MSVC.

2 years agoRemove some explicit self.infcx for fcx, which derefs into infcx
Michael Goulet [Fri, 22 Jul 2022 18:49:35 +0000 (18:49 +0000)]
Remove some explicit self.infcx for fcx, which derefs into infcx

2 years agohandle consts with param/infer in const_eval_resolve better
Michael Goulet [Fri, 22 Jul 2022 01:46:43 +0000 (01:46 +0000)]
handle consts with param/infer in const_eval_resolve better

2 years agoRestore Opaque behavior to coherence check
Michael Goulet [Sun, 24 Jul 2022 10:34:35 +0000 (10:34 +0000)]
Restore Opaque behavior to coherence check

2 years agoAuto merge of #99735 - JohnTitor:rollup-d93jyr2, r=JohnTitor
bors [Mon, 25 Jul 2022 22:57:23 +0000 (22:57 +0000)]
Auto merge of #99735 - JohnTitor:rollup-d93jyr2, r=JohnTitor

Rollup of 9 pull requests

Successful merges:

 - #92390 (Constify a few `(Partial)Ord` impls)
 - #97077 (Simplify some code that depend on Deref)
 - #98710 (correct the output of a `capacity` method example)
 - #99084 (clarify how write_bytes can lead to UB due to invalid values)
 - #99178 (Lighten up const_prop_lint, reusing const_prop)
 - #99673 (don't ICE on invalid dyn calls)
 - #99703 (Expose size_hint() for TokenStream's iterator)
 - #99709 (`Inherited` always has `TypeckResults` available)
 - #99713 (Fix sidebar background)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup