Commit Graph

24988 Commits

Author SHA1 Message Date
Matthias Krüger
092352f6fd
Rollup merge of #111841 - matthewjasper:validate-match-guards, r=compiler-errors
Run AST validation on match guards correctly

AST validation was being skipped on match guards other than `if let` guards.
2023-05-24 21:36:57 +02:00
Matthias Krüger
52890cc719
Rollup merge of #111759 - cjgillot:interval-kill, r=b-naber
Leverage the interval property to precompute borrow kill points.
2023-05-24 21:36:56 +02:00
Matthias Krüger
09489b9137
Rollup merge of #111121 - Zalathar:ra-false-positive, r=jackh726
Work around `rust-analyzer` false-positive type errors

rust-analyzer incorrectly reports two type errors in `debug.rs`:

> expected &dyn Display, found &i32
> expected &dyn Display, found &i32

This is due to a known bug in r-a: (https://github.com/rust-lang/rust-analyzer/issues/11847).

In these particular cases, changing `&0` to `&0i32` seems to be enough to avoid the bug.
2023-05-24 21:36:56 +02:00
Camille GILLOT
9a7ed3625f Emit diagnostic for privately uninhabited uncovered witnesses. 2023-05-24 19:16:07 +00:00
bors
c373194cb6 Auto merge of #111260 - petrochenkov:effvisperf7, r=cjgillot
rustc_privacy: Cleanups and perf improvements to `EmbargoVisitor`

Continuation of https://github.com/rust-lang/rust/pull/110907.
2023-05-24 19:02:19 +00:00
Michael Goulet
d7ccbdd696 Split out opaque from type_of 2023-05-24 17:23:58 +00:00
Michael Goulet
b1387e776c Don't skip mir typeck if body has errors 2023-05-24 17:12:46 +00:00
bors
97d328012b Auto merge of #111673 - cjgillot:dominator-preprocess, r=cjgillot,tmiasko
Preprocess and cache dominator tree

Preprocessing dominators has a very strong effect for https://github.com/rust-lang/rust/pull/111344.
That pass checks that assignments dominate their uses repeatedly. Using the unprocessed dominator tree caused a quadratic runtime (number of bbs x depth of the dominator tree).

This PR also caches the dominator tree and the pre-processed dominators in the MIR cfg cache.

Rebase of https://github.com/rust-lang/rust/pull/107157
cc `@tmiasko`
2023-05-24 16:18:21 +00:00
Michael Goulet
521a0bcd1f Use ObligationCtxt in custom type ops 2023-05-24 16:06:32 +00:00
Maybe Waffle
307799a711 Use is_some_and/is_ok_and in less obvious spots 2023-05-24 14:33:43 +00:00
Maybe Waffle
fb0f74a8c9 Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00
bors
b3cbf7c835 Auto merge of #111694 - Amanieu:no-assume-bdynamic, r=petrochenkov
Don't assume that `-Bdynamic` is the default linker mode

In particular this is false when passing `-static` or `-static-pie` to the linker, which changes the default to `-Bstatic`. This PR ensures we explicitly initialize the correct mode when we first need it.
2023-05-24 13:35:30 +00:00
bors
d69787f098 Auto merge of #111195 - GuillaumeGomez:fix-ice-intra-doc-link, r=petrochenkov
Prevent crash when a path is not resolved in intra-doc link

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

cc `@petrochenkov`
r? `@notriddle`
2023-05-24 07:49:53 +00:00
Matthias Krüger
8227c4fd6e
Rollup merge of #111880 - compiler-errors:pointer-like-param-env, r=jackh726
Don't ICE when computing PointerLike trait when region vars are in param-env

Fixes #111877
2023-05-24 06:05:39 +02:00
Matthias Krüger
783bea940b
Rollup merge of #111870 - WaffleLapkin:just_🌟traits🌟_query, r=compiler-errors
Rename `traits_in_crate` query to `traits`

> NOTE: Not named just `traits` due to a naming conflict.

This can, in fact, be easily avoided.
2023-05-24 06:05:38 +02:00
Matthias Krüger
efea88ae08
Rollup merge of #111864 - Jules-Bertholet:sized-closures, r=compiler-errors
Always require closure parameters to be `Sized`

The `rust-call` ABI isn't compatible with `#![feature(unsized_fn_params)]`, so trying to use that feature with closures leads to an ICE (#67981). This turns that ICE into a type-check error.

`@rustbot` label A-closures F-unsized_fn_params
2023-05-24 06:05:38 +02:00
Matthias Krüger
224b6511b1
Rollup merge of #111861 - compiler-errors:rtn-in-super, r=jackh726
Don't ICE on return-type notation when promoting trait preds to associated type bounds

Fixes #111846
2023-05-24 06:05:37 +02:00
Nicholas Nethercote
59c5259bc9 Add a clarifying comment.
This is something that took me some time to figure out.
2023-05-24 12:33:35 +10:00
Nicholas Nethercote
20de2ba759 Remove {Pre,Post}InliningPartitioning.
I find that these structs obfuscate the code. Removing them and just
passing the individual fields around makes the `Partition` method
signatures a little longer, but makes the data flow much clearer. E.g.

- `codegen_units` is mutable all the way through.
- `codegen_units`'s length is changed by `merge_codegen_units`, but only
  the individual elements are changed by `place_inlined_mono_items` and
  `internalize_symbols`.
- `roots`, `internalization_candidates`, and `mono_item_placements` are
  all immutable after creation, and all used by just one of the four
  methods.
2023-05-24 12:33:35 +10:00
Nicholas Nethercote
b39b7098ea Remove the merging module.
Three of the four methods in `DefaultPartitioning` are defined in
`default.rs`. But `merge_codegen_units` is defined in a separate module,
`merging`, even though it's less than 100 lines of code and roughly the
same size as the other three methods. (Also, the `merging` module
currently sits alongside `default`, when it should be a submodule of
`default`, adding to the confusion.)

In #74275 this explanation was given:

> I pulled this out into a separate module since it seemed like we might
> want a few different merge algorithms to choose from.

But in the three years since there have been no additional merging
algorithms, and there is no mechanism for choosing between different
merging algorithms. (There is a mechanism,
`-Zcgu-partitioning-strategy`, for choosing between different
partitioning strategies, but the merging algorithm is just one piece of
a partitioning strategy.)

This commit merges `merging` into `default`, making the code easier to
navigate and read.
2023-05-24 12:25:58 +10:00
Nicholas Nethercote
e26c0c92bd Inline and remove numbered_codegen_unit_name.
It is small and has a single call site, and this change will facilitate
the next commit.
2023-05-24 10:05:15 +10:00
Maybe Waffle
cc1ec49a14 Rename traits_in_crate query to traits 2023-05-23 21:26:37 +00:00
bors
d5699874dc Auto merge of #111882 - matthiaskrgr:rollup-1xyv5mq, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #111427 ([rustdoc][JSON] Use exclusively externally tagged enums in the JSON representation)
 - #111486 (Pretty-print inherent projections correctly)
 - #111722 (Document stack-protector option)
 - #111761 (fix(resolve): not defined `extern crate shadow_name`)
 - #111845 (Update books)
 - #111851 (CFI: Fix encode_region: unexpected ReEarlyBound(0, 'a))
 - #111871 (Migrate GUI colors test to original CSS color format)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-23 18:13:36 +00:00
Matthias Krüger
20b6e5a1d8
Rollup merge of #111851 - rcvalle:rust-cfi-fix-111515, r=bjorn3
CFI: Fix encode_region: unexpected ReEarlyBound(0, 'a)

Fixes #111515 and complements #106547 by adding support for encoding early bound regions and also excluding projections when transforming trait objects' traits into their identities before emitting type checks.
2023-05-23 19:53:43 +02:00
Matthias Krüger
37c9478b1a
Rollup merge of #111761 - bvanjoi:fix-109148, r=petrochenkov
fix(resolve): not defined `extern crate shadow_name`

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

## Why does #109148 panic?

When resolving `use std::xx` it enters `visit_scopes` from `early_resolve_ident_in_lexical_scope`, and iters twice during the loop:

|iter| `scope` | `break_result` | result |
|-|-|-|-|
| 0 | `Module` pointed to root | binding pointed to `Undetermined`, so result is `None` | scope changed to `ExternPrelude` |
| 1 | `ExternPrelude` | binding pointed to `std` | - |

Then, the result of `maybe_resolve_path` is `Module(std)`, so `import.imported_module.set` is executed.

Finally, during the `finalize_import` of `use std::xx`, `resolve_path` returns `NonModule` because `Binding(Ident(std), Module(root)`'s binding points to `extern crate blah as std`, which causes the assertion to fail at `assert!(import.imported_module.get().is_none());`.

## Investigation

The question is why `#[a] extern crate blah as std` is not defined as a binding of `std::xxx`, which causes the iteration twice during `visit_scopes` when resolving `std::xxx`. Ideally, the value of `break_result.is_some()` should have been valid in the first iteration.

After debugging, I found that because `#[a] extern crate blah as std` had been dummied by `placeholder` during `collect_invocations`, so it had lost its attrs, span, etc..., so it will not be defined. However, `expand_invoc` added them back, then the next `build_reduced_graph`, `#[a] extern crate blah as std` would have been defined, so it makes the result of `resolved_path` unexpected, and the program panics.

## Try to solve

I think there has two-way to solve this issue:

- Expand invocations before the first `resolve_imports` during `fully_expand_fragment`. However, I do not think this is a good idea because it would mess up the current design.
- As my PR described: do not define to `extern crate blah as std` during the second `build_reduced_graph`, which is very easy and more reasonable.

r? `@petrochenkov`
2023-05-23 19:53:42 +02:00
Matthias Krüger
221039b416
Rollup merge of #111486 - fmease:pp-inh-proj, r=petrochenkov
Pretty-print inherent projections correctly

Previously, we were trying to pretty-print inherent projections with `Printer::print_def_path` which is incorrect since
it expects the substitutions to be of a certain format (parents substs followed by own substs) which doesn't hold for
inherent projections (self type subst followed by own substs).
Now we print inherent projections manually.

Fixes #111390.
Fixes #111397.

Lacking tests! Is there a test suite / compiletest flags for the pretty-printer? In most if not all cases,
inherent projections are normalized away before they get the chance to appear in diagnostics.

If I were to create regression tests for linked issues, they would need to be `mir-opt` tests to exercise
`-Zdump-mir=all` (right?) which doesn't feel quite adequate to me.

`@rustbot` label F-inherent_associated_types
2023-05-23 19:53:41 +02:00
Michael Goulet
3a2710cdb6 Don't ICE when computing PointerLike trait when region vars are in param-env 2023-05-23 17:23:30 +00:00
Jules Bertholet
5cd02eaece
Always require closure parameters to be Sized
The `rust-call` ABI isn't compatible with
`#![feature(unsized_fn_params)]`, so trying to use that feature with
closures leads to an ICE (#67981). This turns that ICE into a
type-check error.
2023-05-23 12:46:25 -04:00
Ramon de C Valle
9bbdfea23c CFI: Fix encode_region: unexpected ReEarlyBound(0, 'a)
Fixes #111515 and complements #106547 by adding support for encoding
early bound regions and also excluding projections when transforming
trait objects' traits into their identities before emitting type checks.
2023-05-23 16:44:03 +00:00
Dominik Stolz
8dac074087 Add RegionInferenceContext::outlives_constraints 2023-05-23 17:33:55 +02:00
bors
52dd1cde59 Auto merge of #107294 - JamieCunliffe:neon-fp, r=Amanieu
Fix some issues with folded AArch64 features

In #91608 the `fp` feature was removed for AArch64 and folded into the `neon` feature, however disabling the `neon` feature doesn't actually disable the `fp` feature. If my understanding on that thread is correct it should do.

While doing this, I also noticed that disabling some features would disable features that it shouldn't. For instance enabling `sve` will enable `neon`, however, when disabling `sve` it would then also disable `neon`, I wouldn't expect disabling `sve` to also disable `neon`.

cc `@workingjubilee`
2023-05-23 15:30:37 +00:00
Maybe Waffle
e2b953063d Don't leak the function that is called on drop 2023-05-23 14:53:36 +00:00
Guillaume Gomez
234927e098 Ignore "non-real" type Res in rustdoc intra doc link resolution 2023-05-23 15:33:34 +02:00
bors
b08148f6a7 Auto merge of #111869 - Dylan-DPC:rollup-9pydw08, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #111461 (Fix symbol conflict diagnostic mistakenly being shown instead of missing crate diagnostic)
 - #111579 (Also assume wrap-around discriminants in `as` MIR building)
 - #111704 (Remove return type sized check hack from hir typeck)
 - #111853 (Check opaques for mismatch during writeback)
 - #111854 (rustdoc: clean up `settings.css`)
 - #111860 (Don't ICE if method receiver fails to unify with `arbitrary_self_types`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-23 12:47:51 +00:00
Dominik Stolz
c6e3f27864 Move BodyWithBorrowckFacts to consumers 2023-05-23 14:36:36 +02:00
Dylan DPC
c4f2a62182
Rollup merge of #111860 - compiler-errors:issue-111838, r=WaffleLapkin
Don't ICE if method receiver fails to unify with `arbitrary_self_types`

Consider:

```rust
struct Foo(u32);
impl Foo {
    fn get<R: Deref<Target=Self>>(self: R) -> u32 {
        self.0
    }
}

fn main() {
    let mut foo = Foo(1);
    foo.get::<&Foo>();
}
```

The problem here is that with `arbitrary_self_types`, we're allowed to have a method receiver that mentions generics from the method itself (`fn get<R: Deref<Target=Self>>(self: R)`). Since we don't actually take into account the user-written turbofish generics when doing method lookup (nor do we check that method predicates hold), method probing will happily infer `R = Foo` during the probe. When we later confirm the method, we do use the turbofish'd subst and instead now have that `R = &Foo`. This doesn't unify with the self type we chose during the probe, causing an ICE.

Getting this to work correctly will be difficult. Specifically, we'll need to actually pass in the turbofish generics for the method being probed for and check that the self type unifies considering those generics. This seems like a lot of work, and I'm not actually familiar with the restrictions originally called out for `#![feature(arbitrary_self_types)]`, but I think we should probably instead just deny having receivers that mention (type/const) generics that come from the method itself.

But I mostly just want to turn this ICE into an error, so I'll leave that up for later PRs.

Fixes #111838
2023-05-23 16:44:29 +05:30
Dylan DPC
6583025c93
Rollup merge of #111853 - compiler-errors:opaque-check, r=oli-obk
Check opaques for mismatch during writeback

Revive #111705.

I realized that we don't need to put any substs in the writeback results since all of the hidden types have already been remapped. See the comment in `compiler/rustc_middle/src/ty/typeck_results.rs`, which should make that clear for other explorers of the codebase.

Additionally, we need to do some diagnostic stashing because the diagnostics we produce during HIR typeck is very poor and we should prefer the diagnostic that comes from MIR, if we have one.

r? `@oli-obk`
2023-05-23 16:44:28 +05:30
Dylan DPC
4b26b80dd5
Rollup merge of #111704 - compiler-errors:sized-return-cleanup, r=oli-obk
Remove return type sized check hack from hir typeck

Remove a bunch of special-cased suggestions when someone returns `-> dyn Trait` that checks for type equality, etc.

This was a pretty complex piece of code that also relied on a hack in hir typeck (see changes to `compiler/rustc_hir_typeck/src/check.rs`), and I'm not convinced that it's necessary to maintain, when all we really need to tell the user is that they should return `-> impl Trait` or `-> Box<dyn Trait>`, depending on their specific use-case.

This is necessary because we may need to move the "return type is sized" check from hir typeck to wfcheck, which does not have access to typeck results. This is a prerequisite for that, and I'm fairly confident that the diagnostics "regressions" here are not a big deal.
2023-05-23 16:44:27 +05:30
Dylan DPC
00185bec7c
Rollup merge of #111579 - scottmcm:enum-as-signed, r=oli-obk
Also assume wrap-around discriminants in `as` MIR building

Resolves this FIXME:

8d18c32b61/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs (L231)

r? `@oli-obk`
2023-05-23 16:44:27 +05:30
Dylan DPC
731c1a5592
Rollup merge of #111461 - oli-obk:crate_collision, r=petrochenkov
Fix symbol conflict diagnostic mistakenly being shown instead of missing crate diagnostic

This was a refactoring mistake in https://github.com/rust-lang/rust/pull/109213

fixes #111284
2023-05-23 16:44:26 +05:30
Dominik Stolz
ab9e7037d1 Make place helpers accessible 2023-05-23 13:11:23 +02:00
Dominik Stolz
0e44a38892 Return promoteds in BodyWithBorrowckFacts 2023-05-23 13:11:23 +02:00
Jonáš Fiala
388071a2cb Allow consumers to retrieve borrowck output 2023-05-23 13:11:23 +02:00
bors
f3d597b31c Auto merge of #111807 - erikdesjardins:noalias, r=oli-obk
[rustc_ty_utils] Treat `drop_in_place`'s *mut argument like &mut when adding LLVM attributes

This resurrects PR #103614, which has sat idle for a while.

This could probably use a new perf run, since we're on a new LLVM version now.

r? `@oli-obk`
cc `@RalfJung`

---

LLVM can make use of the `noalias` parameter attribute on the parameter to `drop_in_place` in areas like argument promotion. Because the Rust compiler fully controls the code for `drop_in_place`, it can soundly deduce parameter attributes on it.

In #103957, Miri was changed to retag `drop_in_place`'s argument as if it was `&mut`, matching this change.
2023-05-23 10:12:46 +00:00
Oli Scherer
6d1a1cf354 Fix symbol conflict diagnostic mistakenly being shown instead of missing crate diagnostic 2023-05-23 07:37:16 +00:00
bohan
c41b2089c7 fix(resolve): not defined extern crate shadow_name 2023-05-23 13:14:34 +08:00
bors
4400d8fce7 Auto merge of #110204 - compiler-errors:new-solver-hir-typeck-hacks, r=lcnr
Deal with unnormalized projections when structurally resolving types with new solver

1. Normalize types in `structurally_resolved_type` when the new solver is enabled
2. Normalize built-in autoderef targets in `Autoderef` when the new solver is enabled
3. Normalize-erasing-regions in `resolve_type` in writeback

This is motivated by the UI test provided, which currently fails with:

```
error[E0609]: no field `x` on type `<usize as SliceIndex<[Foo]>>::Output`
 --> <source>:9:11
  |
9 |     xs[0].x = 1;
  |           ^
```

 I'm pretty happy with the approach in (1.) and (2.) and think we'll inevitably need something like this in the long-term, but (3.) seems like a hack to me. It's a *lot* of work to add tons of new calls to every user of these typeck results though (mir build, late lints, etc). Happy to discuss further.

r? `@lcnr`
2023-05-23 04:41:44 +00:00
Michael Goulet
e54bc1c5ff Don't ICE on RPITIT when promoting trait preds to associated type bounds 2023-05-23 03:43:09 +00:00
Michael Goulet
05c5caa500 Don't ICE if method receiver fails to unify with arbitrary_self_types 2023-05-23 03:23:52 +00:00
Michael Goulet
0307db4a59 Check opaques for mismatch during writeback 2023-05-22 23:33:34 +00:00
Michael Goulet
4cfafb275e Structurally normalize in the new solver 2023-05-22 21:18:20 +00:00
Michael Goulet
eaf10dcb70 Normalize types in writeback results with new solver 2023-05-22 21:18:20 +00:00
Alex Gaynor
12fd46d691
Enable sanitizers and profiler for aarch64-unknown-linux-musl 2023-05-22 14:13:23 -07:00
León Orell Valerian Liehr
778abc7a00
properly pretty-print inherent projections 2023-05-22 22:39:45 +02:00
bors
8b4b20836b Auto merge of #111848 - Dylan-DPC:rollup-7jqydzg, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #111501 (MIR drive-by cleanups)
 - #111609 (Mark internal functions and traits unsafe to reflect preconditions)
 - #111612 (Give better error when collecting into `&[T]`)
 - #111756 (Rename `{drop,forget}_{copy,ref}` lints to more consistent naming)
 - #111843 (move lcnr to only review types stuff)
 - #111844 (Migrate GUI colors test to original CSS color format)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-22 20:33:51 +00:00
Dylan DPC
71f78682be
Rollup merge of #111756 - Urgau:rename_drop_forget_copy_ref_lints, r=fee1-dead
Rename `{drop,forget}_{copy,ref}` lints to more consistent naming

This PR renames previous uplifted lints in https://github.com/rust-lang/rust/pull/109732 to more consistent naming.

I followed the renaming done [here](https://github.com/rust-lang/rust/issues/53224) and also advocated in this [clippy issue](https://github.com/rust-lang/rust-clippy/issues/2845):
   - `drop_copy` to `dropping_copy_types`
   - `forget_copy` to `forgetting_copy_types`
   - `drop_ref` to `dropping_references`
   - `forget_ref` to `forgetting_references`
2023-05-23 00:32:19 +05:30
Dylan DPC
df8b0dfc27
Rollup merge of #111612 - ChayimFriedman2:collect-into-slice-ref, r=petrochenkov
Give better error when collecting into `&[T]`

The detection of slice reference of `{integral}` in `rustc_on_unimplemented` is hacky, but a proper solution requires changing `FmtPrinter` to add a parameter to print integers as `{integral}` and I didn't want to change it just for `rustc_on_unimplemented`. I can do that if requested, though.

I'm open to better wording; this is the best I could come up with.
2023-05-23 00:32:18 +05:30
Dylan DPC
df86200965
Rollup merge of #111501 - WaffleLapkin:drivebycleanupuwu, r=oli-obk
MIR drive-by cleanups

Some random drive-by cleanups I did while working with MIR/THIR.
2023-05-23 00:32:17 +05:30
bors
cfcde247cd Auto merge of #111754 - lcnr:recursion-depth, r=matthewjasper
fix recursion depth handling after confirmation

fixes #111729

I think having to use `Obligation::with_depth` correctly everywhere is very hard because e.g. the nested obligations from `eq` currently do not have the correct obligation depth.

The new solver [completely removes `recursion_depth` from obligations](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/traits/solve/struct.Goal.html) and instead tracks the depth in the solver itself which is far easier to get right. Moving the old solver towards this shouldn't be that hard but is probably somewhat annoying.

r? `@matthewjasper`
2023-05-22 17:56:26 +00:00
Vadim Petrochenkov
edf95b5d8c rustc_privacy: Reach underlying types of impl Traits in a separate pass
outside of fixed point iteration.
2023-05-22 19:59:38 +03:00
Vadim Petrochenkov
e41c422dff rustc_privacy: Merge three matches on ItemKind into one
and remove some more `Option`s as a result
2023-05-22 19:59:35 +03:00
Vadim Petrochenkov
d831141638 rustc_privacy: Remove some Options
in cases where they are guaranteed to be `Some`
2023-05-22 19:58:28 +03:00
Vadim Petrochenkov
e3b830d4da rustc_privacy: Migrate EmbargoVisitor to visit_all_item_likes_in_crate
Previously it had some logic requiring tree visiting, but it was moved to resolve last year.
2023-05-22 19:58:28 +03:00
Matthew Jasper
72d41f3bd3 Run AST validation on match guards correctly 2023-05-22 14:52:52 +01:00
Jamie Cunliffe
a059e68d11 Create a structure to define the features from to_llvm_features.
Rather than returning an array of features from to_llvm_features, return a structure that contains
the dependencies. This also contains metadata on how the features depend on each other to allow for
the correct enabling and disabling.
2023-05-22 14:46:40 +01:00
Jamie Cunliffe
aab0757c66 Only disable folded features when it makes sense.
Some features that are tied together only make sense to be folded
together when enabling the feature. For example on AArch64 sve and
neon are tied together, however it doesn't make sense to disable neon
when disabling sve.
2023-05-22 14:27:14 +01:00
Jamie Cunliffe
4cca436e30 Tie neon with fp-armv8.
In #91608 the fp-armv8 feature was removed as it's tied to the neon
feature. However disabling neon didn't actually disable the use of
floating point registers and instructions, for this `-fp-armv8` is
required.
2023-05-22 14:27:14 +01:00
bors
03761a50a3 Auto merge of #111775 - compiler-errors:triple-check, r=Nilstrieb
Add extra debug assertions for equality for Adt/Variant/FieldDef

Would've made it easier to both catch and test https://github.com/rust-lang/rust/pull/111494. Maybe not worth it, since it does mean that the compiler is doing extra work when debug-assertions are enabled, but also that's what debug assertions are for :^)

This is a revival of #111523 because I think I pushed an empty branch and bors got a bit too excited it closed the PR.
2023-05-22 12:19:16 +00:00
Lukas Markeffsky
cb2ba42a10 update pulldown-cmark to 0.9.3 2023-05-22 11:35:25 +02:00
Scott McMurray
05bf42bfa9 PR feedback: better comments and debug asserts 2023-05-21 17:48:37 -07:00
Scott McMurray
977ac5b4dd MIR: opt-in normalization of BasicBlock and Local numbering 2023-05-21 17:48:36 -07:00
Scott McMurray
57c5ac7894 Tweak the post-order for multi-successor blocks 2023-05-21 17:48:36 -07:00
bors
2440ccabc8 Auto merge of #111808 - Zoxc:query-structs-trim, r=cjgillot
Replace `QueryStruct` with arrays local to `rustc_query_impl`

This removes `QueryStruct` and instead uses constant arrays of function pointers for `try_collect_active_jobs`, `alloc_self_profile_query_strings` and `encode_query_results`. This further decouples `rustc_query_impl` from `rustc_middle`.

r? `@cjgillot`
2023-05-21 22:18:01 +00:00
bors
9d871b0617 Auto merge of #111731 - MU001999:fix/issue-111727, r=cjgillot
Keep only the trait when emitting the error for `MyTrait + 'a`

Fixes #111727
2023-05-21 19:19:49 +00:00
bors
965cf5c1f5 Auto merge of #111820 - matthiaskrgr:rollup-9sb2lw9, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #111745 (Fix overflow in error emitter)
 - #111770 (Read beta version from the version file if building from a source tarball)
 - #111797 (Migrate GUI colors test to original CSS color format)
 - #111809 (Unset MIRI_BLESS for mir-opt-level 4 miri tests)
 - #111817 (Migrate GUI colors test to original CSS color format)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-21 14:14:29 +00:00
Matthias Krüger
cb5dd1d598
Rollup merge of #111745 - Badel2:emitter-add-overflow, r=compiler-errors
Fix overflow in error emitter

Fix #109854
Close #94171 (was already fixed before but missing test)

This bug happens when a multipart suggestion spans more than one line.

The fix is to update the `acc` variable, which didn't handle the case when the text to remove spans multiple lines but the text to add spans only one line.

Also, use `usize::try_from` instead of  `as usize` to detect overflows earlier in the future, and point to the source of the overflow (the original issue points to a different place where this value is used, not where the overflow had happened).

And finally add an `if start != end` check to avoid doing any extra work in case of empty ranges.

Long explanation:

Given this test case:

```rust
fn generate_setter() {
    String::with_capacity(
    //~^ ERROR this function takes 1 argument but 3 arguments were supplied
    generate_setter,
    r#"
pub(crate) struct Person<T: Clone> {}
"#,
     r#""#,
    );
}
```

The compiler will try to convert that code into the following:

```rust
fn generate_setter() {
    String::with_capacity(
    //~^ ERROR this function takes 1 argument but 3 arguments were supplied
    /* usize */,
    );
}
```

So it creates a suggestion with 3 separate parts:

```
// Replace "generate_setter" with "/* usize */"
SubstitutionPart { span: fuzz_input.rs:4:5: 4:20 (#0), snippet: "/* usize */" }
// Remove second arg (multiline string)
SubstitutionPart { span: fuzz_input.rs:4:20: 7:3 (#0), snippet: "" }
// Remove third arg (r#""#)
SubstitutionPart { span: fuzz_input.rs:7:3: 8:11 (#0), snippet: "" }
```

Each of this parts gets a separate `SubstitutionHighlight` (this marks the relevant text green in a terminal, the values are 0-indexed so `start: 4` means column 5):

```
SubstitutionHighlight { start: 4, end: 15 }
SubstitutionHighlight { start: 15, end: 15 }
SubstitutionHighlight { start: 18446744073709551614, end: 18446744073709551614 }
```

The 2nd and 3rd suggestion are empty (start = end) because they only remove text, so there are no additions to highlight. But the 3rd span has overflowed because the compiler assumes that the 3rd suggestion is on the same line as the first suggestion. The 2nd span starts at column 20 and the highlight starts at column 16 (15+1), so that suggestion is good. But since the 3rd span starts at column 3, the result is `3 - 4`, or column -1, which turns into -2 with 0-indexed, and that's equivalent to `18446744073709551614 as isize`.

With this fix, the resulting `SubstitutionHighlight` are:

```
SubstitutionHighlight { start: 4, end: 15 }
SubstitutionHighlight { start: 15, end: 15 }
SubstitutionHighlight { start: 15, end: 15 }
```

As expected. I guess ideally we shouldn't emit empty highlights when removing text, but I am too scared to change that.
2023-05-21 16:02:59 +02:00
Urgau
6b08a745a4 Rename forget_ref lint to forgetting_references 2023-05-21 14:28:09 +02:00
Urgau
c93d9c1794 Rename drop_ref lint to dropping_references 2023-05-21 14:16:41 +02:00
Urgau
85a1828943 Rename forget_copy lint to forgetting_copy_types 2023-05-21 14:09:03 +02:00
Urgau
1c7ab18c08 Rename drop_copy lint to dropping_copy_types 2023-05-21 13:37:32 +02:00
bors
06345574d9 Auto merge of #111424 - JakobDegen:inline-unsized, r=tmiasko
Don't inline functions with unsized args

Fixes #111355 .

I have some ideas for how we can get this back in the future, out of scope for this PR though.

r? `@cjgillot`
2023-05-21 11:23:26 +00:00
John Kåre Alsaker
aa5d43647b Add comment 2023-05-21 11:25:07 +02:00
bors
d77014a608 Auto merge of #111697 - rcvalle:rust-cfi-fix-111510, r=bjorn3
CFI: Fix encode_ty: unexpected Param(B/#1)

Fixes #111510 and complements #106547 by adding support for encoding type parameters and also by transforming trait objects' traits into their identities before emitting type checks.
2023-05-21 06:42:05 +00:00
bors
a11235d1bf Auto merge of #111696 - lukas-code:offset-of-erase-regions-harder, r=compiler-errors
don't skip inference for type in `offset_of!`

Fixes https://github.com/rust-lang/rust/issues/111678 by no longer skipping inference on the type in `offset_of!`. Simply erasing the regions the during writeback isn't enough and can cause ICEs. A test case for this is included.

This reverts https://github.com/rust-lang/rust/pull/111661, because it becomes redundant, since inference already erases the regions.
2023-05-21 04:02:46 +00:00
John Kåre Alsaker
9c978b955e Replace QueryStruct with arrays local to rustc_query_impl 2023-05-21 03:12:56 +02:00
bors
1b67f8b013 Auto merge of #111675 - Urgau:fix-local-libs-for-native-static-libs, r=bjorn3
Fix local libs not included when printing native static libs

This PR fixes https://github.com/rust-lang/rust/issues/111643 by adding the local used libs to the printed `--print=native-static-libs` output.

It seems that `--print=native-static-libs` doesn't have any test, so I added one. It's very simple and doesn't even tries to compile the result to a binary as I don't know how to handle external library linking in CI. (Note that https://github.com/rust-lang/rust/blob/master/tests/run-make/staticlib-dylib-linkage/Makefile does compile to a binary)

r? `@bjorn3`
2023-05-21 01:12:45 +00:00
Jakob Degen
60cc72cf7b Don't inline functions with unsized args 2023-05-20 17:45:50 -07:00
Erik Desjardins
644818351b ensure !Unpin types do not get noalias 2023-05-20 19:34:31 -04:00
Erik Desjardins
47444d7c25 improve code checking for drop_in_place lang item 2023-05-20 18:12:54 -04:00
Patrick Walton
21b8815b6c Apply noalias, nonnull, dereferenceable, and align attributes unconditionally.
We've done measurements with Miri and have determined that `noalias` shouldn't
break code. The requirements that allow us to add dereferenceable and align
have been long documented in the standard library documentation.
2023-05-20 18:12:54 -04:00
Patrick Walton
f71741bac4 [rustc_ty_utils] Add the LLVM noalias parameter attribute to drop_in_place in certain cases.
LLVM can make use of the `noalias` parameter attribute on the parameter to
`drop_in_place` in areas like argument promotion. Because the Rust compiler
fully controls the code for `drop_in_place`, it can soundly deduce parameter
attributes on it. In the case of a value that has a programmer-defined Drop
implementation, we know that the first thing `drop_in_place` will do is pass a
pointer to the object to `Drop::drop`. `Drop::drop` takes `&mut`, so it must be
guaranteed that there are no pointers to the object upon entering that
function. Therefore, it should be safe to mark `noalias` there.

With this patch, we mark `noalias` only when the type is a value with a
programmer-defined Drop implementation. This is possibly overly conservative,
but I thought that proceeding cautiously was best in this instance.
2023-05-20 18:12:53 -04:00
bors
6bacf5a544 Auto merge of #111798 - GuillaumeGomez:rollup-t3bus8o, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #111450 (Use `OpaqueTypeKey` in query response)
 - #111726 (Migrate GUI colors test to original CSS color format)
 - #111746 (Merge some query impl modules into one)
 - #111765 (Migrate GUI colors test to original CSS color format)
 - #111771 (add `--remote-time` flag to curl for bootstrap)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-20 16:07:54 +00:00
Guillaume Gomez
3f9a7e7c81
Rollup merge of #111746 - Zoxc:query-impl-mod, r=cjgillot
Merge some query impl modules into one

This merges some modules in `rustc_query_impl` into one per query, analogous to https://github.com/rust-lang/rust/pull/111703.

r? `@cjgillot`
2023-05-20 15:37:24 +02:00
Guillaume Gomez
de074242eb
Rollup merge of #111450 - compiler-errors:opaque-ty-key, r=oli-obk
Use `OpaqueTypeKey` in query response

Makes it a bit clearer that at least one of the types being returned from a canonical query is an opaque.
2023-05-20 15:37:23 +02:00
Lukas Markeffsky
7cdb23b98a don't skip inference for type in offset_of! 2023-05-20 15:20:27 +02:00
bors
4eb5225cdf Auto merge of #111413 - workingjubilee:bump-object-0-31-1, r=MarkSimulacrum
Bump object and thorin-dwp

Required to fix watchOS breakage.
2023-05-20 13:19:37 +00:00
bors
6d1bf733d6 Auto merge of #111778 - Dylan-DPC:rollup-107ig9h, r=Dylan-DPC
Rollup of 10 pull requests

Successful merges:

 - #111491 (Dont check `must_use` on nested `impl Future` from fn)
 - #111606 (very minor cleanups)
 - #111619 (Add timings for MIR passes to profiling report)
 - #111652 (Better diagnostic for `use Self::..`)
 - #111665 (Add more tests for the offset_of macro)
 - #111708 (Give a more useful location for where a span_bug was delayed)
 - #111715 (Fix doc comment for `ConstParamTy` derive)
 - #111723 (style: do not overwrite obligations)
 - #111743 (Improve cgu merging debug output)
 - #111762 (fix: emit error when fragment is `MethodReceiverExpr` and items is empty)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-20 10:30:30 +00:00
bors
25f084d5e0 Auto merge of #111596 - cjgillot:dominator-bucket, r=Mark-Simulacrum
Process current bucket instead of parent's bucket when starting loop for dominators.

The linked paper by Georgiadis suggests in §2.2.3 to process `bucket[w]` when beginning the loop, instead of `bucket[parent[w]]` when finishing it.

In the test case, we correctly computed `idom[2] = 0` and `sdom[3] = 1`, but the algorithm returned `idom[3] = 1`, instead of the correct value 0, because of the path 0-7-2-3.

This provoked LLVM ICE in https://github.com/rust-lang/rust/pull/111061#issuecomment-1546912112. LLVM checks that SSA assignments dominate uses using its own implementation of Lengauer-Tarjan, and saw case where rustc was breaking the dominance property.

r? `@Mark-Simulacrum`
2023-05-20 07:41:15 +00:00
Dylan DPC
94ca44a50a
Rollup merge of #111762 - bvanjoi:fix-111749, r=compiler-errors
fix: emit error when fragment is `MethodReceiverExpr` and items is empty

Fixes https://github.com/rust-lang/rust/issues/111749
2023-05-20 12:21:02 +05:30
Dylan DPC
9074769dc5
Rollup merge of #111743 - nnethercote:improve-cgu-merging-debug-output, r=lqd
Improve cgu merging debug output

r? ```@lqd```
2023-05-20 12:21:02 +05:30
Dylan DPC
c453b48fd8
Rollup merge of #111723 - lcnr:overwrite-obligations, r=compiler-errors
style: do not overwrite obligations

this looks sketchy and would break if the original obligations do not start out empty 😁
2023-05-20 12:21:01 +05:30
Dylan DPC
35bef062c7
Rollup merge of #111708 - jyn514:delay-span-bug-msg, r=compiler-errors
Give a more useful location for where a span_bug was delayed

Before:
```
   = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1335:29
              1: <rustc_errors::Handler>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1124:9
...
```

After:
```
   = note: delayed at compiler/rustc_parse/src/parser/diagnostics.rs:2158:28
              0: <rustc_errors::HandlerInner>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1335:29
              1: <rustc_errors::Handler>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1124:9
...
```

This both makes the relevant frame easier to find without having to dig through diagnostic internals, and avoids the weird-looking formatting for the first frame.

Found while working on https://github.com/rust-lang/rust/issues/111529.
2023-05-20 12:21:00 +05:30
Dylan DPC
13f3585dc6
Rollup merge of #111652 - clubby789:self-import-improvement, r=compiler-errors
Better diagnostic for `use Self::..`

Fixes #111627

cc `@petrochenkov,` you might have thoughts on a better way to handle this (https://github.com/rust-lang/rust/issues/63720#issuecomment-591597466)
2023-05-20 12:21:00 +05:30
Dylan DPC
1397827f25
Rollup merge of #111619 - cjgillot:profile-pass, r=WaffleLapkin
Add timings for MIR passes to profiling report

This will help identify which pass is responsible for a regression.
2023-05-20 12:20:59 +05:30
Dylan DPC
fa11c9e8ca
Rollup merge of #111606 - jyn514:nightly-diagnostics, r=lcnr
very minor cleanups

- add `must_use` to `early_error_no_abort`

  this was already being used at its only callsite, but this ensures that new code remembers to use it if it's called in the future. found this while investigating https://github.com/rust-lang/rust/issues/110090.

- remove outdated and incorrect comment in `builder.rs`. `doc_rust_lang_org_channel` doesn't exist in rustdoc, it gets it from an env var instead: b275d2c30b/src/librustdoc/clean/utils.rs (L569-L573)
2023-05-20 12:20:59 +05:30
Dylan DPC
2294d81fb3
Rollup merge of #111491 - compiler-errors:nested-fut-must-use, r=wesleywiser
Dont check `must_use` on nested `impl Future` from fn

Fixes (but does not close, per beta policy) #111484

Also fixes a `FIXME` left in the code about (presumably) false-positives on non-async `#[must_use] fn() -> impl Future` cases, though if that's not desirable to include in the beta backport then I can certainly revert it.

Beta nominating as it fixes a beta ICE.
2023-05-20 12:20:58 +05:30
Michael Goulet
2b1d4bf44e Add extra debug assertions for equality for Adt/Variant/FieldDef 2023-05-19 22:51:50 +00:00
Badel2
cbb41008fd Fix overflow in error emitter 2023-05-19 20:58:06 +02:00
Maybe Waffle
140cdcbc9d Drive-by-cleanup: Don't emit thir::ExprKind::NeverToAny for ! -> ! 2023-05-19 21:50:01 +04:00
Mu001999
d57383855e Avoid redundant to_string 2023-05-19 23:11:02 +08:00
Mu001999
a9528a28f2 Keep only the trait when emitting the error for MyTrait + 'a 2023-05-19 22:11:54 +08:00
bohan
990b2899ad fix: emit error when fragment is MethodReceiverExpr and items is empty 2023-05-19 21:21:05 +08:00
Camille GILLOT
340fc2d08a Leverage the interval property to precompute borrow kill points. 2023-05-19 11:58:31 +00:00
bors
17a681000b Auto merge of #111641 - michaelwoerister:debugger-visualizer-fixes, r=cjgillot
Fix dependency tracking for debugger visualizers

This PR fixes dependency tracking for debugger visualizer files by changing the `debugger_visualizers` query to an `eval_always` query that scans the AST while it is still available. This way the set of visualizer files is already available when dep-info is emitted. Since the query is turned into an `eval_always` query, dependency tracking will now reliably detect changes to the visualizer script files themselves.

TODO:
 - [x] perf.rlo
 - [x] Needs a bit more documentation in some places
 - [x] Needs regression test for the incr. comp. case

Fixes https://github.com/rust-lang/rust/issues/111226
Fixes https://github.com/rust-lang/rust/issues/111227
Fixes https://github.com/rust-lang/rust/issues/111295

r? `@wesleywiser`
cc `@gibbyfree`
2023-05-19 11:30:44 +00:00
Ryo Yoshida
3a03587836
Consider lint check attributes on match arms in match checks 2023-05-19 19:04:15 +09:00
Ryo Yoshida
ddafe23401
Consider lint check attributes on match arms in late lints
Additionally add analogous test for early lints.
2023-05-19 19:04:10 +09:00
lcnr
1708ad65a4 update recursion depth in confirm_candidate 2023-05-19 10:33:13 +02:00
bors
19ca5692f6 Auto merge of #110100 - compiler-errors:no-infer-pred-must-hold, r=jackh726
do not allow inference in `predicate_must_hold` (alternative approach)

See the FCP description for more info, but tl;dr is that we should not return `EvaluatedToOkModuloRegions` if an obligation may hold only with some choice of inference vars being constrained.

Attempts to solve this in the approach laid out by lcnr here: https://github.com/rust-lang/rust/pull/109558#discussion_r1147318134, rather than by eagerly replacing infer vars with placeholders which is a bit too restrictive.

r? `@ghost`
2023-05-19 03:36:37 +00:00
bors
92f5dea0eb Auto merge of #109602 - bvanjoi:fix-issue-109343, r=petrochenkov
fix(resolve): replace bindings to dummy for unresolved imports

close #109343

In #109343, `f` in `pub use f as g` points to:

|namespace| binding|
|-|-|
|type| `external crate f`|
|value| `None` |
|macro| `None` |

When resolve `value_ns` during `resolve_doc_links`, the value of the binding of single_import `pub use f as g` goes to `pub use inner::f`, and since it does not satisfy [!self.is_accessible_from(binding.vis, single_import.parent_scope.module)](https://github.com/rust-lang/rust/blob/master/compiler/rustc_resolve/src/ident.rs#L971) and returns `Err(Undetermined)`, which eventually goes to `PathResult::Indeterminate => unreachable!`.

This PR replace all namespace binding to `dummy_binding` for indeterminate import, so, the bindings of `pub use f as g` had been changed to followings after finalize:

|namespace| binding|
|-|-|
|type| `dummy`|
|value| `dummy` |
|macro| `dummy` |

r?`@petrochenkov`
2023-05-19 00:41:32 +00:00
John Kåre Alsaker
9e755d98cc Merge some query impl modules into one 2023-05-19 01:38:27 +02:00
Nicholas Nethercote
1bb957efc6 Improve CGU partitioning debug output.
- Pass a slice instead of an iterator to `debug_dump`.
- For each CGU set, print: the number of CGUs, the max and min size, and
  the ratio of the max and min size (which indicates how evenly sized
  they are).
- Print a `FINAL` entry, showing the absolute final results.
2023-05-19 08:48:28 +10:00
Nicholas Nethercote
1551495d32 Fix an ICE in CGU dumping code. 2023-05-19 08:48:28 +10:00
bors
c9dc55d05c Auto merge of #111345 - jyn514:cfg-release-caching, r=cjgillot,est31
Only depend on CFG_VERSION in rustc_interface

This avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`.

cc https://github.com/rust-lang/rust/issues/76720 - this won't fix it, and I'm not suggesting we turn this on by default, but it will make it less painful for people who do have `omit-git-hash` on as a workaround.
2023-05-18 21:45:02 +00:00
bors
d3f416dc06 Auto merge of #110493 - bvanjoi:new_disambiguated_key, r=petrochenkov
fix(resolve): only disambiguate binding key during define

- close https://github.com/rust-lang/rust/issues/110164
- discussion: https://github.com/rust-lang/rust/pull/110264#discussion_r1168895468

r? `@petrochenkov`
2023-05-18 18:53:49 +00:00
Scott McMurray
400866b7ab Also assume wrap-around discriminants in as MIR building
Resolves this FIXME:

8d18c32b61/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs (L231)
2023-05-18 10:28:36 -07:00
Camille GILLOT
7c8f29f02c Revert spurious changes. 2023-05-18 14:36:13 +00:00
jyn
04265621f9 very minor cleanups
- add `must_use` to `early_error_no_abort`

  this was already being used at its only callsite, but this ensures
that new code remembers to use it if it's called in the future.

- remove outdated and incorrect comment in `builder.rs`.
  `doc_rust_lang_org_channel` doesn't exist in rustdoc, it gets it from
an env var instead.
2023-05-18 08:06:47 -05:00
lcnr
3e4ed61c09 do not overwrite obligations 2023-05-18 15:00:30 +02:00
Dylan DPC
ad214ac02b
Rollup merge of #111707 - nnethercote:rm-WorkerLocal-Vec, r=compiler-errors
Remove unused `impl<T> WorkerLocal<Vec<T>>`.

cc ``@SparrowLii`` ``@Zoxc``
2023-05-18 17:37:10 +05:30
Dylan DPC
cca0f97985
Rollup merge of #111703 - Zoxc:queries-mod, r=cjgillot
Merge query property modules into one

This merges all the query modules that defines types into a single module per query with a normal naming convention for type aliases.

r? ``@cjgillot``
2023-05-18 17:37:10 +05:30
Dylan DPC
d2823a1bbe
Rollup merge of #111695 - fmease:dont-lump-together-alias-tys, r=compiler-errors
Exclude inherent projections from some alias type `match`es

Updating (hopefully) all remaining `match`es which I overlooked to update when adding `AliasKind::Inherent` in #109410.

Fixes #111399.
Sadly the regression test is a clippy test instead of a rustc one as I don't know of another way to test that a trait bound like `Ty::InhProj: Trait` doesn't cause a crash without reaching a cycle error first (this is getting old ^^').

`@rustbot` label F-inherent_associated_types
r? `@compiler-errors`
2023-05-18 17:37:09 +05:30
Dylan DPC
ea6ac450e2
Rollup merge of #111686 - cjgillot:no-foreign-item, r=compiler-errors
Retire is_foreign_item query.

This can be written in terms of `DefKind`. This does not deserve the cost of a query.
2023-05-18 17:37:09 +05:30
Dylan DPC
ee26abdafb
Rollup merge of #111054 - cjgillot:cfg-eval-recover, r=b-naber
Do not recover when parsing stmt in cfg-eval.

`parse_stmt` does recovery on its own. When parsing the statement fails, we always get `Ok(None)` instead of an `Err` variant with the diagnostic that we can emit.

To avoid this behaviour, we need to opt-out of recovery for cfg_eval.

Fixes https://github.com/rust-lang/rust/issues/105228
2023-05-18 17:37:08 +05:30
Dylan DPC
f2b213cfc4
Rollup merge of #110986 - cjgillot:delay-feed-bug, r=WaffleLapkin
Delay a bug when overwriting fed value.

Fixes https://github.com/rust-lang/rust/issues/110887
2023-05-18 17:37:07 +05:30
Camille GILLOT
f52db3ecaa Stop confusing specification levels when computing expectations. 2023-05-18 08:52:54 +00:00
John Kåre Alsaker
f6c6d10443 Merge query property modules into one 2023-05-18 09:45:12 +02:00
bors
9052ca9393 Auto merge of #111710 - Dylan-DPC:rollup-eutrx54, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #110884 (Support RISC-V unaligned-scalar-mem target feature)
 - #111160 (Update serde in workspace and non-synced dependencies)
 - #111168 (Specialize ToString implementation for fmt::Arguments)
 - #111527 (add examples of port 0 binding behavior)
 - #111561 (Include better context for "already exists" error in compiletest)
 - #111633 (Avoid `&format("...")` calls in error message code.)
 - #111679 (Remove libs message about ACPs from triagebot)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-18 07:14:23 +00:00
Dylan DPC
08efb9d652
Rollup merge of #111633 - nnethercote:avoid-ref-format, r=WaffleLapkin
Avoid `&format("...")` calls in error message code.

Some error message cleanups. Best reviewed one commit at a time.

r? `@davidtwco`
2023-05-18 10:52:35 +05:30
Dylan DPC
677da1c4e5
Rollup merge of #110884 - korran:unaligned-scalar-mem, r=wesleywiser
Support RISC-V unaligned-scalar-mem target feature

This adds `unaligned-scalar-mem` as an allowed RISC-V target feature. Some RISC-V cores support unaligned access to memory without trapping. On such cores, the compiler could significantly improve code-size and performance when using functions like core::ptr::read_unaligned<u32> by emitting a single load or store instruction with an unaligned address, rather than a long sequence of byte load/store/bitmanip instructions.

Enabling the `unaligned-scalar-mem` target feature allows LLVM to do this optimization.

Fixes #110883
2023-05-18 10:52:33 +05:30
jyn
d5f2b8e5c6 Only depend on CFG_VERSION in rustc_interface
this avoids having to rebuild the whole compiler on each commit when
`omit-git-hash = false`.
2023-05-17 23:54:21 -05:00
bors
77c836e1ae Auto merge of #108938 - chenyukang:yukang/fix-107910-shorten-ice, r=cjgillot
Shorten backtraces for queries in ICEs

r? `@jyn514`
Fixes #107910
2023-05-18 04:21:15 +00:00
jyn
e6a7fdedd7 Give a more useful location for where a span_bug was delayed
Before:
```
   = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1335:29
              1: <rustc_errors::Handler>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1124:9
...
```

After:
```
   = note: delayed at compiler/rustc_parse/src/parser/diagnostics.rs:2158:28
              0: <rustc_errors::HandlerInner>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1335:29
              1: <rustc_errors::Handler>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1124:9
```

This both makes the relevant frame easier to find without having to dig
through diagnostic internals, and avoids the weird-looking formatting
for the first frame.
2023-05-17 23:15:22 -05:00
Nicholas Nethercote
9bfb90b1be Remove unused impl<T> WorkerLocal<Vec<T>>. 2023-05-18 13:14:45 +10:00
Michael Goulet
3db2bcf4eb Remove return type sized check hack from hir typeck 2023-05-18 01:53:01 +00:00
Michael Goulet
795fdf7d61 Simplify suggestion when returning bare dyn trait 2023-05-18 01:47:55 +00:00
bors
77fb0cd3aa Auto merge of #111364 - cuviper:unhack-thinlto, r=nikic
Remove the ThinLTO CU hack

This reverts #46722, commit e0ab5d5feb.

Since #111167, commit 10b69dde3f, we are
generating DWARF subprograms in a way that is meant to be more compatible
with LLVM's expectations, so hopefully we don't need this workaround
rewriting CUs anymore.
2023-05-18 01:35:41 +00:00
bohan
5b09810976 fix(resolve): only disambiguate binding key during define 2023-05-18 09:29:48 +08:00
bohan
f34678c097 fix(resolve): replace bindings to dummy for unresolved imports 2023-05-18 09:22:29 +08:00
Ramon de C Valle
f067935ab2 CFI: Fix encode_ty: unexpected Param(B/#1)
Fixes #111510 and complements #106547 by adding support for encoding
type parameters and also by transforming trait objects' traits into
their identities before emitting type checks.
2023-05-17 22:12:13 +00:00
León Orell Valerian Liehr
434f08884e
Exclude inherent projections from some alias ty matches 2023-05-17 23:53:58 +02:00