Commit Graph

28579 Commits

Author SHA1 Message Date
Ali MJ Al-Nasrawy
996ffcb718 always show and explain sub region 2023-10-08 09:59:51 +00:00
Ali MJ Al-Nasrawy
5be0b2283a improve the suggestion of generic_bound_failure 2023-10-08 09:56:57 +00:00
bors
e08de86036 Auto merge of #116487 - tamird:avoid-unwrap-absolute, r=bjorn3
compiler: env/path handling fixes

Please see individual commits. r? `@bjorn3` cf. #116426
2023-10-08 05:24:16 +00:00
bors
1516ca1bc0 Auto merge of #116486 - van-ema:master, r=nikic
Fix to register analysis passes with -Zllvm-plugins at link-time

This PR fixes an unexpected behavior of the `-Zllvm-plugins` flag. It allows to run an out-of-tree pass as part of LTO.
However, analysis passes are registered before the plugin is loaded. As a result an analysis pass, which is passed as a plugin, is not registered. This causes the LLVM PassManager to fail when the analysis pass is queried from a transformation pass  [(here)](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/PassManager.h#L776).

This fix mimics the bahavior in [LLVM LTOBackend.cpp](https://github.com/llvm/llvm-project/blob/main/llvm/lib/LTO/LTOBackend.cpp#L273) by loading the plugin before the analysis passes are registered.

Tested with rustc 1.60 and 1.65 and LLVM-13.0.1.
2023-10-08 03:36:37 +00:00
bors
cf21a0823b Auto merge of #116437 - nnethercote:rustc_features, r=Nilstrieb
Clean up `rustc_features`

Plenty more to be done, but this is a decent start.

r? `@Nilstrieb`
2023-10-07 19:11:17 +00:00
bors
935a091a78 Auto merge of #116330 - RalfJung:dont-key-on-allocid, r=oli-obk
remove Key impls for types that involve an AllocId

I don't understand how but somehow that leads to issues like https://github.com/rust-lang/rust/issues/83085? Anyway removing unused impls doesn't seem like a bad idea. The concerning part is that of course nothing will stop us from having such impls again in the future, alongside re-introducing bugs like #83085.

r? `@oli-obk`
2023-10-07 15:21:05 +00:00
bors
91db3bdc8c Auto merge of #116310 - Enselic:check_fn_args_move_size, r=oli-obk
rustc_monomorphize: Introduce check_fn_args_move_size()

This is in preparation of improving diagnostics of "large moves into functions", a.k.a. passing args.

Note: This PR consists of two self-contained commits that can be reviewed independently.

For https://github.com/rust-lang/rust/issues/83518

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

r? `@oli-obk` who is E-mentor
2023-10-07 13:33:19 +00:00
bors
48e24629e9 Auto merge of #115583 - RalfJung:packed-unsized, r=lcnr
fix detecting references to packed unsized fields

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

This is a breaking change, but permitted as a soundness fix.
2023-10-07 10:57:18 +00:00
bors
d087c6fae2 Auto merge of #116457 - RalfJung:try_eval_scalar_int, r=cjgillot
fix fast-path for try_eval_scalar_int

Cc https://github.com/rust-lang/rust/pull/116281 `@Nadrieril`
2023-10-07 08:58:23 +00:00
Martin Nordholts
56e4715fc6 rustc_monomorphize: Introduce check_fn_args_move_size()
So that we later can improve the accuracy of diagnostics.
2023-10-07 10:29:37 +02:00
Martin Nordholts
41d24ccb49 rustc_monomorphize: Move limit check into check_move_size()
And rename to check_operand_move_size(). Later we will introduce
check_fn_args_move_size().
2023-10-07 10:29:16 +02:00
Jubilee
0d68e416a5
Rollup merge of #116400 - estebank:issue-78585, r=WaffleLapkin
Detect missing `=>` after match guard during parsing

```
error: expected one of `,`, `:`, or `}`, found `.`
  --> $DIR/missing-fat-arrow.rs:25:14
   |
LL |         Some(a) if a.value == b {
   |                               - while parsing this struct
LL |             a.value = 1;
   |             -^ expected one of `,`, `:`, or `}`
   |             |
   |             while parsing this struct field
   |
help: try naming a field
   |
LL |             a: a.value = 1;
   |             ++
help: you might have meant to start a match arm after the match guard
   |
LL |         Some(a) if a.value == b => {
   |                                 ++
```

Fix #78585.
2023-10-06 16:37:47 -07:00
Jubilee
6d1c3a40cb
Rollup merge of #116277 - RalfJung:post-mono, r=oli-obk
dont call mir.post_mono_checks in codegen

It seems like all tests are still passing when I remove this... let's see what CI says.
2023-10-06 16:37:46 -07:00
bors
960754090a Auto merge of #116492 - matthiaskrgr:rollup-xzfhmq1, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #114564 (Attempt to describe the intent behind the `From` trait further)
 - #116297 (add some docs to hooks/mod.rs)
 - #116423 (Fix typo in attrs.rs)
 - #116466 (`rustc_transmute` cleanups)
 - #116474 (Assorted small cleanups)
 - #116481 (Reuse existing `Some`s in `Option::(x)or`)
 - #116484 (Minor doc clarification in Once::call_once)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-06 20:51:40 +00:00
Matthias Krüger
9796dfdd56
Rollup merge of #116474 - nnethercote:rustc_assorted, r=spastorino
Assorted small cleanups

r? `@spastorino`
2023-10-06 21:17:50 +02:00
Matthias Krüger
25fbd133ea
Rollup merge of #116466 - nnethercote:rustc_transmute, r=oli-obk
`rustc_transmute` cleanups

Just some things I found while poking around this code.

r? `@oli-obk`
2023-10-06 21:17:49 +02:00
Matthias Krüger
fdb136a83f
Rollup merge of #116297 - RalfJung:hooks, r=oli-obk
add some docs to hooks/mod.rs

r? `@oli-obk`
2023-10-06 21:17:48 +02:00
bors
94bc9c737e Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiser
Show more information when multiple `impl`s apply

- When there are `impl`s without type params, show only those (to avoid showing overly generic `impl`s).
```
error[E0283]: type annotations needed
  --> $DIR/multiple-impl-apply.rs:34:9
   |
LL |     let y = x.into();
   |         ^     ---- type must be known at this point
   |
note: multiple `impl`s satisfying `_: From<Baz>` found
  --> $DIR/multiple-impl-apply.rs:14:1
   |
LL | impl From<Baz> for Bar {
   | ^^^^^^^^^^^^^^^^^^^^^^
...
LL | impl From<Baz> for Foo {
   | ^^^^^^^^^^^^^^^^^^^^^^
   = note: required for `Baz` to implement `Into<_>`
help: consider giving `y` an explicit type
   |
LL |     let y: /* Type */ = x.into();
   |          ++++++++++++
```

- Lower the importance of `T: Sized`, `T: WellFormed` and coercion errors, to prioritize more relevant errors. The pre-existing deduplication logic deals with hiding redundant errors better that way, and we show errors with more metadata that is useful to the user.

- Show `<SelfTy as Trait>::assoc_fn` suggestion in more cases.
```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
  --> $DIR/cross-return-site-inference.rs:38:16
   |
LL |     return Err(From::from("foo"));
   |                ^^^^^^^^^^ cannot call associated function of trait
   |
help: use a fully-qualified path to a specific available implementation
   |
LL |     return Err(</* self type */ as From>::from("foo"));
   |                +++++++++++++++++++     +
```

Fix #88284.
2023-10-06 18:44:32 +00:00
Ralf Jung
fa248cd9e6 add some comments explaining how the required_consts stuff fits together 2023-10-06 18:25:23 +02:00
bors
64fa0c34d7 Auto merge of #115304 - Enselic:trailing-gt, r=cjgillot
Allow file names to end with '>'

The [`rustc_span::FileName`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_span/enum.FileName.html) enum already differentiates between real files and "fake" files such as `<anon>`. We do not need to artificially forbid real file names from ending in `>`.

Closes #73419
2023-10-06 14:57:09 +00:00
Tamir Duberstein
3cac3de200
rustc_metadata: use try_canonicalize
This is simpler and avoids unnecessary calls to `env::current_dir`.

rustc_plugin is left unchanged to avoid conflicts with #116412.

Updates #116426.
2023-10-06 09:54:12 -04:00
Tamir Duberstein
5aeb6a326f
rustc_codegen_ssa: use try_canonicalize in rpath
This is simpler and avoids unnecessary calls to `env::current_dir`.
2023-10-06 09:54:11 -04:00
Tamir Duberstein
a081007265
rustc_driver: avoid fallible conversions
Use `std::path::PathBuf` rather than `String`; use `std::env::var_os`
rather than `std::env::var`. These changes avoid a number of error paths
which can arise in the presence of non-UTF-8 paths.
2023-10-06 08:54:14 -04:00
Tamir Duberstein
7654d4b398
compiler: always use var_os("RUST_BACKTRACE")
There are 3 instances of var(...) and 3 instances of var_os(...); the
latter avoids an appearance of unhandled error, so use it everywhere.
2023-10-06 08:53:23 -04:00
Emanuele Vannacci
5048f81313 fix to register analysis pass from llvm plugin 2023-10-06 12:04:28 +00:00
Guillaume Gomez
9e28a9349c
Rollup merge of #116329 - RalfJung:swap-comments, r=scottmcm
update some comments around swap()

Based on ``@eddyb's`` comment [here](https://github.com/rust-lang/unsafe-code-guidelines/issues/461#issuecomment-1742156410).

And then I noticed the wrong capitalization for Miri and fixed it in some other places as well.
2023-10-06 13:18:35 +02:00
Guillaume Gomez
3785fed021
Rollup merge of #116198 - Jarcho:diag_items, r=WaffleLapkin
Add more diagnostic items for clippy
2023-10-06 13:18:34 +02:00
Matthias Krüger
7d7004d3e6
Rollup merge of #116421 - Urgau:inter-mut-invalid_ref_casting, r=oli-obk
Clarify `invalid_reference_casting` lint around interior mutable types

This is PR intends to clarify the `invalid_reference_casting` lint around interior mutable types by adding a note for them saying that they should go through `UnsafeCell::get`.

So for this code:
```rust
let cell = &std::cell::UnsafeCell::new(0);
let _num = &mut *(cell as *const _ as *mut i32);
```

the following note will be added to the lint output:

```diff
 error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused,  consider instead using an `UnsafeCell`
   --> $DIR/reference_casting.rs:68:16
    |
 LL |     let _num = &mut *(cell as *const _ as *mut i32);
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+   = note: even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get`
```

Suggestion are welcome around the note contents.

Fixes https://github.com/rust-lang/rust/issues/116410
cc `@RalfJung`
2023-10-06 06:23:48 +02:00
Nicholas Nethercote
e7dabc9f87 Remove unnecessary pub. 2023-10-06 14:59:11 +11:00
Nicholas Nethercote
093b435b78 Remove unneeded features. 2023-10-06 14:58:01 +11:00
Nicholas Nethercote
4b51a3eb52 Remove unneeded dependency.
Also sort them.
2023-10-06 14:57:25 +11:00
Nicholas Nethercote
e49a1470ba Factor out insert_or_error.
It appears identically as a closure in two functions.

Also change its return type from `bool` to `Option<()>` so it can be
used with `?`.
2023-10-06 14:57:09 +11:00
Nicholas Nethercote
108e541cc2 Remove unused FileName::CfgSpec. 2023-10-06 14:57:09 +11:00
Nicholas Nethercote
442a66d385 Remove unneeded dependency. 2023-10-06 14:57:09 +11:00
Nicholas Nethercote
29ed8e492a Remove the MaybeTransmutableQuery<&'l Dfa<...>, C> impl.
Because there is also a `MaybeTransmutableQuery<Dfa<...>, C>` impl, and
we don't need both.
2023-10-06 11:25:32 +11:00
Nicholas Nethercote
73420fc13b Fix a comment.
It was duplicated from the method above.
2023-10-06 11:22:06 +11:00
Nicholas Nethercote
449b84cb99 Remove map_layouts.
As per the `FIXME` comment, it's an abstraction that makes the code
harder to read.
2023-10-06 11:21:08 +11:00
bors
2c9b0de8ea Auto merge of #116269 - Veykril:rustc-abi, r=WaffleLapkin
Bring back generic parameters for indices in rustc_abi and make it compile on stable

This effectively reverses https://github.com/rust-lang/rust/pull/107163, allowing rust-analyzer to depend on this crate again,

It also moves some glob imports / expands them in the first commit because they made it more difficult for me to reason about things.
2023-10-06 00:03:56 +00:00
Nicholas Nethercote
409193654d Make the comment order match variant declaration order. 2023-10-06 10:17:29 +11:00
Nicholas Nethercote
80bf6883be Remove an unnecessary pub(crate). 2023-10-06 10:16:54 +11:00
Jason Newcomb
d464b72970 Add more diagnostic items for clippy 2023-10-05 18:21:47 -04:00
Ralf Jung
cbe892fd65 fix fast-path for try_eval_scalar_int 2023-10-05 22:00:24 +02:00
bors
cae0791da4 Auto merge of #116417 - ouz-a:trait_type_detective, r=compiler-errors
Remove is global hack

In attempt to fix https://github.com/rust-lang/rust/issues/114057 we found several issues with how compiler computes layouts, this change removes `is_global` from `and` to stop impl from being shadowed.

In depth conversation can be read here https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Getting.20different.20types.20from.20almost.20same.20inputs

This is a fix candidate opened for performance run.

r? `@lcnr`
2023-10-05 19:42:05 +00:00
Oğuz Ağcayazı
e30d27be00 remove is global hack 2023-10-05 21:38:12 +03:00
Martin Nordholts
8a1be9942d Allow file names to end with '>'
The `rustc_span::FileName` enum already differentiates between real
files and "fake" files such as `<anon>`. We do not need to artificially
forbid real file names from ending in `>`.
2023-10-05 20:17:48 +02:00
Matthias Krüger
76d0b794cb
Rollup merge of #116452 - cjgillot:noassert-erased, r=oli-obk
Do not assert that hidden types don't have erased regions.

cc https://github.com/rust-lang/rust/issues/116306

`args` can have erased regions.
In the linked issue, this is reached by computing whether a large type is `Freeze` to compute its ABI.

I do not have a minimized test to include.
2023-10-05 19:24:35 +02:00
Matthias Krüger
c1c5ab717e
Rollup merge of #116428 - Alexendoo:note-duplicate-diagnostics, r=compiler-errors,estebank
Add a note to duplicate diagnostics

Helps explain why there may be a difference between manual testing and the test suite output and highlights them as something to potentially look into

For existing duplicate diagnostics I just blessed them other than a few files that had other `NOTE` annotations in
2023-10-05 19:24:35 +02:00
Matthias Krüger
08cc7428d9
Rollup merge of #116415 - ouz-a:move_subtyper, r=oli-obk
Move subtyper below reveal_all and change reveal_all

In previous attempt https://github.com/rust-lang/rust/pull/116378 we tried to handle `Opaque` in few different places, but this isn't necessary, after moving subtyper below reveal_all and calling `super_place` on reveal_all, issues cease to exist.

r? ``@oli-obk``

Fixes https://github.com/rust-lang/rust/issues/116332
Fixes https://github.com/rust-lang/rust/issues/116265
Fixes https://github.com/rust-lang/rust/issues/116383
Fixes https://github.com/rust-lang/rust/issues/116333
2023-10-05 19:24:34 +02:00
Matthias Krüger
b301bd4220
Rollup merge of #116288 - ouz-a:smir_spans, r=spastorino
Add Span to various smir types

Had to make few extra changes to few structs to attach spans to them.

r? ``@oli-obk``
2023-10-05 19:24:34 +02:00
Matthias Krüger
864e5d8d94
Rollup merge of #116220 - llogiq:stabilize-option-as-slice, r=BurntSushi
stabilize `Option::as_`(`mut_`)`slice`

This is the stabilization to #108545. Thanks to everyone who helped getting this into Rust proper.
2023-10-05 19:24:33 +02:00