Commit Graph

243582 Commits

Author SHA1 Message Date
bors 25b706cde3 Auto merge of #119111 - michaelwoerister:measureme-11, r=Mark-Simulacrum
Update measureme crate to version 11

perf.rlo has been updated to use 11.0.0 already, so it should be able to handle the new file format.

r? `@Mark-Simulacrum`

Fixes https://github.com/rust-lang/rust/issues/99282
Fixes https://github.com/rust-lang/rust/issues/119103
2024-01-17 09:32:03 +00:00
bors 16f4b02dd8 Auto merge of #119922 - nnethercote:fix-Diag-code-is_lint, r=oli-obk
Rework how diagnostic lints are stored.

`Diagnostic::code` has the type `DiagnosticId`, which has `Error` and
`Lint` variants. Plus `Diagnostic::is_lint` is a bool, which should be
redundant w.r.t. `Diagnostic::code`.

Seems simple. Except it's possible for a lint to have an error code, in
which case its `code` field is recorded as `Error`, and `is_lint` is
required to indicate that it's a lint. This is what happens with
`derive(LintDiagnostic)` lints. Which means those lints don't have a
lint name or a `has_future_breakage` field because those are stored in
the `DiagnosticId::Lint`.

It's all a bit messy and confused and seems unintentional.

This commit:
- removes `DiagnosticId`;
- changes `Diagnostic::code` to `Option<String>`, which means both
  errors and lints can straightforwardly have an error code;
- changes `Diagnostic::is_lint` to `Option<IsLint>`, where `IsLint` is a
  new type containing a lint name and a `has_future_breakage` bool, so
  all lints can have those, error code or not.

r? `@oli-obk`
2024-01-17 07:33:52 +00:00
bors f45fe573a5 Auto merge of #119651 - novafacing:proc_macro_c_str_literals, r=Amanieu
proc_macro: Add Literal::c_string constructor

Adds a constructor for C string literals, hopefully starts addressing #118560.

Tracking issue: #119750
2024-01-17 05:07:38 +00:00
bors 6bf600bc98 Auto merge of #120019 - lcnr:fn-wf, r=BoxyUwU
fix fn/const items implied bounds and wf check (rebase)

A rebase of #104098, see that PR for discussion. This is pretty much entirely the work of `@aliemjay.` I received his permission for this rebase.

---

These are two distinct changes (edit: actually three, see below):
1. Wf-check all fn item args. This is a soundness fix.
Fixes #104005

2. Use implied bounds from impl header in borrowck of associated functions/consts. This strictly accepts more code and helps to mitigate the impact of other breaking changes.
Fixes #98852
Fixes #102611

The first is a breaking change and will likely have a big impact without the the second one. See the first commit for how it breaks libstd.

Landing the second one without the first will allow more incorrect code to pass. For example an exploit of #104005 would be as simple as:
```rust
use core::fmt::Display;

trait ExtendLt<Witness> {
    fn extend(self) -> Box<dyn Display>;
}

impl<T: Display> ExtendLt<&'static T> for T {
    fn extend(self) -> Box<dyn Display> {
        Box::new(self)
    }
}

fn main() {
    let val = (&String::new()).extend();
    println!("{val}");
}
```

The third change is to to check WF of user type annotations before normalizing them (fixes #104764, fixes #104763). It is mutually dependent on the second change above: an attempt to land it separately in #104746 caused several crater regressions that can all be mitigated by using the implied from the impl header. It is also necessary for the soundness of associated consts that use the implied bounds of impl header. See #104763 and how the third commit fixes the soundness issue in `tests/ui/wf/wf-associated-const.rs` that was introduces by the previous commit.

r? types
2024-01-17 02:35:06 +00:00
bors 6ed31aba1a Auto merge of #120036 - weihanglo:update-cargo, r=weihanglo
Update cargo

10 commits in 84976cd699f4aea56cb3a90ce3eedeed9e20d5a5..1cff2ee6b92e0ad3f87c44b70b28f788b2528b3c
2024-01-12 15:55:43 +0000 to 2024-01-16 16:56:57 +0000
- doc: add a heading to highlight "How to find features enabled on dependencies" (rust-lang/cargo#13305)
- fix(cargo-update): `--precise` accept arbitrary git revisions (rust-lang/cargo#13250)
- Strip debuginfo when debuginfo is not requested (rust-lang/cargo#13257)
- Update ahash dependency to 0.8.7 (rust-lang/cargo#13301)
- docs: add more links to pkgid spec chapter (rust-lang/cargo#13298)
- fix(metadata): Stabilize id format as PackageIDSpec (rust-lang/cargo#12914)
- Introduce `-Zprecise-pre-release` unstable flag (rust-lang/cargo#13296)
- Delete sentence about parentheses being unsupported in license (rust-lang/cargo#13292)
- Add guidance on setting homepage in manifest (rust-lang/cargo#13293)
- Clarify the function of the test options (rust-lang/cargo#13236)

r? ghost
2024-01-17 00:03:51 +00:00
Weihang Lo 7e1e61a447
Update cargo 2024-01-16 18:34:44 -05:00
bors 098d4fd74c Auto merge of #119977 - Mark-Simulacrum:defid-cache, r=cjgillot
Cache local DefId-keyed queries without hashing

This caches local DefId-keyed queries using just an IndexVec. This costs ~5% extra max-rss at most but brings significant runtime improvement, up to 13% cycle counts (mean: 4%) on primary benchmarks. It's possible that further tweaks could reduce the memory overhead further but this win seems worth landing despite the increased memory, particularly with regards to eliminating the present set in non-incr or storing it inline (skip list?) with the main data.

We tried applying this scheme to all keys in the [first perf run] but found that it carried a significant memory hit (50%). instructions/cycle counts were also much more mixed, though that may have been due to the lack of the present set optimization (needed for fast iter() calls in incremental scenarios).

Closes https://github.com/rust-lang/rust/issues/45275

[first perf run]: https://perf.rust-lang.org/compare.html?start=30dfb9e046aeb878db04332c74de76e52fb7db10&end=6235575300d8e6e2cc6f449cb9048722ef43f9c7&stat=instructions:u
2024-01-16 21:58:10 +00:00
novafacing ee007ab187 proc_macro_c_str_literals: Implement Literal::c_string constructor 2024-01-16 13:27:58 -08:00
bors 92f2e0aa62 Auto merge of #116520 - Enselic:large-copy-into-fn, r=oli-obk
large_assignments: Lint on specific large args passed to functions

Requires lowering function call arg spans down to MIR, which is done in the second commit.

Part of #83518

Also see
* https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/arg.20Spans.20for.20TerminatorKind.3A.3ACall.3F
* https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/move_size_limit.20lint

r? `@oli-obk` (E-mentor)
2024-01-16 19:33:14 +00:00
bors e64f8495e7 Auto merge of #120025 - matthiaskrgr:rollup-e9ai06k, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #118361 (stabilise bound_map)
 - #119816 (Define hidden types in confirmation)
 - #119900 (Inline `check_closure`, simplify `deduce_sig_from_projection`)
 - #119969 (Simplify `closure_env_ty` and `closure_env_param`)
 - #119990 (Add private `NonZero<T>` type alias.)
 - #119998 (Update books)
 - #120002 (Lint `overlapping_ranges_endpoints` directly instead of collecting into a Vec)
 - #120018 (Don't allow `.html` files in `tests/mir-opt/`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-16 17:33:12 +00:00
Matthias Krüger 91544102aa
Rollup merge of #120018 - Zalathar:mir-opt-html, r=Nilstrieb
Don't allow `.html` files in `tests/mir-opt/`

HTML files were needed for testing `-Z dump-mir-spanview`, but that flag has been removed by #119566.
2024-01-16 17:55:25 +01:00
Matthias Krüger 1f0daa5738
Rollup merge of #120002 - Nadrieril:dont-collect, r=compiler-errors
Lint `overlapping_ranges_endpoints` directly instead of collecting into a Vec

In https://github.com/rust-lang/rust/pull/119396 I was a bit silly: I was trying to avoid any lints being fired from within the exhaustiveness algorithm for some vague aesthetic/reusability reason that doesn't really hold. This PR fixes that: instead of passing a `&mut Vec` around I just added a method to the `TypeCx` trait.

r? `@compiler-errors`
2024-01-16 17:55:25 +01:00
Matthias Krüger bcea676e13
Rollup merge of #119998 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/nomicon

1 commits in f6bd083c4ccfc4ce6699b8b4154e3c45c5a27a8c..6bc2415218d4dd0cb01433d8320f5ccf79c343a1
2024-01-03 04:01:04 UTC to 2024-01-03 04:01:04 UTC

- Update an example of `thread_local` to use `local_key_cell_methods` (rust-lang/nomicon#438)

## rust-lang/reference

1 commits in 3565c7978cfc9662f5963b135690ff9cbbfa0318..8c77e8be9da1a9c70545556218d563c8d061f1fd
2024-01-08 15:16:51 UTC to 2024-01-08 15:16:51 UTC

- Document that <- is a single token (rust-lang/reference#1424)

## rust-lang/rust-by-example

4 commits in c0be6299e52e4164c30ba6f41bd0ad0aaee64972..ddf5cb0e6ee54ba2dd84c8ca3e1314120014e20d
2024-01-13 11:06:22 UTC to 2024-01-13 11:01:00 UTC

- Update attribute.md, (rust-lang/rust-by-example#1791)
- fix: typo `unusude` (rust-lang/rust-by-example#1797)
- Update print.md (rust-lang/rust-by-example#1796)
- Update alias.md (rust-lang/rust-by-example#1790)

## rust-lang/rustc-dev-guide

4 commits in d13e85152a977cd0bcaf583cf5f49e86225697de..4af29d1a7f64f88a36539662c6a84fe1fbe6cde1
2024-01-14 10:42:53 UTC to 2024-01-06 17:47:01 UTC

- Expand upon PR guidelines (rust-lang/rustc-dev-guide#1851)
- Correct the link to rust reference (rust-lang/rustc-dev-guide#1848)
- Explain the important concepts of exhaustiveness checking (rust-lang/rustc-dev-guide#1830)
- Add guide for rustdoc search implementation (rust-lang/rustc-dev-guide#1846)
2024-01-16 17:55:24 +01:00
Matthias Krüger ac3108f208
Rollup merge of #119990 - reitermarkus:nonzero-type-alias, r=dtolnay
Add private `NonZero<T>` type alias.

According to step 2 suggested in https://github.com/rust-lang/rust/pull/100428#pullrequestreview-1767139731.

This adds a private type alias for `NonZero<T>` so that some parts of the code can already start using `NonZero<T>` syntax.

Using `NonZero<T>` for `convert` and other parts which implement `From` doesn't work while it is a type alias, since this results in conflicting implementations.
2024-01-16 17:55:24 +01:00
Matthias Krüger 4735171667
Rollup merge of #119969 - compiler-errors:simplify-closure-env-ty, r=oli-obk
Simplify `closure_env_ty` and `closure_env_param`

Random cleanup that I found when working on async closures. This makes it easier to separate the latter into a new tykind.
2024-01-16 17:55:23 +01:00
Matthias Krüger 5f9d1d4e09
Rollup merge of #119900 - compiler-errors:closure-checking, r=oli-obk
Inline `check_closure`, simplify `deduce_sig_from_projection`

Some minor cleanups that I've collected when reimplementing async closure

r? oli-obk
2024-01-16 17:55:22 +01:00
Matthias Krüger d4b276caa4
Rollup merge of #119816 - oli-obk:tait_ice_unify_obligations, r=lcnr
Define hidden types in confirmation

fixes  #111470

r? `@lcnr` or `@compiler-errors`

explanation in the newly added test
2024-01-16 17:55:22 +01:00
Matthias Krüger 304a17a475
Rollup merge of #118361 - Dylan-DPC:80626/stab/bound-map, r=Amanieu
stabilise bound_map

Closes https://github.com/rust-lang/rust/issues/86026
2024-01-16 17:55:21 +01:00
bors bf2637f4e8 Auto merge of #119954 - scottmcm:option-unwrap-failed, r=WaffleLapkin
Split out `option::unwrap_failed` like we have `result::unwrap_failed`

...and like `option::expect_failed`
2024-01-16 15:32:39 +00:00
bors 533cfde67c Auto merge of #119947 - compiler-errors:old-solver-instantiate-response, r=lcnr
Make sure to instantiate placeholders correctly in old solver

When creating the query substitution guess for an input placeholder type like `!1_T` (in universe 1), we were guessing the response substitution with something like `!0_T`. This failed to unify with `!1_T`, causing an ICE.

This PR reworks the query substitution guess code to work a bit more like the new solver. I'm *pretty* sure this is correct, though I'd really appreciate some scrutiny from someone (*cough* lcnr) who knows a bit more about query instantiation :)

Fixes #119941

r? lcnr
2024-01-16 13:33:04 +00:00
bors fa0dc208d0 Auto merge of #119672 - cjgillot:dse-sandwich, r=oli-obk
Sandwich MIR optimizations between DSE.

This PR reorders MIR optimization passes in an attempt to increase their efficiency.

- Stop running CopyProp before GVN, it's useless as GVN will do the same thing anyway. Instead, we perform CopyProp at the end of the pipeline, to ensure we do not emit copy/move chains.
- Run DSE before GVN, as it increases the probability to have single-assignment locals.
- Run DSE after the final CopyProp to turn copies into moves.

r? `@ghost`
2024-01-16 11:34:16 +00:00
Ali MJ Al-Nasrawy 66090ef7ba try fast path for wf type ops 2024-01-16 09:25:28 +01:00
Ali MJ Al-Nasrawy aac2f84794 wf-check type annotations before normalization 2024-01-16 09:25:28 +01:00
Ali MJ Al-Nasrawy 8d4693c0f8 borrowck: use implied bounds from impl header 2024-01-16 09:25:28 +01:00
Ali MJ Al-Nasrawy a3fe3bbb2c borrowck: wf-check fn item args 2024-01-16 09:25:28 +01:00
Zalathar 40166c894a Don't allow `.html` files in `tests/mir-opt/`
HTML files were needed for testing `-Z dump-mir-spanview`, but that flag has
been removed by #119566.
2024-01-16 17:48:31 +11:00
bors f9c2421a2a Auto merge of #119439 - cjgillot:gvn-faster, r=oli-obk
Avoid some redundant work in GVN

The first 2 commits are about reducing the perf effect.

Third commit avoids doing redundant work: is a local is SSA, it already has been simplified, and the resulting value is in `self.locals`. No need to call any code on it.

The last commit avoids removing some storage statements.

r? wg-mir-opt
2024-01-16 05:17:49 +00:00
Mark Rousskov 37849643c6 Cache local DefId-keyed queries without hashing
Foreign maps are used to cache external DefIds, typically backed by
metadata decoding. In the future we might skip caching `V` there (since
loading from metadata usually is already cheap enough), but for now this
cuts down on the impact to memory usage and time to None-init a bunch of
memory. Foreign data is usually much sparser, since we're not usually
loading *all* entries from the foreign crate(s).
2024-01-15 17:16:45 -05:00
bors 714b29a17f Auto merge of #119610 - Nadrieril:never_pattern_bindings, r=compiler-errors
never patterns: Check bindings wrt never patterns

Never patterns:
- Shouldn't contain bindings since they never match anything;
- Don't count when checking that or-patterns have consistent bindings.

r? `@compiler-errors`
2024-01-15 21:24:13 +00:00
David Tolnay 604d2083d3
Revert unrelated changes from PR 119990 2024-01-15 13:09:46 -08:00
bors bfcc027a75 Auto merge of #119988 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? ghost
2024-01-15 18:43:19 +00:00
Nadrieril 448c4a4efb Remove the unused `overlapping_range_endpoints` Vec 2024-01-15 19:27:06 +01:00
Nadrieril 8b66f497eb Lint overlapping ranges directly from exhaustiveness 2024-01-15 19:27:06 +01:00
Martin Nordholts 8f440f06c6 large_assignments: Lint on specific large args passed to functions 2024-01-15 19:07:12 +01:00
Martin Nordholts 16ba56c242 compiler: Lower fn call arg spans down to MIR
To enable improved accuracy of diagnostics in upcoming commits.
2024-01-15 19:07:11 +01:00
Martin Nordholts 924ea05103 Implement TypeVisitable and TypeFoldable for Spanned
The traits are already implemented for Span, so it makes sense to also
have them for Spanned (upcoming commits will make use of this).
2024-01-15 19:07:11 +01:00
rustbot 0a049cb71e Update books 2024-01-15 12:00:28 -05:00
bors 67e7b84425 Auto merge of #119987 - matthiaskrgr:rollup-f7lkx4w, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #119818 (Silence some follow-up errors [3/x])
 - #119870 (std: Doc blocking behavior of LazyLock)
 - #119897 (`OutputTypeParameterMismatch` -> `SignatureMismatch`)
 - #119963 (Fix `allow_internal_unstable` for `(min_)specialization`)
 - #119971 (Use `zip_eq` to enforce that things being zipped have equal sizes)
 - #119974 (Minor `trimmed_def_paths` improvements)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-15 16:45:41 +00:00
Markus Reiter f7602232a5
Add private `NonZero<T>` type alias. 2024-01-15 13:44:52 +01:00
Laurențiu Nicola 32bd51eebf Merge commit '9d8889cdfcc3aa0302353fc988ed21ff9bc9925c' into sync-from-ra 2024-01-15 11:40:09 +02:00
bors 1ead4761e9 Auto merge of #119878 - scottmcm:inline-always-unwrap, r=workingjubilee
Tune the inlinability of `unwrap`

Fixes #115463
cc `@thomcc`

This tweaks `unwrap` on ~~`Option` &~~ `Result` to be two parts:
- `#[inline(always)]` for checking the discriminant
- `#[cold]` for actually panicking

The idea here is that checking the discriminant on a `Result` ~~or `Option`~~ should always be trivial enough to be worth inlining, even in `opt-level=z`, especially compared to passing it to a function.

As seen in the issue and codegen test, this will hopefully help particularly for things like `.try_into().unwrap()`s that are actually infallible, but in a way that's only visible with the inlining.

EDIT: I've restricted this to `Result` to avoid combining effects
2024-01-15 09:20:46 +00:00
Matthias Krüger 82f38ab62e
Rollup merge of #119974 - nnethercote:trimmed_def_paths-improvements, r=compiler-errors
Minor `trimmed_def_paths` improvements

r? `@compiler-errors`
2024-01-15 08:44:50 +01:00
Matthias Krüger b6f68a7fca
Rollup merge of #119971 - compiler-errors:zip-eq, r=nnethercote
Use `zip_eq` to enforce that things being zipped have equal sizes

Some `zip`s are best enforced to be equal, since size mismatches suggest deeper bugs in the compiler.
2024-01-15 08:44:49 +01:00
Matthias Krüger 0891cb4d81
Rollup merge of #119963 - clubby789:spec-allow-internal-unstable, r=compiler-errors
Fix `allow_internal_unstable` for `(min_)specialization`

Fixes #119950

Blocked on #119949 (comment doesn't make sense until that merges)

I'd like to follow this up and look for more instances of not properly checking spans for features but I wanted to fix the motivating issue.
2024-01-15 08:44:49 +01:00
Matthias Krüger 1e46be6a53
Rollup merge of #119897 - compiler-errors:fulfillment-errors, r=lcnr
`OutputTypeParameterMismatch` -> `SignatureMismatch`

I'm probably missing something that made this rename more complicated. What did you end up getting stuck on when renaming this selection error, `@lcnr?`

**also** I renamed the `FulfillmentErrorCode` variants. This is just churn but I wanted to do it forever. I can move it out of this PR if desired.

r? lcnr
2024-01-15 08:44:48 +01:00
Matthias Krüger 6f2670da7b
Rollup merge of #119870 - behnam-oneschema:lazylock-blocking-1, r=tgross35,ChrisDenton
std: Doc blocking behavior of LazyLock

Adding notes about blocking behavior of calls that can block the current thread, similar to those on https://doc.rust-lang.org/std/sync/struct.OnceLock.html

I'm not sure if the "This method never blocks." counterparts would be desired. If so, can add those, as well.
2024-01-15 08:44:48 +01:00
Matthias Krüger 73256c68b8
Rollup merge of #119818 - oli-obk:even_more_follow_up_errors3, r=compiler-errors
Silence some follow-up errors [3/x]

this is one piece of the requested cleanups from https://github.com/rust-lang/rust/pull/117449

Keep error types around, even in obligations.

These help silence follow-up errors, as we now figure out that some types (most notably inference variables) are equal to an error type.

But it also allows figuring out more types in the presence of errors, possibly causing more errors.
2024-01-15 08:44:46 +01:00
bors 73252d51d1 Auto merge of #119508 - Zalathar:graph, r=compiler-errors
coverage: Simplify building the coverage graph with `CoverageSuccessors`

This is a collection of simplifications to the code that builds the *basic coverage block* graph, which is a simplified view of the MIR control-flow graph that ignores panics and merges straight-line sequences of blocks into a single BCB node.

The biggest change is to how we determine the coverage-relevant successors of a block. Previously we would call `Terminator::successors` and apply some ad-hoc postprocessing, but with this PR we instead have our own `match` on the terminator kind that produces a coverage-specific enum `CoverageSuccessors`. That enum also includes information about whether a block has exactly one successor that it can be chained into as part of a single BCB.
2024-01-15 06:45:33 +00:00
bors 9567c3ee73 Auto merge of #119581 - Nadrieril:detangle-arena, r=compiler-errors
Exhaustiveness: remove the need for arena-allocation within the algorithm

After https://github.com/rust-lang/rust/pull/119688, exhaustiveness checking doesn't need access to the arena anymore. This simplifies the lifetime story and makes it compile on stable without the extra dependency.

r? `@compiler-errors`
2024-01-15 00:04:09 +00:00
Nicholas Nethercote 32de78cade Replace `TrimmedDefPaths` with a bool.
It's a tri-state enum but the `Always` variant is never used, so a bool
is simpler.
2024-01-15 09:16:14 +11:00