Commit Graph

234001 Commits

Author SHA1 Message Date
bors
8a7cab8d0e Auto merge of #115547 - WaffleLapkin:spin_looping, r=Mark-Simulacrum
Simplify `core::hint::spin_loop`

The grouping was inconsistent and not really helpful.

r? t-libs
2023-09-18 00:02:40 +00:00
bors
203c57dbe2 Auto merge of #115334 - RalfJung:transparent-aligned-zst, r=compiler-errors
repr(transparent): it's fine if the one non-1-ZST field is a ZST

This code currently gets rejected:
```rust
#[repr(transparent)]
struct MyType([u16; 0])
```
That clearly seems like a bug to me: `repr(transparent)` [got defined ](https://github.com/rust-lang/rust/issues/77841#issuecomment-716575747) as having any number of 1-ZST fields plus optionally one more field; `MyType` clearly satisfies that definition.

This PR changes the `repr(transparent)` logic to actually match that definition.
2023-09-17 15:20:44 +00:00
bors
db9c21fd94 Auto merge of #115909 - Dylan-DPC:rollup-uf96r2d, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #114965 (Remove Drop impl of mpsc Receiver and (Sync)Sender)
 - #115434 (make `Debug` impl for `ascii::Char` match that of `char`)
 - #115477 (Stabilize the `Saturating` type)
 - #115611 (add diagnostic for raw identifiers in format string)
 - #115654 (improve PassMode docs)
 - #115862 (Migrate `compiler/rustc_hir_typeck/src/callee.rs` to translatable diagnostics)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-17 13:31:49 +00:00
bors
8ed1d4a02d Auto merge of #114750 - Enselic:metadata-dep-info, r=compiler-errors
Make `.rmeta` file in `dep-info` have correct name (`lib` prefix)

Since `filename_for_metadata()` and
`OutputFilenames::path(OutputType::Metadata)` had different logic for the name of the metadata file, the `.d` file contained a file name different from the actual name used. Share the logic to fix the out-of-sync name.

Without this fix, the `.d` file contained

    dash-separated_something-extra.rmeta: dash-separated.rs

instead of

    libdash_separated_something-extra.rmeta: dash-separated.rs

which is the name of the file that is actually written by the compiler.

Worth noting: It took me several iterations to get all tests to pass, so I am relatively confident that this PR does not break anything.

Closes #68839
2023-09-17 11:45:53 +00:00
Dylan DPC
f082f1dd30
Rollup merge of #115862 - clubby789:migrate-callee-translatable, r=compiler-errors
Migrate `compiler/rustc_hir_typeck/src/callee.rs` to translatable diagnostics
2023-09-17 11:23:26 +00:00
Dylan DPC
0c5f5b6db7
Rollup merge of #115654 - RalfJung:pass-mode-cast, r=compiler-errors
improve PassMode docs
2023-09-17 11:23:25 +00:00
Dylan DPC
0900712fe0
Rollup merge of #115611 - lukas-code:format!("{r#ident}"), r=compiler-errors
add diagnostic for raw identifiers in format string

Format strings don't support raw identifiers (e.g. `format!("{r#type}")`), but they do support keywords in the format string directly (e.g. `format!("{type}")`). This PR improves the error output when attempting to use a raw identifier in a format string and adds a machine-applicable suggestion to remove the `r#`.

fixes https://github.com/rust-lang/rust/issues/115466
2023-09-17 11:23:25 +00:00
Dylan DPC
6011fd4655
Rollup merge of #115477 - kellerkindt:stabilized_int_impl, r=dtolnay
Stabilize the `Saturating` type

Closes #87920
Closes #92354

Stabilization report https://github.com/rust-lang/rust/issues/87920#issuecomment-1652346124
FCP https://github.com/rust-lang/rust/issues/87920#issuecomment-1676438885
2023-09-17 11:23:24 +00:00
Dylan DPC
584eb696df
Rollup merge of #115434 - soqb:ascii-char-manual-debug, r=dtolnay
make `Debug` impl for `ascii::Char` match that of `char`

# Objective
use a more recognisable format for the `Debug` impl on `ascii::Char` than the derived one based off the enum variants. The alogorithm used is the following:
 - escape `ascii::Char::{Null, CharacterTabulation, CarraigeReturn, LineFeed, ReverseSolidus, Apostrophe}` to `'\0'`, `'\t'`, `'\r'`, `'\n'`, `'\\'` and `'\''` respectively. these are the same escape codes as `<char as Debug>::fmt` uses.
 - if `u8::is_ascii_control` is false, print the character wrapped in single quotes.
 - otherwise, print in the format `'\xAB'` where `A` and `B` are the hex nibbles of the byte. (`char` uses unicode escapes and this seems like the corresponding ascii format).

Tracking issue: https://github.com/rust-lang/rust/issues/110998
2023-09-17 11:23:24 +00:00
Dylan DPC
7cbe7fa6bf
Rollup merge of #114965 - benschulz:mpsc-drop, r=dtolnay
Remove Drop impl of mpsc Receiver and (Sync)Sender

This change removes the empty `Drop` implementations for `mpsc::Receiver`, `mpsc::Sender` and `mpsc::SyncSender`. These implementations do not specify `#[may_dangle]`, so by removing them we make `mpsc` types play nice with drop check.

This was previously attempted in [#105243](https://github.com/rust-lang/rust/pull/105243#issuecomment-1337188646) but then [abandoned due to a test failure](https://github.com/rust-lang/rust/pull/105243#issuecomment-1337227970). I've aligned the test with those for `Mutex` and `RwLock`.
2023-09-17 11:23:23 +00:00
bors
327e6cf55c Auto merge of #114452 - weiznich:feature/diagnostic_on_unimplemented, r=compiler-errors
`#[diagnostic::on_unimplemented]` without filters

This commit adds support for a `#[diagnostic::on_unimplemented]` attribute with the following options:

* `message` to customize the primary error message
* `note` to add a customized note message to an error message
* `label` to customize the label part of the error message

The relevant behavior is specified in [RFC-3366](https://rust-lang.github.io/rfcs/3366-diagnostic-attribute-namespace.html)
2023-09-17 10:00:15 +00:00
bors
cdd182cbb2 Auto merge of #115514 - onur-ozkan:bootstrap-codebase-improvements, r=albertlarsan68
optimize and cleanup bootstrap source

I suggest reviewing this commit by commit.
2023-09-17 08:11:41 +00:00
bors
3ecc563628 Auto merge of #113748 - clarfonthey:ip-step, r=dtolnay
impl Step for IP addresses

ACP: rust-lang/libs-team#235

Note: since this is insta-stable, it requires an FCP.

Separating out from the bit operations PR since it feels logically disjoint, and so their FCPs can be separate.
2023-09-17 06:27:09 +00:00
onur-ozkan
9971008b8d micro-level optimizations for bootstrap
Overall optimizations for bootstrap on conditions, assertions,
trait implementations, etc.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-09-17 07:50:28 +03:00
onur-ozkan
12b1784b0b update the beginning part of bootstrap/README.md
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-09-17 07:50:18 +03:00
bors
a09c1f85f1 Auto merge of #115782 - a1phyr:improve_pad_adapter, r=dtolnay
Improve `PadAdapter::write_char`

Split from #108043
2023-09-17 01:47:49 +00:00
bors
d7229c479c Auto merge of #113753 - dvdsk:master, r=dtolnay
Add implementation for thread::sleep_until

- Feature gate is `thread::sleep_until`
- Tracking issue is: #113752
- APC: https://github.com/rust-lang/libs-team/issues/237
2023-09-17 00:02:45 +00:00
bors
7d9bce3273 Auto merge of #115900 - matthiaskrgr:rollup-3ba15da, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #115247 (Document std limitations before/after main)
 - #115329 (fix std::primitive doc: homogenous -> homogeneous)
 - #115487 (Improve documentation on when signes are printed by default)
 - #115560 (Update doc for `alloc::format!` and `core::concat!`)
 - #115836 (update rust_analyzer_settings.json)
 - #115884 (make ty::Const debug printing less verbose)
 - #115890 (Migrate GUI colors test to original CSS color format)
 - #115895 (Improve Vec(Deque)::truncate documentation)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-16 22:09:02 +00:00
Matthias Krüger
e2ea347517
Rollup merge of #115895 - 52:patch-docs-vec-truncate, r=dtolnay
Improve Vec(Deque)::truncate documentation

Fixes #115784
2023-09-16 23:20:43 +02:00
Matthias Krüger
5a8179bf5a
Rollup merge of #115890 - GuillaumeGomez:migrate-gui-test-color-41, r=notriddle
Migrate GUI colors test to original CSS color format

Follow-up of https://github.com/rust-lang/rust/pull/111459.

r? `@notriddle`
2023-09-16 23:20:42 +02:00
Matthias Krüger
abae2b66e8
Rollup merge of #115884 - RalfJung:const-debug-print, r=oli-obk
make ty::Const debug printing less verbose

Similar in spirit to https://github.com/rust-lang/rust/pull/115873
2023-09-16 23:20:42 +02:00
Matthias Krüger
edea0d5179
Rollup merge of #115836 - RalfJung:rust_analyzer_settings.json, r=compiler-errors
update rust_analyzer_settings.json

This works around https://github.com/rust-lang/rust-analyzer/issues/15595, and avoids relying on the unspecified working directory of this command.
2023-09-16 23:20:41 +02:00
Matthias Krüger
633f143921
Rollup merge of #115560 - ShE3py:format-results, r=dtolnay
Update doc for `alloc::format!` and `core::concat!`

Closes #115551.

Used comments instead of `assert!`s as [`std::fmt`](https://doc.rust-lang.org/std/fmt/index.html#usage) uses comments.

Should all the str-related macros (`format!`, `format_args!`, `concat!`, `stringify!`, `println!`, `writeln!`, etc.) references each others? For instance, [`concat!`](https://doc.rust-lang.org/core/macro.concat.html) mentions that integers are stringified, but don't link to `stringify!`.

`@rustbot` label +A-docs +A-fmt
2023-09-16 23:20:41 +02:00
Matthias Krüger
b8c4b78a79
Rollup merge of #115487 - ModProg:patch-1, r=dtolnay
Improve documentation on when signes are printed by default

I found the original formulation a bit irritating, but not sure if I really improved it.
2023-09-16 23:20:40 +02:00
Matthias Krüger
edfe8b4434
Rollup merge of #115329 - xzmeng:fix-std-doc, r=dtolnay
fix std::primitive doc: homogenous -> homogeneous

replace "homogenous" with the more commonly used "homogeneous".
2023-09-16 23:20:39 +02:00
Matthias Krüger
cf9ce96a5b
Rollup merge of #115247 - the8472:life-before-main, r=dtolnay
Document std limitations before/after main

Solves #110708
2023-09-16 23:20:39 +02:00
bors
341ef15eee Auto merge of #115733 - Zoxc:group-dep-node-kinds, r=cjgillot
Store a index per dep node kind

This stores an index map per dep node kind instead of using a single index map. This avoids storing `DepKind` in the key for greater cache efficiency.

<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th><td align="right">Memory</td><td align="right">Memory</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check:unchanged</td><td align="right">0.4376s</td><td align="right">0.4334s</td><td align="right"> -0.95%</td><td align="right">92.53 MiB</td><td align="right">92.39 MiB</td><td align="right"> -0.15%</td></tr><tr><td>🟣 <b>hyper</b>:check:unchanged</td><td align="right">0.1442s</td><td align="right">0.1446s</td><td align="right"> 0.29%</td><td align="right">47.48 MiB</td><td align="right">47.63 MiB</td><td align="right"> 0.31%</td></tr><tr><td>🟣 <b>regex</b>:check:unchanged</td><td align="right">0.3296s</td><td align="right">0.3261s</td><td align="right">💚  -1.06%</td><td align="right">72.37 MiB</td><td align="right">71.20 MiB</td><td align="right">💚  -1.62%</td></tr><tr><td>🟣 <b>syn</b>:check:unchanged</td><td align="right">0.6149s</td><td align="right">0.6014s</td><td align="right">💚  -2.19%</td><td align="right">105.74 MiB</td><td align="right">101.69 MiB</td><td align="right">💚  -3.83%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check:unchanged</td><td align="right">1.4882s</td><td align="right">1.4560s</td><td align="right">💚  -2.16%</td><td align="right">209.75 MiB</td><td align="right">201.46 MiB</td><td align="right">💚  -3.95%</td></tr><tr><td>Total</td><td align="right">3.0144s</td><td align="right">2.9616s</td><td align="right">💚  -1.75%</td><td align="right">527.87 MiB</td><td align="right">514.37 MiB</td><td align="right">💚  -2.56%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9879s</td><td align="right">💚  -1.21%</td><td align="right">1 byte</td><td align="right">0.98 bytes</td><td align="right">💚  -1.85%</td></tr></table>
2023-09-16 18:32:11 +00:00
bors
4514fb98d5 Auto merge of #112229 - clarfonthey:range-iter-count, r=dtolnay
Specialize count for range iterators

Since `size_hint` is already specialized, it feels apt to specialize `count` as well. Without any specialized version of `ExactSizeIterator::len` or `Step::steps_between`, this feels like a more reliable way of accessing this without having to rely on knowing that `size_hint` is correct.

In my case, this is particularly useful to access the `steps_between` implementation for `char` from the standard library without having to compute it manually.

I didn't think it was worth modifying the `Step` trait to add a version of `steps_between` that used native overflow checks since this is just doing one subtraction in most cases anyway, and so I decided to make the inclusive version use `checked_add` so it didn't have this lopsided overflow-checks-but-only-sometimes logic.
2023-09-16 16:43:31 +00:00
bors
409e7f6f21 Auto merge of #115894 - matthiaskrgr:rollup-pe5efh4, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #115860 (Enable varargs support for AAPCS calling convention)
 - #115867 (coverage: Simplify internal representation of debug types)
 - #115885 (don't globally ignore rustc-ice files)

Failed merges:

 - #115873 (Make `TyKind::Adt`'s `Debug` impl be more pretty)
 - #115884 (make ty::Const debug printing less verbose)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-16 14:55:47 +00:00
Ralf Jung
5a3410ad1a make ty::Const debug printing less verbose 2023-09-16 16:31:09 +02:00
mxnkarou
1c7a77a638
edit std::collections::VecDeque docs 2023-09-16 15:52:34 +02:00
mxnkarou
d1ff5e174b
edit std::vec::Vec::truncate docs 2023-09-16 15:46:31 +02:00
Matthias Krüger
04edb2bab8
Rollup merge of #115885 - RalfJung:dont-ignore-ice, r=oli-obk
don't globally ignore rustc-ice files

Reverts a change that happened in https://github.com/rust-lang/rust/pull/114586 but is unrelated to that PR and wasn't discussed.

ICE files appearing is somewhat of a nuisance, but I'd rather clean them up than have them accumulate in my source folder. `@oli-obk` if you want to ignore them you can add them to your local `.git/info/exclude`.
2023-09-16 15:18:24 +02:00
Matthias Krüger
77e0102d19
Rollup merge of #115867 - Zalathar:debug, r=oli-obk
coverage: Simplify internal representation of debug types

Most of these debug helper types store each of their fields as `Option<T>`, and then set them to `Some` when the relevant debug checks are enabled. This makes the struct fields awkward to read and results in some contortions when accessing the field values.

This PR addresses those problems by changing each of the helper types to have a single `state: Option<FooState>` field. Each individual method can then obtain the state up-front (or return early if it is absent), allowing the rest of the code to just access the state's contents directly.

---

There are some more improvements I'd like to make to the debug code, but for this PR I'm focusing on a straightforward mechanical change that should be fairly easy to review.

(I did thrown in a few trivial changes to imports and docs, along with one switch from `FxHashMap` to `FxHashSet`.)

---

Most of the changed lines are just indentation churn, so ignoring whitespace is recommended.
2023-09-16 15:18:23 +02:00
Matthias Krüger
ab90d708da
Rollup merge of #115860 - Soveu:varargs2, r=WaffleLapkin
Enable varargs support for AAPCS calling convention

Welp, I was looking for a reason why this shouldn't be stabilized after so long... and here it is.
2023-09-16 15:18:23 +02:00
bors
41bafc4ff3 Auto merge of #110800 - GuillaumeGomez:custom_code_classes_in_docs, r=t-rustdoc
Accept additional user-defined syntax classes in fenced code blocks

Part of #79483.

This is a re-opening of https://github.com/rust-lang/rust/pull/79454 after a big update/cleanup. I also converted the syntax to pandoc as suggested by `@notriddle:` the idea is to be as compatible as possible with the existing instead of having our own syntax.

## Motivation

From the original issue: https://github.com/rust-lang/rust/issues/78917

> The technique used by `inline-c-rs` can be ported to other languages. It's just super fun to see C code inside Rust documentation that is also tested by `cargo doc`. I'm sure this technique can be used by other languages in the future.

Having custom CSS classes for syntax highlighting will allow tools like `highlight.js` to be used in order to provide highlighting for languages other than Rust while not increasing technical burden on rustdoc.

## What is the feature about?

In short, this PR changes two things, both related to codeblocks in doc comments in Rust documentation:

 * Allow to disable generation of `language-*` CSS classes with the `custom` attribute.
 * Add your own CSS classes to a code block so that you can use other tools to highlight them.

#### The `custom` attribute

Let's start with the new `custom` attribute: it will disable the generation of the `language-*` CSS class on the generated HTML code block. For example:

```rust
/// ```custom,c
/// int main(void) {
///     return 0;
/// }
/// ```
```

The generated HTML code block will not have `class="language-c"` because the `custom` attribute has been set. The `custom` attribute becomes especially useful with the other thing added by this feature: adding your own CSS classes.

#### Adding your own CSS classes

The second part of this feature is to allow users to add CSS classes themselves so that they can then add a JS library which will do it (like `highlight.js` or `prism.js`), allowing to support highlighting for other languages than Rust without increasing burden on rustdoc. To disable the automatic `language-*` CSS class generation, you need to use the `custom` attribute as well.

This allow users to write the following:

```rust
/// Some code block with `{class=language-c}` as the language string.
///
/// ```custom,{class=language-c}
/// int main(void) {
///     return 0;
/// }
/// ```
fn main() {}
```

This will notably produce the following HTML:

```html
<pre class="language-c">
int main(void) {
    return 0;
}</pre>
```

Instead of:

```html
<pre class="rust rust-example-rendered">
<span class="ident">int</span> <span class="ident">main</span>(<span class="ident">void</span>) {
    <span class="kw">return</span> <span class="number">0</span>;
}
</pre>
```

To be noted, we could have written `{.language-c}` to achieve the same result. `.` and `class=` have the same effect.

One last syntax point: content between parens (`(like this)`) is now considered as comment and is not taken into account at all.

In addition to this, I added an `unknown` field into `LangString` (the parsed code block "attribute") because of cases like this:

```rust
/// ```custom,class:language-c
/// main;
/// ```
pub fn foo() {}
```

Without this `unknown` field, it would generate in the DOM: `<pre class="language-class:language-c language-c">`, which is quite bad. So instead, it now stores all unknown tags into the `unknown` field and use the first one as "language". So in this case, since there is no unknown tag, it'll simply generate `<pre class="language-c">`. I added tests to cover this.

Finally, I added a parser for the codeblock attributes to make it much easier to maintain. It'll be pretty easy to extend.

As to why this syntax for adding attributes was picked: it's [Pandoc's syntax](https://pandoc.org/MANUAL.html#extension-fenced_code_attributes). Even if it seems clunkier in some cases, it's extensible, and most third-party Markdown renderers are smart enough to ignore Pandoc's brace-delimited attributes (from [this comment](https://github.com/rust-lang/rust/pull/110800#issuecomment-1522044456)).

## Raised concerns

#### It's not obvious when the `language-*` attribute generation will be added or not.

It is added by default. If you want to disable it, you will need to use the `custom` attribute.

#### Why not using HTML in markdown directly then?

Code examples in most languages are likely to contain `<`, `>`, `&` and `"` characters. These characters [require escaping](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre) when written inside the `<pre>` element. Using the \`\`\` code blocks allows rustdoc to take care of escaping, which means doc authors can paste code samples directly without manually converting them to HTML.

cc `@poliorcetics`
r? `@notriddle`
2023-09-16 13:10:11 +00:00
onur-ozkan
90348db550 create helper module to be embedded for the bootstrap binaries
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-09-16 14:32:25 +03:00
bors
42dead4d23 Auto merge of #115889 - matthiaskrgr:rollup-kfmauvh, r=matthiaskrgr
Rollup of 2 pull requests

Successful merges:

 - #115607 (clarify that unsafe code must not rely on our safe traits)
 - #115866 (make interpreter and TyAndLayout type Debug impl independent of Ty debug impl)

Failed merges:

 - #115873 (Make `TyKind::Adt`'s `Debug` impl be more pretty)
 - #115884 (make ty::Const debug printing less verbose)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-16 10:53:22 +00:00
Guillaume Gomez
e691752210 Migrate GUI colors test to original CSS color format 2023-09-16 11:54:25 +02:00
Matthias Krüger
53cd9783c5
Rollup merge of #115866 - RalfJung:interpret-debug, r=compiler-errors
make interpreter and TyAndLayout type Debug impl independent of Ty debug impl

This fixes some (but not all) of the fallout from https://github.com/rust-lang/rust/pull/115661.

Second commit is taken from https://github.com/rust-lang/rust/pull/107084 (and slightly adjusted); I preserved the original git author information.
2023-09-16 11:48:18 +02:00
Matthias Krüger
c2f228f654
Rollup merge of #115607 - RalfJung:safe-traits-unsafe-code, r=dtolnay
clarify that unsafe code must not rely on our safe traits

This adds a disclaimer to PartialEq, Eq, PartialOrd, Ord, Hash, Deref, DerefMut.

We already have a similar disclaimer in ExactSizeIterator (worded a bit differently):
```
/// Note that this trait is a safe trait and as such does *not* and *cannot*
/// guarantee that the returned length is correct. This means that `unsafe`
/// code **must not** rely on the correctness of [`Iterator::size_hint`]. The
/// unstable and unsafe [`TrustedLen`](super::marker::TrustedLen) trait gives
/// this additional guarantee.
```
If there are any other traits that should carry such a disclaimer, please let me know.

Fixes https://github.com/rust-lang/rust/issues/73682
2023-09-16 11:48:18 +02:00
Guillaume Gomez
e39c39346b Fix invalid markdown codeblock label 2023-09-16 11:37:41 +02:00
bors
fd70f7eea2 Auto merge of #115740 - tmiasko:cache-reachable-set, r=cjgillot
Cache reachable_set on disk
2023-09-16 09:07:38 +00:00
Ralf Jung
ec1d04967d don't globally ignore rustc-ice files 2023-09-16 09:44:44 +02:00
ltdk
08aa6c9b65 Specialize count for range iterators 2023-09-16 01:33:56 -04:00
bors
790309b102 Auto merge of #115315 - RalfJung:field-capture-packed-alignment, r=oli-obk
closure field capturing: don't depend on alignment of packed fields

This fixes the closure field capture part of https://github.com/rust-lang/rust/issues/115305: field capturing always stops at projections into packed structs, no matter the alignment of the field. This means changing a private field type from `u8` to `u64` can never change how closures capture fields, which is probably what we want.

Here's an example where, before this PR, changing the type of a private field in a repr(Rust) struct can change the output of a program:

```rust
#![allow(dead_code)]

mod m {
    // before patch
    #[derive(Default)]
    pub struct S1(u8);
    // after patch
    #[derive(Default)]
    pub struct S2(u64);
}

struct NoisyDrop;
impl Drop for NoisyDrop {
    fn drop(&mut self) {
        eprintln!("dropped!");
    }
}

#[repr(packed)]
struct MyType {
    field: m::S1, // output changes when this becomes S2
    other_field: NoisyDrop,
    third_field: Vec<()>,
}

fn test(r: MyType) {
    let c = || {
        let _val = std::ptr::addr_of!(r.field);
        let _val = r.third_field;
    };
    drop(c);
    eprintln!("before dropping");
}

fn main() {
    test(MyType {
        field: Default::default(),
        other_field: NoisyDrop,
        third_field: Vec::new(),
    });
}
```

Of course this is a breaking change for the same reason that doing field capturing in the first place was a breaking change. Packed fields are relatively rare and depending on drop order is relatively rare, so I don't expect this to have much impact, but it's hard to be sure and even a crater run will only tell us so much.

Also see the [nomination comment](https://github.com/rust-lang/rust/pull/115315#issuecomment-1702807825).

Cc `@rust-lang/wg-rfc-2229` `@ehuss`
2023-09-16 05:29:23 +00:00
ltdk
8184c9c50d impl Step for IP addresses 2023-09-16 01:28:13 -04:00
bors
635c4a5e61 Auto merge of #114494 - est31:extend_useless_ptr_null_checks, r=jackh726
Make useless_ptr_null_checks smarter about some std functions

This teaches the `useless_ptr_null_checks` lint that some std functions can't ever return null pointers, because they need to point to valid data, get references as input, etc.

This is achieved by introducing an `#[rustc_never_returns_null_ptr]` attribute and adding it to these std functions (gated behind bootstrap `cfg_attr`).

Later on, the attribute could maybe be used to tell LLVM that the returned pointer is never null. I don't expect much impact of that though, as the functions are pretty shallow and usually the input data is already never null.

Follow-up of PR #113657

Fixes #114442
2023-09-16 03:40:20 +00:00
Zalathar
91e0b46f76 coverage: Replace an unnecessary map with a set
This hashmap's values were never used.
2023-09-16 12:07:35 +10:00
Zalathar
3b5b1aa2a5 coverage: Simplify internal representation of debug types 2023-09-16 12:07:35 +10:00