]> git.lizzy.rs Git - rust.git/log
rust.git
23 months agolint: add comment about diag lints in group
David Wood [Tue, 26 Jul 2022 10:46:01 +0000 (11:46 +0100)]
lint: add comment about diag lints in group

Add a brief comment explaining why the diagnostic migration lints aren't
included in the `rustc::internal` diagnostic group.

Signed-off-by: David Wood <david.wood@huawei.com>
23 months agoAuto merge of #99792 - JohnTitor:rollup-20i7ewx, r=JohnTitor
bors [Wed, 27 Jul 2022 04:18:49 +0000 (04:18 +0000)]
Auto merge of #99792 - JohnTitor:rollup-20i7ewx, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #98583 (Stabilize Windows `FileTypeExt` with `is_symlink_dir` and `is_symlink_file`)
 - #99698 (Prefer visibility map parents that are not `doc(hidden)` first)
 - #99700 (Add a clickable link to the layout section)
 - #99712 (passes: port more of `check_attr` module)
 - #99759 (Remove dead code from cg_llvm)
 - #99765 (Don't build std for *-uefi targets)
 - #99771 (Update pulldown-cmark version to 0.9.2 (fixes url encoding for some chars))
 - #99775 (rustdoc: do not allocate String when writing path full name)

Failed merges:

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

23 months agoRollup merge of #99775 - notriddle:notriddle/as-str, r=camelid
Yuki Okushi [Wed, 27 Jul 2022 02:52:59 +0000 (11:52 +0900)]
Rollup merge of #99775 - notriddle:notriddle/as-str, r=camelid

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.

23 months agoRollup merge of #99771 - GuillaumeGomez:update-pulldown-cmark, r=Urgau
Yuki Okushi [Wed, 27 Jul 2022 02:52:58 +0000 (11:52 +0900)]
Rollup merge of #99771 - GuillaumeGomez:update-pulldown-cmark, r=Urgau

Update pulldown-cmark version to 0.9.2 (fixes url encoding for some chars)

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

r? ``@Dylan-DPC``

23 months agoRollup merge of #99765 - nicholasbishop:bishop-disable-uefi-std-build, r=jyn514
Yuki Okushi [Wed, 27 Jul 2022 02:52:57 +0000 (11:52 +0900)]
Rollup merge of #99765 - nicholasbishop:bishop-disable-uefi-std-build, r=jyn514

Don't build std for *-uefi targets

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

23 months 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

23 months 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`

23 months 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`.

23 months 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.

23 months 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).

23 months 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.

23 months 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

23 months 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`

23 months 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.

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

23 months 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.

23 months 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

23 months 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

23 months 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 :)

23 months 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

23 months 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

23 months 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.

23 months 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

23 months 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>

23 months 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.

23 months 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).

23 months agoRemove dead code from cg_llvm
bjorn3 [Tue, 26 Jul 2022 11:29:18 +0000 (11:29 +0000)]
Remove dead code from cg_llvm

23 months 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>
23 months 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

23 months 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

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

23 months 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.

23 months 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``

23 months 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.

23 months 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``

23 months 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``

23 months 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.

23 months 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

23 months 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

23 months 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

23 months 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

23 months 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

23 months 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``

23 months 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

23 months 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

23 months 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.

23 months 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.

23 months 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".

23 months 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.

23 months 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

23 months 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

23 months 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

23 months 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

23 months agoImplement `fs::get_path` for FreeBSD.
David CARLIER [Fri, 17 Jun 2022 19:31:59 +0000 (20:31 +0100)]
Implement `fs::get_path` for FreeBSD.

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

23 months agoRollup merge of #99713 - GuillaumeGomez:fix-sidebar-background, r=notriddle
Yuki Okushi [Mon, 25 Jul 2022 22:14:52 +0000 (07:14 +0900)]
Rollup merge of #99713 - GuillaumeGomez:fix-sidebar-background, r=notriddle

Fix sidebar background

Fixes #99691.

cc `@jsha`
r? `@notriddle`

23 months agoRollup merge of #99709 - lcnr:rm-MaybeTypeckResults, r=compiler-errors
Yuki Okushi [Mon, 25 Jul 2022 22:14:51 +0000 (07:14 +0900)]
Rollup merge of #99709 - lcnr:rm-MaybeTypeckResults, r=compiler-errors

`Inherited` always has `TypeckResults` available

23 months agoRollup merge of #99703 - dtolnay:tokenstreamsizehint, r=petrochenkov
Yuki Okushi [Mon, 25 Jul 2022 22:14:50 +0000 (07:14 +0900)]
Rollup merge of #99703 - dtolnay:tokenstreamsizehint, r=petrochenkov

Expose size_hint() for TokenStream's iterator

The iterator for `proc_macro::TokenStream` is a wrapper around a `Vec` iterator:

https://github.com/rust-lang/rust/blob/babff2211e3ae9ef52852dc1b01f3eacdd94c12e/library/proc_macro/src/lib.rs#L363-L371

so it can cheaply provide a perfectly precise size hint, with just a pointer subtraction:

https://github.com/rust-lang/rust/blob/babff2211e3ae9ef52852dc1b01f3eacdd94c12e/library/alloc/src/vec/into_iter.rs#L170-L177

I need the size hint in syn (https://github.com/dtolnay/syn/blob/1.0.98/src/buffer.rs) to reduce allocations when converting TokenStream into syn's internal TokenBuffer representation.

Aside from `size_hint`, the other non-default methods in `std::vec::IntoIter`'s `Iterator` impl are `advance_by`, `count`, and `__iterator_get_unchecked`. I've included `count` in this PR since it is trivial. I did not include `__iterator_get_unchecked` because it is spoopy and I did not feel like dealing with that. Lastly, I did not include `advance_by` because that requires `feature(iter_advance_by)` (https://github.com/rust-lang/rust/issues/77404) and I noticed this comment at the top of libproc_macro:

https://github.com/rust-lang/rust/blob/babff2211e3ae9ef52852dc1b01f3eacdd94c12e/library/proc_macro/src/lib.rs#L20-L22

23 months agoRollup merge of #99673 - RalfJung:interpret-invalid-dyn, r=oli-obk
Yuki Okushi [Mon, 25 Jul 2022 22:14:49 +0000 (07:14 +0900)]
Rollup merge of #99673 - RalfJung:interpret-invalid-dyn, r=oli-obk

don't ICE on invalid dyn calls

Due to https://github.com/rust-lang/rust/issues/50781 this is actually reachable.
Fixes https://github.com/rust-lang/miri/issues/2432

r? ``@oli-obk``

23 months agoRollup merge of #99178 - Dajamante:clean_up, r=oli-obk
Yuki Okushi [Mon, 25 Jul 2022 22:14:48 +0000 (07:14 +0900)]
Rollup merge of #99178 - Dajamante:clean_up, r=oli-obk

Lighten up const_prop_lint, reusing const_prop

r? `@oli-obk`

23 months agoRollup merge of #99084 - RalfJung:write_bytes, r=thomcc
Yuki Okushi [Mon, 25 Jul 2022 22:14:46 +0000 (07:14 +0900)]
Rollup merge of #99084 - RalfJung:write_bytes, r=thomcc

clarify how write_bytes can lead to UB due to invalid values

Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/330

Cc ``@5225225``

23 months agoRollup merge of #98710 - mojave2:string, r=JohnTitor
Yuki Okushi [Mon, 25 Jul 2022 22:14:45 +0000 (07:14 +0900)]
Rollup merge of #98710 - mojave2:string, r=JohnTitor

correct the output of a `capacity` method example

The output of this example in std::alloc is different from which shown in the comment. I have tested it on both Linux and Windows.

23 months agoRollup merge of #97077 - ouz-a:Optimize-backend, r=oli-obk
Yuki Okushi [Mon, 25 Jul 2022 22:14:44 +0000 (07:14 +0900)]
Rollup merge of #97077 - ouz-a:Optimize-backend, r=oli-obk

Simplify some code that depend on Deref

Now that we can assume #97025 works, it's safe to expect Deref is always in the first place of projections. With this, I was able to simplify some code that depended on Deref's place in projections. When we are able to move Derefer before `ElaborateDrops` successfully we will be able to optimize more places.

r? `@oli-obk`

23 months agoRollup merge of #92390 - fee1-dead-contrib:const_cmp, r=oli-obk
Yuki Okushi [Mon, 25 Jul 2022 22:14:43 +0000 (07:14 +0900)]
Rollup merge of #92390 - fee1-dead-contrib:const_cmp, r=oli-obk

Constify a few `(Partial)Ord` impls

Only a few `impl`s are constified for now, as #92257 has not landed in the bootstrap compiler yet and quite a few impls would need that fix.

This unblocks #92228, which unblocks marking iterator methods as `default_method_body_is_const`.

23 months agoAuto merge of #97313 - cjgillot:ast-lifetimes-anon, r=petrochenkov
bors [Mon, 25 Jul 2022 20:02:55 +0000 (20:02 +0000)]
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`

23 months agoUnused tuple fields in rustc_resolve.
Camille GILLOT [Mon, 25 Jul 2022 17:45:26 +0000 (19:45 +0200)]
Unused tuple fields in rustc_resolve.

23 months agoUnused tuple fields in rustc_infer.
Camille GILLOT [Mon, 25 Jul 2022 17:45:10 +0000 (19:45 +0200)]
Unused tuple fields in rustc_infer.

23 months agoClippy fallout.
Camille GILLOT [Mon, 6 Jun 2022 18:26:41 +0000 (20:26 +0200)]
Clippy fallout.

23 months agoUpdate file description.
Camille GILLOT [Fri, 22 Jul 2022 18:15:14 +0000 (20:15 +0200)]
Update file description.

23 months agoReport elision failures on the AST.
Camille GILLOT [Sun, 5 Jun 2022 16:33:09 +0000 (18:33 +0200)]
Report elision failures on the AST.

23 months agoapply review suggestions
Maybe Waffle [Mon, 25 Jul 2022 17:12:56 +0000 (21:12 +0400)]
apply review suggestions

23 months agoAdd a clickable link to the layout section
est31 [Sun, 24 Jul 2022 22:35:58 +0000 (00:35 +0200)]
Add a clickable link to the layout section

23 months agoAuto merge of #99722 - RalfJung:miri, r=RalfJung
bors [Mon, 25 Jul 2022 16:48:01 +0000 (16:48 +0000)]
Auto merge of #99722 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/99664
r? `@ghost`

23 months agoFix some broken link fragments.
Eric Huss [Mon, 25 Jul 2022 16:16:28 +0000 (09:16 -0700)]
Fix some broken link fragments.

23 months agoupdate Miri
Ralf Jung [Mon, 25 Jul 2022 15:23:59 +0000 (11:23 -0400)]
update Miri

23 months agoUpdate list of allowed dependencies
bjorn3 [Mon, 25 Jul 2022 15:08:20 +0000 (17:08 +0200)]
Update list of allowed dependencies

Cranelift started depending on a couple of new crates

23 months agopasses: port more of `check_attr` module
David Wood [Tue, 19 Jul 2022 09:00:16 +0000 (10:00 +0100)]
passes: port more of `check_attr` module

Signed-off-by: David Wood <david.wood@huawei.com>
23 months agoMerge commit 'c19edfd71a1d0ddef86c2c67fdb40718d40a72b4' into sync_cg_clif-2022-07-25
bjorn3 [Mon, 25 Jul 2022 14:07:57 +0000 (16:07 +0200)]
Merge commit 'c19edfd71a1d0ddef86c2c67fdb40718d40a72b4' into sync_cg_clif-2022-07-25

23 months agoRustup to rustc 1.64.0-nightly (7fe022f5a 2022-07-24)
bjorn3 [Mon, 25 Jul 2022 14:06:39 +0000 (16:06 +0200)]
Rustup to rustc 1.64.0-nightly (7fe022f5a 2022-07-24)

23 months agoAuto merge of #85673 - csmoe:export-exe-sym, r=bjorn3
bors [Mon, 25 Jul 2022 14:04:40 +0000 (14:04 +0000)]
Auto merge of #85673 - csmoe:export-exe-sym, r=bjorn3

RFC-2841: add codegen flag export symbols from executable

Closes #84161
r? `@nikomatsakis` `@Mark-Simulacrum`

23 months agoSync from rust 2f320a224e827b400be25966755a621779f797cc
bjorn3 [Mon, 25 Jul 2022 14:00:44 +0000 (16:00 +0200)]
Sync from rust 2f320a224e827b400be25966755a621779f797cc

23 months agoremoved CanConstProp + Visitor
Aïssata [Mon, 25 Jul 2022 13:54:49 +0000 (13:54 +0000)]
removed CanConstProp + Visitor

23 months agoUpdate Cranelift to 0.85.3
bjorn3 [Mon, 25 Jul 2022 13:50:43 +0000 (13:50 +0000)]
Update Cranelift to 0.85.3

This fixes a couple of potential miscompilations. None affect cg_clif on
x86_64, but one may affect cg_clif on AArch64.

23 months agoMerge pull request #1247 from bjorn3/melt_some_ice
bjorn3 [Mon, 25 Jul 2022 13:46:04 +0000 (15:46 +0200)]
Merge pull request #1247 from bjorn3/melt_some_ice

Melt some ICE

23 months agoavoid `&str`/`Symbol` to `String` conversions
Takayuki Maeda [Mon, 25 Jul 2022 13:40:00 +0000 (22:40 +0900)]
avoid `&str`/`Symbol` to `String` conversions

23 months agoremove `is_local_span` as it is no longer used
Takayuki Maeda [Mon, 25 Jul 2022 13:37:14 +0000 (22:37 +0900)]
remove `is_local_span` as it is no longer used

23 months agoLighten up const_prop_lint, reusing const_prop
Aïssata [Tue, 12 Jul 2022 12:17:58 +0000 (12:17 +0000)]
Lighten up const_prop_lint, reusing const_prop

23 months agoFix -Zpolymorphize
bjorn3 [Mon, 25 Jul 2022 13:17:53 +0000 (13:17 +0000)]
Fix -Zpolymorphize

23 months agoFix size_of_val and min_align_of_val for truly unsized types
bjorn3 [Mon, 25 Jul 2022 11:35:24 +0000 (11:35 +0000)]
Fix size_of_val and min_align_of_val for truly unsized types

23 months agoAdd GUI test to prevent sidebar background regression
Guillaume Gomez [Mon, 25 Jul 2022 12:35:06 +0000 (14:35 +0200)]
Add GUI test to prevent sidebar background regression

23 months agoFix sidebar background-color on mobile
Guillaume Gomez [Mon, 25 Jul 2022 12:19:26 +0000 (14:19 +0200)]
Fix sidebar background-color on mobile

23 months agoRemove reachable coverage without counters
Tomasz Miąsko [Mon, 25 Jul 2022 00:00:00 +0000 (00:00 +0000)]
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;
    }

    ...
}
```

23 months agoError when trying to define variadic functions
bjorn3 [Mon, 25 Jul 2022 11:18:34 +0000 (11:18 +0000)]
Error when trying to define variadic functions

They aren't yet supported by Cranelift

23 months ago`Inherited` always has `TypeckResults` available
lcnr [Mon, 25 Jul 2022 11:11:07 +0000 (13:11 +0200)]
`Inherited` always has `TypeckResults` available

23 months agoAuto merge of #99707 - JohnTitor:rollup-74rb8vq, r=JohnTitor
bors [Mon, 25 Jul 2022 10:33:32 +0000 (10:33 +0000)]
Auto merge of #99707 - JohnTitor:rollup-74rb8vq, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #95040 (protect `std::io::Take::limit` from overflow in `read`)
 - #95916 (kmc-solid: Use `libc::abort` to abort a program)
 - #99494 (Use non-relocatable code in nofile-limit.rs test)
 - #99581 (Improve error messages involving `derive` and `packed`.)
 - #99643 (Add `sign-ext` target feature to the WASM target)
 - #99659 (Use `VecMap::get` in `ConstraintLocator::check`)
 - #99690 (add miri-track-caller to more intrinsic-exposing methods)

Failed merges:

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

23 months agoRollup merge of #99690 - RalfJung:miri-track-caller, r=Mark-Simulacrum
Yuki Okushi [Mon, 25 Jul 2022 09:46:55 +0000 (18:46 +0900)]
Rollup merge of #99690 - RalfJung:miri-track-caller, r=Mark-Simulacrum

add miri-track-caller to more intrinsic-exposing methods

Follow-up to https://github.com/rust-lang/rust/pull/98674: I went through the Miri test suite to find more functions that would benefit from Miri backtrace pruning, and this is what I found.

Basically anything that just exposes a potentially-UB intrinsic to the user should get this treatment.

23 months agoRollup merge of #99659 - compiler-errors:opaque-type-nit, r=oli-obk
Yuki Okushi [Mon, 25 Jul 2022 09:46:54 +0000 (18:46 +0900)]
Rollup merge of #99659 - compiler-errors:opaque-type-nit, r=oli-obk

Use `VecMap::get` in `ConstraintLocator::check`

Also rename the `def_id` param to `item_def_id` because that's easily confused with `self.def_id` (which is the opaque ty did).

23 months agoRollup merge of #99643 - daxpedda:sign-ext-wasm, r=oli-obk
Yuki Okushi [Mon, 25 Jul 2022 09:46:52 +0000 (18:46 +0900)]
Rollup merge of #99643 - daxpedda:sign-ext-wasm, r=oli-obk

Add `sign-ext` target feature to the WASM target

Some target features are still missing from that list.
See #97808 for basically the same PR by `@alexcrichton.`

Related issue: #96472.
PR introducing this issue: #87402.

23 months agoRollup merge of #99581 - nnethercote:improve-derive-packed-errors, r=estebank
Yuki Okushi [Mon, 25 Jul 2022 09:46:51 +0000 (18:46 +0900)]
Rollup merge of #99581 - nnethercote:improve-derive-packed-errors, r=estebank

Improve error messages involving `derive` and `packed`.

There are two errors involving `derive` and `packed`.

```
`#[derive]` can't be derived on a `#[repr(packed)]` struct with type or const parameters
`#[derive]` can't be derived on a `#[repr(packed)]` struct that does not derive Copy
```
The second one overstates things. It is possible to use derive on a
repr(packed) struct that doesn't derive Copy in two cases.
- If all the fields within the struct meet the required alignment: 1 for
  `repr(packed)`, or `N` for `repr(packed(N))`.
- If `Default` is the only trait derived.

This commit improves things in a few ways.
- Changes the errors to say `this trait can't be derived on this ...`.
  This is more accurate, because it's just *this* trait and *this*
  packed struct that are a problem, not *all* derived traits on *all*
  packed structs.
- Adds more details to the "ERROR" lines in the test case, enough to
  distinguish between the two error messages.
- Adds more cases to the test case that don't cause errors, e.g. `Default`
  derives.
- Uses a wider variety of builtin traits in the test case, for better coverage.

r? `@estebank`

23 months agoRollup merge of #99494 - tmiasko:no-pie, r=Mark-Simulacrum
Yuki Okushi [Mon, 25 Jul 2022 09:46:50 +0000 (18:46 +0900)]
Rollup merge of #99494 - tmiasko:no-pie, r=Mark-Simulacrum

Use non-relocatable code in nofile-limit.rs test

To avoid using static-pie which is not essential to the test but which
was reported to cause problems on Void Linux where glibc is build
without support for static-pie.

23 months agoRollup merge of #95916 - solid-rs:feat-kmc-solid-abort, r=Mark-Simulacrum
Yuki Okushi [Mon, 25 Jul 2022 09:46:48 +0000 (18:46 +0900)]
Rollup merge of #95916 - solid-rs:feat-kmc-solid-abort, r=Mark-Simulacrum

kmc-solid: Use `libc::abort` to abort a program

This PR updates the target-specific abort subroutine for the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets.

The current implementation uses a `hlt` instruction, which is the most direct way to notify a connected debugger but is not the most flexible way. This PR changes it to call the `abort` libc function, making it possible for a system designer to override its behavior as they see fit.