Commit Graph

23191 Commits

Author SHA1 Message Date
clubby789
979c265a5d Check for escape sequences in Fluent resources 2023-03-29 18:34:29 +01:00
bors
bf57e8ada6 Auto merge of #108080 - oli-obk:FnPtr-trait, r=lcnr
Add a builtin `FnPtr` trait that is implemented for all function pointers

r? `@ghost`

Rebased version of https://github.com/rust-lang/rust/pull/99531 (plus adjustments mentioned in the PR).

If perf is happy with this version, I would like to land it, even if the diagnostics fix in 9df8e1befb5031a5bf9d8dfe25170620642d3c59 only works for `FnPtr` specifically, and does not generally improve blanket impls.
2023-03-28 12:50:01 +00:00
bors
60660371ef Auto merge of #109557 - fee1-dead-contrib:mv-const-traits, r=oli-obk
Move const trait bounds checks to MIR constck

Fixes #109543. When checking paths in HIR typeck, we don't want to check for const predicates since all we want might just be a function pointer. Therefore we move this to MIR constck and check that bounds are met during MIR constck.

r? `@oli-obk`
2023-03-28 09:43:19 +00:00
Deadbeef
b17e6680d6 Move const trait bounds checks to MIR constck
Fixes #109543. When checking paths in HIR typeck, we don't want to check
for const predicates since all we want might just be a function pointer.
Therefore we move this to MIR constck and check that bounds are met
during MIR constck.
2023-03-28 08:39:55 +00:00
Matthias Krüger
cad4893a52
Rollup merge of #109685 - est31:not_llvm_but_backend, r=jyn514
Make doc comment a little bit more accurate

It queries not LLVM in particular but the codegen backend *in general*. While cranelift does not provide target features, other codegen backends do.

Found while looking for [this answer](https://github.com/rust-lang/rust/issues/108680#issuecomment-1484324690).
2023-03-28 07:01:12 +02:00
Matthias Krüger
fceb3d49f4
Rollup merge of #109678 - compiler-errors:dont-shadow-in-incremental_verify_ich_failed, r=Nilstrieb
Don't shadow the `dep_node` var in `incremental_verify_ich_failed`

It's better to debug print `DepNode` instead of `ErrorGuaranteed` one line below :^)

fixes #109676
2023-03-28 07:01:11 +02:00
Matthias Krüger
eee3f484f9
Rollup merge of #109565 - WaffleLapkin:better_docs_for_e0223, r=oli-obk
Improve documentation for E0223

See discussion in https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Inconsistency.20in.20prohibiting.20.60Type.3A.3AAssocType.60
2023-03-28 07:01:08 +02:00
Matthias Krüger
a7c07cf731
Rollup merge of #108548 - jamen:master, r=compiler-errors
Clarify the 'use a constant in a pattern' error message

```rs
use std::borrow::Cow;

const ERROR_CODE: Cow<'_, str> = Cow::Borrowed("23505");

fn main() {
    let x = Cow::from("23505");

    match x {
        ERROR_CODE => {}
    }
}
```
```
error: to use a constant of type `Cow` in a pattern, `Cow` must be annotated with `#[derive(PartialEq, Eq)]`
 --> src/main.rs:9:9
  |
9 |         ERROR_CODE => {}
  |         ^^^^^^^^^^

error: could not compile `playground` due to previous error
```

It seems helpful to link to StructuralEq in this message. I was a little confused, because `Cow<'_, str>` implements PartialEq and Eq, but they're not derived, which I learned is necessary for structural equality and using constants in patterns (thanks to the Rust community Discord server)

For tests, should I update every occurrence of this message? I see tests where this is still a warning and I'm not sure if I should update those.
2023-03-28 07:01:08 +02:00
est31
7bbc8ef022 Make doc comment a little bit more accurate
It queries not LLVM in particular but the codegen backend *in general*.
While cranelift does not provide target features, other codegen backends do.
2023-03-28 02:19:46 +02:00
bors
5bf139e360 Auto merge of #109440 - WaffleLapkin:make_tidy_slower, r=jyn514
Don't skip all directories when tidy-checking

This fixes a regression from https://github.com/rust-lang/rust/pull/108772 which basically made it that tidy style checks only `README.md` and `COMPILER_TESTS.md`.
2023-03-27 22:19:56 +00:00
Michael Goulet
f738b44c6d no shadow plz 2023-03-27 20:47:15 +00:00
Maybe Waffle
904dd2c398 Bless tidy 2023-03-27 18:58:07 +00:00
Maybe Waffle
3c4fabc341 Improve documentation for E0223 2023-03-27 18:00:22 +00:00
Guillaume Gomez
b1e8be783f
Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errors
Remove the `NodeId` of `ast::ExprKind::Async`

This is a followup to https://github.com/rust-lang/rust/pull/104833#pullrequestreview-1314537416.

In my original attempt, I was using `LoweringContext::expr`, which was not correct as it creates a fresh `DefId`.
It now uses the correct `DefId` for the wrapping `Expr`, and also makes forwarding `#[track_caller]` attributes more explicit.
2023-03-27 18:56:19 +02:00
Jamen Marz
73c34cbaf7 Add notes to non-structural const in pattern error message 2023-03-27 11:08:11 -04:00
Matthias Krüger
7f6b406fa1
Rollup merge of #109582 - scottmcm:local-ref-pending, r=oli-obk
Refactor: Separate `LocalRef` variant for not-evaluated-yet operands

As I was reading through this, I noticed that almost every place that was using this needed to distinguish between Some vs None in the match arm anyway, so thought that separating the cases at the variant level might be clearer instead.

I like how it ended up; let me know what you think!
2023-03-27 15:32:42 +02:00
Matthias Krüger
9c73bf9038
Rollup merge of #109580 - compiler-errors:new-solver-fixmes, r=lcnr
Remove some stale FIXMEs in new solver

Some FIXMEs are no longer needed
2023-03-27 15:32:41 +02:00
Oli Scherer
9e27c6c133 Some tracing/instrument cleanups 2023-03-27 12:19:15 +00:00
lcnr
0c13565ca6 Add a builtin FnPtr trait 2023-03-27 12:16:54 +00:00
bors
553ecbe8ba Auto merge of #109652 - matthiaskrgr:rollup-pbw3hi3, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #97506 (Stabilize `nonnull_slice_from_raw_parts`)
 - #98651 (Follow C-RW-VALUE in std::io::Cursor example)
 - #102742 (Remove unnecessary raw pointer in __rust_start_panic arg)
 - #109587 (Use an IndexVec to debug fingerprints.)
 - #109613 (fix type suggestions in match arms)
 - #109633 (Fix "Directly go to item in search if there is only one result" setting)
 - #109635 (debuginfo: Get pointer size/align from tcx.data_layout instead of layout_of)
 - #109641 (Don't elaborate non-obligations into obligations)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-27 10:44:27 +00:00
Matthias Krüger
6535e66fa5
Rollup merge of #109641 - compiler-errors:dont-elaborate-non-obl, r=oli-obk
Don't elaborate non-obligations into obligations

It's suspicious to elaborate a `PolyTraitRef` or `Predicate` into an `Obligation`, since the former does not have a param-env associated with it, but the latter does. This is a footgun that, while not being misused *currently* in the compiler, easily could be misused by someone less familiar with the elaborator's inner workings.

This PR just changes the API -- ideally, the elaborator wouldn't even have to deal with obligations if we're not elaborating obligations, but that would require a bit more abstraction than I could be bothered with today.
2023-03-27 08:46:55 +02:00
Matthias Krüger
2b7dc94535
Rollup merge of #109635 - Nilstrieb:debrrruginfo, r=compiler=errors
debuginfo: Get pointer size/align from tcx.data_layout instead of layout_of

This avoids some type interning and a query execution. It also just makes the code simpler.
2023-03-27 08:46:54 +02:00
Matthias Krüger
04b8523c46
Rollup merge of #109613 - lukas-code:match-str-to-char-suggestion, r=compiler-errors
fix type suggestions in match arms

fix https://github.com/rust-lang/rust/issues/109586
2023-03-27 08:46:53 +02:00
Matthias Krüger
32aa4c03d9
Rollup merge of #109587 - cjgillot:no-hashmap-fingerprint, r=Nilstrieb
Use an IndexVec to debug fingerprints.

Uncontroversial part of https://github.com/rust-lang/rust/pull/109050
2023-03-27 08:46:52 +02:00
bors
7a0600714a Auto merge of #109091 - Nilstrieb:match-on-attr, r=cjgillot
Cleanup `codegen_fn_attrs`

The `match` control flow construct has been stable since 1.0, we should use it here.

Sorry for the hard to review diff, I did try to at least split it into two commits. But looking at before-after side-by-side (instead of whatever github is doing) is probably the easiest way to make sure that I didn't forget about anything.

On top of #109088, you can wait for that
2023-03-27 05:01:19 +00:00
Michael Goulet
1ce4b37900 Don't elaborate non-obligations into obligations 2023-03-26 20:33:54 +00:00
Nilstrieb
72c917d4be debuginfo: Get pointer size/align from tcx.data_layout instead of layout_of
This avoids some type interning and a query execution. It also just
makes the code simpler.
2023-03-26 20:05:17 +02:00
bors
89c2e3d3d7 Auto merge of #109626 - matthiaskrgr:rollup-k0y7bdd, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #109007 (rustdoc: skip `// some variants omitted` if enum is `#[non_exhaustive]`)
 - #109593 (Rustdoc Book refer to rustdoc::missing_doc_code_examples. Fixes #109592.)
 - #109595 (Improve "Auto-hide trait implementation documentation" GUI test)
 - #109619 (Still-further-specializable projections are ambiguous in new solver)
 - #109620 (Correct typo (`back_box` -> `black_box`))
 - #109621 (Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-26 12:05:38 +00:00
Matthias Krüger
4aa4ce6ee2
Rollup merge of #109621 - scottmcm:update-variantidx, r=compiler-errors
Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT`

Since structs are always `VariantIdx(0)`, there's a bunch of files where the only reason they had `VariantIdx` or `vec::Idx` imported at all was to get the first variant.

So this uses a constant for that, and adds some doc-comments to `VariantIdx` while I'm there, since [it doesn't have any today](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/abi/struct.VariantIdx.html).
2023-03-26 08:39:28 +02:00
Matthias Krüger
705435fe01
Rollup merge of #109619 - compiler-errors:new-solver-still-further-specializable, r=BoxyUwU
Still-further-specializable projections are ambiguous in new solver

Fixes https://github.com/rust-lang/rust/pull/108896/files#r1148450781

r? ``@BoxyUwU`` (though feel free to re-roll)

---

This can be used to create an unsound transmute function with the new solver:

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

trait Default {
   type Id;

   fn intu(&self) -> &Self::Id;
}

impl<T> Default for T {
   default type Id = T;

   fn intu(&self) -> &Self::Id {
        self
   }
}

fn transmute<T: Default<Id = U>, U: Copy>(t: T) -> U {
    *t.intu()
}

use std::num::NonZeroU8;
fn main() {
    let s = transmute::<u8, Option<NonZeroU8>>(0);
    assert_eq!(s, None);
}
```
2023-03-26 08:39:27 +02:00
bors
2420bd34ba Auto merge of #106428 - saethlin:inline-diverging-functions, r=cjgillot
Permit the MIR inliner to inline diverging functions

This heuristic prevents inlining of `hint::unreachable_unchecked`, which in turn makes `Option/Result::unwrap_unchecked` a bad inlining candidate. I looked through the changes to `core`, `alloc`, `std`, and `hashbrown` by hand and they all seem reasonable. Let's see how this looks in perf...

---

Based on rustc-perf it looks like this regresses ctfe-stress, and the cachegrind diff indicates that this regression is in `InterpCx::statement`. I don't know how to do any deeper analysis because that function is _enormous_ in the try toolchain, which has no debuginfo in it. And a local build produces significantly different codegen for that function, even with LTO.
2023-03-26 05:55:32 +00:00
Scott McMurray
0439d13176 Refactor: VariantIdx::from_u32(0) -> FIRST_VARIANT
Since structs are always `VariantIdx(0)`, there's a bunch of files where the only reason they had `VariantIdx` or `vec::Idx` imported at all was to get the first variant.

So this uses a constant for that, and adds some doc-comments to `VariantIdx` while I'm there, since it doesn't have any today.
2023-03-25 18:58:25 -07:00
Michael Goulet
3310f72db9 transmute test 2023-03-26 00:03:14 +00:00
Michael Goulet
20679b1166 Still-further-specializable projections are ambiguous 2023-03-25 23:51:08 +00:00
Lukas Markeffsky
08f3deb3d5 fix type suggestions in match arms 2023-03-25 22:27:24 +01:00
Ben Kimock
88e78aba82 Explain how we get to skip checking for cleanup blocks in the visitor 2023-03-25 13:58:49 -04:00
bors
2d429f3064 Auto merge of #109458 - Nilstrieb:smol-cute-little-bits, r=wesleywiser
Use `SmallVec` in bitsets

This doesn't increase their size and means that we don't have to heap allocate for small sets.
2023-03-25 17:06:43 +00:00
bors
96bd50dd47 Auto merge of #109581 - matthiaskrgr:rollup-e8fi2vi, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #109355 (Fix bad suggestion for clone/is_some in field init shorthand)
 - #109484 (Bugfix: avoid panic on invalid json output from libtest)
 - #109539 (Refactor `find_*_stability` functions)
 - #109542 (rustdoc: clean up `storage.js`)
 - #109545 (Deeply check well-formedness of return-position `impl Trait` in trait)
 - #109568 (miri: fix raw pointer dyn receivers)
 - #109570 (Add GUI test for "Auto-hide item methods' documentation" setting)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-25 14:34:13 +00:00
bors
b72e896268 Auto merge of #109100 - Zoxc:merge-query-try, r=cjgillot
Refactor `try_execute_query`

This merges `JobOwner::try_start` into `try_execute_query`, removing `TryGetJob` in the processes. 3 new functions are extracted from `try_execute_query`: `execute_job`, `cycle_error` and `wait_for_query`. This makes the control flow a bit clearer and improves performance.

Based on https://github.com/rust-lang/rust/pull/109046.

<table><tr><td rowspan="2">Benchmark</td><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></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.7134s</td><td align="right">1.7061s</td><td align="right"> -0.43%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2519s</td><td align="right">0.2510s</td><td align="right"> -0.35%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.9517s</td><td align="right">0.9481s</td><td align="right"> -0.38%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.5389s</td><td align="right">1.5338s</td><td align="right"> -0.33%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">5.9488s</td><td align="right">5.9258s</td><td align="right"> -0.39%</td></tr><tr><td>Total</td><td align="right">10.4048s</td><td align="right">10.3647s</td><td align="right"> -0.38%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9962s</td><td align="right"> -0.38%</td></tr></table>

r? `@cjgillot`
2023-03-25 12:04:46 +00:00
Camille GILLOT
5e49f099a9 Use an IndexVec to debug fingerprints. 2023-03-25 09:22:40 +00:00
Scott McMurray
49798605a0 Refactor: Separate LocalRef variant for not-evaluated-yet operands 2023-03-24 20:36:59 -07:00
Matthias Krüger
31df7f1ecd
Rollup merge of #109568 - RalfJung:miri-raw-ptr-dyn, r=oli-obk
miri: fix raw pointer dyn receivers

r? `@oli-obk`
Fixes https://github.com/rust-lang/miri/issues/2786
2023-03-25 03:37:12 +01:00
Matthias Krüger
3b49ad3814
Rollup merge of #109545 - compiler-errors:rpitit-wf, r=eholk
Deeply check well-formedness of return-position `impl Trait` in trait

Walk the bounds of RPITITs to see if we find any more RPITITs 😸
2023-03-25 03:37:12 +01:00
Matthias Krüger
15ea2276ff
Rollup merge of #109539 - cjgillot:find-stability, r=b-naber
Refactor `find_*_stability` functions

The idea is to split the monolithic function into the 3 cases: stability, const stability, and body stability.
2023-03-25 03:37:11 +01:00
Matthias Krüger
f3d3f350cc
Rollup merge of #109355 - chenyukang:yukang/fix-108470, r=compiler-errors
Fix bad suggestion for clone/is_some in field init shorthand

Fixes #108470
2023-03-25 03:37:10 +01:00
John Kåre Alsaker
820e3a8d6a Pass tcx directly 2023-03-25 03:13:05 +01:00
John Kåre Alsaker
afe4c16b29 Split the if to release the lock earlier 2023-03-25 03:12:41 +01:00
John Kåre Alsaker
dfae9c993d Remove DebugArg 2023-03-25 02:59:54 +01:00
John Kåre Alsaker
8f294066b3 Optimize incremental_verify_ich 2023-03-25 02:59:53 +01:00
Michael Goulet
53ec4bc631 Remove some stale FIXMEs in new solver 2023-03-25 01:51:19 +00:00