Commit Graph

28098 Commits

Author SHA1 Message Date
Nicholas Nethercote
af7d3e501b Remove unused Lift derives.
I found these by commenting out all `Lift` derives and then adding back
the ones that were necessary to successfully compile.
2023-09-18 09:37:10 +10:00
Nicholas Nethercote
6b1980f9cf Rename CloneLiftImpls as TrivialLiftImpls.
To match `TrivialTypeTraversalImpls` and
`TrivialTypeTraversalAndLiftImpls`, and because the `Clone` doesn't mean
anything.
2023-09-18 09:37:09 +10:00
Nicholas Nethercote
46fe65d0e5 Remove unused Display impls. 2023-09-18 09:37:09 +10:00
Nicholas Nethercote
1281d43942 Remove RegionHighlightMode::tcx.
It's easier to pass it in to the one method that needs it
(`highlighting_region_vid`) than to store it in the type. This means
`RegionHighlightMode` can impl `Default`.
2023-09-18 09:37:09 +10:00
Ralf Jung
3b817b2810 nop_lift macros: ensure that we are using the right interner 2023-09-17 20:52:15 +02: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
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
Camille GILLOT
5d18a0edb4 Do not clone MIR for const-prop lint. 2023-09-17 09:00:51 +00: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
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
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
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
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
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
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
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
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
Zalathar
d0d1187ebb coverage: Update log module names in debug docs 2023-09-16 12:07:35 +10:00
Zalathar
d79cd17199 coverage: Arrange imports in rustc_mir_transform::coverage::debug 2023-09-16 12:07:35 +10:00
Boxy
71cab64079 special case TyAndLayout debug impl 2023-09-15 22:57:07 +02:00
Guillaume Gomez
6e21e4823d Fix incorrect codeblock attributes in docs 2023-09-15 21:32:29 +02:00
Guillaume Gomez
5515fc88dc Implement custom classes for rustdoc code blocks with custom_code_classes_in_docs feature 2023-09-15 21:32:27 +02:00
Krasimir Georgiev
af401b0ca3 llvm-wrapper: adapt for LLVM API changes
No functional changes intended.

Adapts the wrapper for 0a1aa6cda2.

Found by our experimental rust + llvm @ head CI: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/22301#018a9926-a810-4e56-8ac2-e6f30b78f433/253-551
2023-09-15 14:31:43 +00:00
clubby789
8696ee8b09 Migrate 'missing fn lang items' diagnostic 2023-09-15 14:24:58 +00:00
clubby789
cb9f666fdf Migrate 'invalid callee' diagnostic 2023-09-15 14:24:58 +00:00
clubby789
b40f11c8a9 Migrate 'rust-call incorrect arguments' diagnostic 2023-09-15 14:24:58 +00:00
clubby789
9edeb19f96 Allow internal untranslatable diagnostic 2023-09-15 14:24:58 +00:00
clubby789
6e2adbf6a3 Migrate 'explicit destructor call' diagnostic 2023-09-15 14:24:58 +00:00
Pietro Albini
d695b95e3b
implement -Z ignore-directory-in-diagnostics-source-blocks 2023-09-15 16:22:50 +02:00
bors
e7f9f48d76 Auto merge of #115853 - obeis:hir-analysis-migrate-diagnostics-6, r=compiler-errors
Migrate `rustc_hir_analysis` to session diagnostic [Part 6]

Part 6: Finish `coherence/inherent_impls.rs` file
2023-09-15 11:55:27 +00:00
Ralf Jung
3ee65c28e9 cannot have Direct for unsized types 2023-09-15 10:45:37 +02:00
Ralf Jung
29a4b7b971 fix gcc, cranelift build 2023-09-15 10:43:44 +02:00
Ralf Jung
89139d4c46 clarify PassMode::Indirect as well 2023-09-15 10:43:44 +02:00
Ralf Jung
7740476a43 explain PassMode::Cast 2023-09-15 10:43:44 +02:00
Ralf Jung
06a76ab415 make interpreter type Debug impl independent of Ty debug impl 2023-09-15 09:54:06 +02:00
bors
915c8af550 Auto merge of #115850 - compiler-errors:effect-canon, r=fee1-dead
Canonicalize effect vars in new solver

No good reason not to fix this, we already have all the machinery to make this work.

r? `@fee1-dead`

Fixes #115792
2023-09-15 06:45:56 +00:00
Michael Goulet
280f058560 Canonicalize effect vars in new solver 2023-09-15 05:11:16 +00:00
bors
9cbc90c0ae Auto merge of #115861 - clubby789:migrate-remove-semi-diag, r=compiler-errors
Make 'remove semi to coerce match' diagnostic translatable
2023-09-15 04:56:26 +00:00
clubby789
b663464ea0 Make 'remove semi to coerce match' diagnostic translatable 2023-09-15 00:45:09 +00:00
bors
ae9465fee3 Auto merge of #115859 - compiler-errors:effect-fallback, r=fee1-dead
Fallback effects even if types also fallback

`||` is short circuiting, so if we do ty/int var fallback, we *don't* do effect fallback 😸

r? `@fee1-dead` or `@oli-obk`

Fixes #115791
Fixes #115842
2023-09-15 00:05:28 +00:00
Soveu
eea6149e03 Enable varargs support for AAPCS calling convention
This is the default calling convention for ARM - it is used for extern "C",
therefore it supports varargs.
2023-09-14 23:21:39 +02:00
Michael Goulet
5c907a7859 Fallback effects even if types also fall back 2023-09-14 21:08:42 +00:00
Ralf Jung
9ac8b363e3 don't point at const usage site for resolution-time errors
also share the code that emits the actual error
2023-09-14 22:34:05 +02:00
Ralf Jung
89ac57db4d move required_consts check to general post-mono-check function 2023-09-14 22:30:42 +02:00
bors
dac91a82e1 Auto merge of #115677 - matthewjasper:let-expr-recovery, r=b-naber
Improve invalid let expression handling

- Move all of the checks for valid let expression positions to parsing.
- Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location.
- Suppress some later errors and MIR construction for invalid let expressions.
- Fix a (drop) scope issue that was also responsible for #104172.

Fixes #104172
Fixes #104868
2023-09-14 19:56:55 +00:00
Obei Sideg
8723af5116 Migrate rustc_hir_analysis to session diagnostic
Part 6: Finish `coherence/inherent_impls.rs`
2023-09-14 21:50:22 +03:00
bors
ccf817b9bb Auto merge of #115848 - matthiaskrgr:rollup-lsul9dz, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #115772 (Improve Span in smir)
 - #115832 (Fix the error message for `#![feature(no_coverage)]`)
 - #115834 (Properly consider binder vars in `HasTypeFlagsVisitor`)
 - #115844 (Paper over an accidental regression)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-14 17:22:20 +00:00
Matthias Krüger
9362604518
Rollup merge of #115844 - oli-obk:opaque_lifetime_ambiguity, r=jackh726
Paper over an accidental regression

r? types

cc https://github.com/rust-lang/rust/issues/115781 (do not close issue until beta backport has been performed)

The PR reasons are explained with comments in the source.

In order to keep the diff simple, this PR effectively reverts https://github.com/rust-lang/rust/pull/113661, but only for RPITs. I will submit a follow up PR that fixes this correctly instead of just disabling the newly added check for RPITs. This PR should be significantly easier to review for beta backport
2023-09-14 19:12:33 +02:00
Matthias Krüger
57370828b9
Rollup merge of #115834 - compiler-errors:binder-vars, r=jackh726
Properly consider binder vars in `HasTypeFlagsVisitor`

Given a PolyTraitRef like `for<'a> Ty: Trait` (where neither `Ty` nor `Trait` mention `'a`), we do *not* return true for `.has_type_flags(TypeFlags::HAS_LATE_BOUND)`, even though binders are supposed to act as if they have late-bound vars even if they don't mention them in their bound value: 31ae3b2bdb. This is because we use `HasTypeFlagsVisitor`, which only computes the type flags for `Ty`, `Const` and `Region` and `Predicates`, and we consequently skip any binders (and setting flags for their vars) that are not contained in one of these types.

This ends up causing a problem, because when we call `TyCtxt::erase_regions` (which both erases regions *and* anonymizes bound vars), we will skip such a PolyTraitRef, not anonymizing it, and therefore not making it structurally equal to other binders. This breaks vtable computations.

This PR computes the flags for all binders we enter in `HasTypeFlagsVisitor` if we're looking for `TypeFlags::HAS_LATE_BOUND` (or `TypeFlags::HAS_{RE,TY,CT}_LATE_BOUND`).

Fixes #115807
2023-09-14 19:12:32 +02:00
Matthias Krüger
3dbcc28884
Rollup merge of #115832 - Zalathar:fix-no-coverage, r=oli-obk
Fix the error message for `#![feature(no_coverage)]`

When #114656 was written, the feature flag to replace `no_coverage` was originally spelled `coverage`, but it was eventually changed to `coverage_attribute` instead.

That update happened to miss this error message in `removed.rs`, and unfortunately I only noticed just *after* the original PR was approved and merged.

cc ``@bossmc`` (original author) ``@oli-obk`` (original reviewer)
``@rustbot`` label +A-code-coverage
2023-09-14 19:12:32 +02:00
Matthias Krüger
4f90a52ae6
Rollup merge of #115772 - ouz-a:smir_span2, r=oli-obk
Improve Span in smir

Addressing https://github.com/rust-lang/project-stable-mir/issues/31

r? ``@oli-obk``
2023-09-14 19:12:31 +02:00
bors
e437e57954 Auto merge of #115804 - RalfJung:valtree-to-const-val, r=oli-obk
consistently pass ty::Const through valtrees

Some drive-by things extracted from https://github.com/rust-lang/rust/pull/115748.
2023-09-14 15:34:31 +00:00
Oli Scherer
0277184977 Paper over an accidental regression 2023-09-14 15:16:48 +00:00
bors
5e71913156 Auto merge of #115817 - fee1-dead-contrib:fix-codegen, r=oli-obk
treat host effect params as erased in codegen

This fixes the changes brought to codegen tests when effect params are added to libcore, by not attempting to monomorphize functions that get the host param by being `const fn`.

r? `@oli-obk`
2023-09-14 13:42:30 +00:00
lcnr
0cb800ec34 differentiate root and nested goals 2023-09-14 15:10:45 +02:00
bors
df63c5f140 Auto merge of #112038 - Nemo157:edition-2024-unsafe_op_in_unsafe_fn, r=RalfJung
Change `unsafe_op_in_unsafe_fn` to be `warn`-by-default from edition 2024

This was previously FCPed: https://github.com/rust-lang/rust/issues/71668#issuecomment-1189396886

There were two blocking requirements:
* Fix the `unused_unsafe` lint, done in https://github.com/rust-lang/rust/pull/100081
* Have `cargo fix` able to fix the lint, done in https://github.com/rust-lang/rust/pull/112017
2023-09-14 11:52:08 +00:00
bors
d97e04fbfc Auto merge of #115764 - RalfJung:const-by-ref-alloc-id, r=oli-obk
some ConstValue refactoring

In particular, use AllocId instead of Allocation in ConstValue::ByRef. This helps avoid redundant AllocIds when a  `ByRef` constant gets put back into the interpreter.

r? `@oli-obk`

Fixes https://github.com/rust-lang/rust/issues/105536
2023-09-14 10:04:45 +00:00
Ralf Jung
b18c0a8c4e fix clippy (and MIR printing) handling of ConstValue::Indirect slices 2023-09-14 11:56:55 +02:00
Ralf Jung
7aa44eee99 don't force all slice-typed ConstValue to be ConstValue::Slice 2023-09-14 11:56:55 +02:00
lcnr
1b141b6d73 inspect: explicitly store added goals 2023-09-14 10:41:36 +02:00
lcnr
a3f9530b30 order added_goals_evaluation and nested_probes 2023-09-14 10:20:23 +02:00
lcnr
be9d7e0b94 GoalCandidate to Probe 2023-09-14 09:58:29 +02:00
Deadbeef
a0a801cd38 treat host effect params as erased generics in codegen
This fixes the changes brought to codegen tests when effect params are
added to libcore, by not attempting to monomorphize functions that get
the host param by being `const fn`.
2023-09-14 07:34:35 +00:00
bors
e17235105c Auto merge of #115825 - cjgillot:expr-field-lint, r=compiler-errors
Visit ExprField for lint levels.

Fixes https://github.com/rust-lang/rust/issues/115823
2023-09-14 06:29:23 +00:00
Ralf Jung
19fb2c7ccd found another place where we can eval() a const, and go through valtrees 2023-09-14 07:56:01 +02:00
Ralf Jung
292d5bba86 always evaluate ConstantKind::Ty through valtrees 2023-09-14 07:44:49 +02:00
Ralf Jung
06947be196 valtree_to_const_value: add fast-path for Scalar tuples/structs 2023-09-14 07:40:05 +02:00
Ralf Jung
430c386821 make it more clear which functions create fresh AllocId 2023-09-14 07:27:31 +02:00
Ralf Jung
0f8908da27 cleanup op_to_const a bit; rename ConstValue::ByRef → Indirect 2023-09-14 07:27:30 +02:00
Ralf Jung
551f481ffb use AllocId instead of Allocation in ConstValue::ByRef 2023-09-14 07:26:24 +02:00
Ralf Jung
3aedb85a27 a bit of cleanup in valtree_to_const_value 2023-09-14 07:22:44 +02:00
bors
2394959310 Auto merge of #115751 - lcnr:inspect-cleanup, r=compiler-errors
some inspect improvements

split from #114810 because I still want to experiment a bunch with that PR and these changes are self-contained.

r? `@compiler-errors`
2023-09-14 04:42:07 +00:00
Michael Goulet
7ae301ec47 Properly consider binder vars in HasTypeFlagsVisitor 2023-09-14 03:49:59 +00:00
Zalathar
c397ca0677 Fix the error message for #![feature(no_coverage)] 2023-09-14 13:01:54 +10:00
bors
c728bf3963 Auto merge of #114656 - bossmc:rework-no-coverage-attr, r=oli-obk
Rework `no_coverage` to `coverage(off)`

As discussed at the tail of https://github.com/rust-lang/rust/issues/84605 this replaces the `no_coverage` attribute with a `coverage` attribute that takes sub-parameters (currently `off` and `on`) to control the coverage instrumentation.

Allows future-proofing for things like `coverage(off, reason="Tested live", issue="#12345")` or similar.
2023-09-14 01:05:18 +00:00
ouz-a
fa57a48cf5 span is index 2023-09-14 00:32:21 +03:00
Camille GILLOT
01d7bf09f3 Visit ExprField for lint levels. 2023-09-13 19:47:20 +00:00
bors
eb2446a57e Auto merge of #115820 - matthiaskrgr:rollup-kyglvpu, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #115736 (Remove `verbose_generic_activity_with_arg`)
 - #115771 (cleanup leftovers of const_err lint)
 - #115798 (add helper method for finding the one non-1-ZST field)
 - #115812 (Merge settings.css into rustdoc.css)
 - #115815 (fix: return early when has tainted in mir pass)
 - #115816 (Disabled socketpair for Vita)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-13 18:19:15 +00:00
Michael Goulet
8fbd78ccea Detect cycle errors hidden by opaques during monomorphization 2023-09-13 17:35:44 +00:00
Matthias Krüger
48d89a8759
Rollup merge of #115815 - bvanjoi:fix-115809, r=oli-obk
fix: return early when has tainted in mir pass

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

As in #115643, `run_pass` is skipped if the body has tainted errors.

r? `@oli-obk`
2023-09-13 18:37:43 +02:00
Matthias Krüger
565b9c2264
Rollup merge of #115798 - RalfJung:non_1zst_field, r=wesleywiser
add helper method for finding the one non-1-ZST field
2023-09-13 18:37:42 +02:00
Matthias Krüger
1ec29fb24f
Rollup merge of #115771 - RalfJung:no-more-const-err-lint, r=oli-obk
cleanup leftovers of const_err lint

Some code / comments seem to not have been updated when const_err was turned into a hard error, so we can do a bit of cleanup here.

r? `@oli-obk`
2023-09-13 18:37:42 +02:00
Matthias Krüger
5dc37c1966
Rollup merge of #115736 - Zoxc:time-cleanup, r=wesleywiser
Remove `verbose_generic_activity_with_arg`

This removes `verbose_generic_activity_with_arg` and changes users to `generic_activity_with_arg`. This keeps the output of `-Z time` readable while these repeated events are still available with the self profiling mechanism.
2023-09-13 18:37:41 +02:00
bors
5adddad28c Auto merge of #115797 - cjgillot:const-prop-noclone, r=oli-obk
Do not clone the Body for ConstProp

~Based on https://github.com/rust-lang/rust/pull/115748 for the `POST_MONO_CHECKS` flag.~
2023-09-13 16:30:07 +00:00
bohan
7c53e87d55 fix: skip opt if body has tainted error 2023-09-13 23:07:39 +08:00
Matthew Jasper
e324a59eb6 Address review comments
- Add doc comment to new type
- Restore "only supported directly in conditions of `if` and `while` expressions" note
- Rename variant with clearer name
2023-09-13 15:00:31 +00:00
bors
76e59c71e8 Auto merge of #115803 - RalfJung:const-eval, r=oli-obk
make the eval() functions on our const types return the resulting value

This is a part of https://github.com/rust-lang/rust/pull/115748 that's hopefully perf-neutral, and that does not depend on https://github.com/rust-lang/rust/pull/115764.
2023-09-13 14:41:55 +00:00
bors
735bb7e5df Auto merge of #115269 - bvanjoi:fix-113834, r=petrochenkov
resolve: mark binding is determined after all macros had been expanded

Fixes #113834
Fixes #115377

r? `@petrochenkov`
2023-09-13 12:11:53 +00:00
John Kåre Alsaker
c64e15e817 Bring back verbose_generic_activity_with_arg 2023-09-13 13:41:19 +02:00