Commit Graph

195896 Commits

Author SHA1 Message Date
Yuki Okushi
7f608e99dc
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
2022-07-27 11:52:56 +09:00
Yuki Okushi
fe51d07b99
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`
2022-07-27 11:52:55 +09:00
Yuki Okushi
181bf05d86
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`.
2022-07-27 11:52:54 +09:00
Yuki Okushi
3ca1c3100d
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.
2022-07-27 11:52:53 +09:00
Yuki Okushi
1ff84f09b2
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).
2022-07-27 11:52:52 +09:00
bors
4d6d601c8a 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`
2022-07-26 19:35:57 +00:00
bors
c11207ec89 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
2022-07-26 16:47:36 +00:00
Matthias Krüger
8e5bc06354
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 :)
2022-07-26 16:57:53 +02:00
Matthias Krüger
a739e28aea
Rollup merge of #99757 - asquared31415:patch-1, r=Dylan-DPC
Make `transmute_copy` docs read better
2022-07-26 16:57:52 +02:00
Matthias Krüger
ddb6a46316
Rollup merge of #99729 - cjgillot:rm-unused-tuple, r=michaelwoerister
Remove unused tuple fields

Found by https://github.com/rust-lang/rust/pull/95977
2022-07-26 16:57:50 +02:00
Matthias Krüger
dfaf6ec128
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.
2022-07-26 16:57:49 +02:00
Matthias Krüger
ea299e8f31
Rollup merge of #99716 - sourcelliu:iomut, r=Mark-Simulacrum
remove useless mut from examples

remove useless mut from examples
2022-07-26 16:57:48 +02:00
Matthias Krüger
811b4b890a
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>
2022-07-26 16:57:46 +02:00
Augie Fackler
130a1df71e 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.
2022-07-26 09:43:28 -04:00
bors
c9b31839b6 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@45575d23f3,
thereby enabling identical code folding again.

Closes #99440 (again).
2022-07-26 13:31:31 +00:00
bjorn3
017e1726ff Remove dead code from cg_llvm 2022-07-26 11:29:18 +00:00
est31
15db4186b7
Simplify test
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2022-07-26 12:45:16 +02:00
bors
2614e437f5 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
2022-07-26 10:35:25 +00:00
Maybe Waffle
a660a6f13a remove useless #[allow] in a test 2022-07-26 14:27:01 +04:00
asquared31415
e241d5a093
Make transmute_copy docs read better 2022-07-26 05:59:44 -04:00
Dylan DPC
ad32667bc8
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.
2022-07-26 14:27:00 +05:30
Dylan DPC
962da8bdce
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``
2022-07-26 14:26:59 +05:30
Dylan DPC
deab13c681
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.
2022-07-26 14:26:58 +05:30
Dylan DPC
99350de0d5
Rollup merge of #99666 - compiler-errors:issue-99663, r=lcnr
Restore `Opaque` behavior to coherence check

Fixes #99663.

This broke in 84c3fcd2a0. 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``
2022-07-26 14:26:57 +05:30
Dylan DPC
a39c00ee8d
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``
2022-07-26 14:26:56 +05:30
bors
96b9bb4620 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.
2022-07-26 07:29:29 +00:00
Michael Goulet
b248647ef0 Address nits, move substs replacement to separate function 2022-07-26 06:43:50 +00:00
Michael Goulet
d3492ca852 Use real opaque type instead of just saying impl Trait 2022-07-26 06:19:58 +00:00
bors
b629c85bd7 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
2022-07-26 04:28:41 +00:00
Yuki Okushi
a572f061c7
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
2022-07-26 13:12:24 +09:00
Yuki Okushi
85afb90788
Rollup merge of #99718 - TaKO8Ki:avoid-&str-symbol-to-string-conversions, r=michaelwoerister
Avoid `&str`/`Symbol` to `String` conversions

follow-up to #99342 and #98668
2022-07-26 13:12:23 +09:00
Yuki Okushi
3c1eef2e91
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``
2022-07-26 13:12:22 +09:00
Yuki Okushi
2744c0ef18
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
2022-07-26 13:12:21 +09:00
Yuki Okushi
d89e99a805
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
2022-07-26 13:12:20 +09:00
Yuki Okushi
2944454540
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.
2022-07-26 13:12:19 +09:00
Yuki Okushi
d3acd0069d
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.
2022-07-26 13:12:18 +09:00
Nicholas Nethercote
6a4b1572f9 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".
2022-07-26 12:54:24 +10:00
bors
daaae25022 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.
2022-07-26 01:47:34 +00:00
Michael Goulet
aaa9989c2f Remove some explicit self.infcx for fcx, which derefs into infcx 2022-07-26 00:40:22 +00:00
Michael Goulet
f1618e8924 handle consts with param/infer in const_eval_resolve better 2022-07-25 23:41:13 +00:00
Michael Goulet
b7cf9f72f6 Restore Opaque behavior to coherence check 2022-07-25 23:38:41 +00:00
bors
a86705942c 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
2022-07-25 22:57:23 +00:00
David CARLIER
e39b44a076 Implement fs::get_path for FreeBSD.
Using `F_KINFO` fcntl flag, the kf_structsize field
needs to be set beforehand for that effect.
2022-07-25 23:25:15 +01:00
Yuki Okushi
e58bfacd90
Rollup merge of #99713 - GuillaumeGomez:fix-sidebar-background, r=notriddle
Fix sidebar background

Fixes #99691.

cc `@jsha`
r? `@notriddle`
2022-07-26 07:14:52 +09:00
Yuki Okushi
b37b39db82
Rollup merge of #99709 - lcnr:rm-MaybeTypeckResults, r=compiler-errors
`Inherited` always has `TypeckResults` available
2022-07-26 07:14:51 +09:00
Yuki Okushi
5bbdf65996
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:

babff2211e/library/proc_macro/src/lib.rs (L363-L371)

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

babff2211e/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:

babff2211e/library/proc_macro/src/lib.rs (L20-L22)
2022-07-26 07:14:50 +09:00
Yuki Okushi
2973b00ca6
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``
2022-07-26 07:14:49 +09:00
Yuki Okushi
74be487ca0
Rollup merge of #99178 - Dajamante:clean_up, r=oli-obk
Lighten up const_prop_lint, reusing const_prop

r? `@oli-obk`
2022-07-26 07:14:48 +09:00
Yuki Okushi
aeca079d7e
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``
2022-07-26 07:14:46 +09:00
Yuki Okushi
b8aab9781a
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.
2022-07-26 07:14:45 +09:00