Commit Graph

3054 Commits

Author SHA1 Message Date
bors
ef8ee73fc4 Auto merge of #112494 - matthiaskrgr:rollup-xdf3om8, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #112297 (bootstrap: Disallow `--exclude test::std`)
 - #112298 (Update field-offset and enable unstable_offset_of)
 - #112335 (ci: Upgrade loongarch64-linux-gnu GCC to 13.1.0)
 - #112413 (Adjust span labels for `HIDDEN_GLOB_REEXPORTS`)
 - #112483 (Add deprecation warning to python versions <3.6 in x.py)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-10 15:49:43 +00:00
Matthias Krüger
312e676333
Rollup merge of #112413 - jieyouxu:fix-hidden-glob-reexports-span-order, r=petrochenkov
Adjust span labels for `HIDDEN_GLOB_REEXPORTS`

Addresses https://github.com/rust-lang/rust/pull/111378#issuecomment-1581226063.

### Before This PR

The possibility that the private item comes before the glob re-export was not account for, causing the span label messages to say "but private item here shadows it" before "the name `Foo` in the type namespace is supposed to be publicly re-exported here".

### After This PR

```rust
warning: private item shadows public glob re-export
  --> $DIR/hidden_glob_reexports.rs:9:5
   |
LL |     struct Foo;
   |     ^^^^^^^^^^^ the private item here shadows the name `Foo` in the type namespace
...
LL |     pub use self::inner::*;
   |             -------------- but it is supposed to be publicly re-exported here
   |
   = note: `#[warn(hidden_glob_reexports)]` on by default

warning: private item shadows public glob re-export
  --> $DIR/hidden_glob_reexports.rs:27:9
   |
LL |     pub use self::inner::*;
   |             -------------- the name `Foo` in the type namespace is supposed to be publicly re-exported here
LL |
LL |     use self::other::Foo;
   |         ^^^^^^^^^^^^^^^^ but the private item here shadows it
```
2023-06-10 15:24:44 +02:00
bors
788c98df59 Auto merge of #111818 - Urgau:uplift_cmp_nan, r=cjgillot
Uplift `clippy::cmp_nan` lint

This PR aims at uplifting the `clippy::cmp_nan` lint into rustc.

## `invalid_nan_comparisons`

~~(deny-by-default)~~ (warn-by-default)

The `invalid_nan_comparisons` lint checks comparison with `f32::NAN` or `f64::NAN` as one of the operand.

### Example

```rust,compile_fail
let a = 2.3f32;
if a == f32::NAN {}
```

### Explanation

NaN does not compare meaningfully to anything – not even itself – so those comparisons are always false.

-----

Mostly followed the instructions for uplifting a clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

`@rustbot` label: +I-lang-nominated
r? compiler
2023-06-10 12:47:51 +00:00
Matthias Krüger
dcdfff61d2
Rollup merge of #112481 - compiler-errors:new-solver-ignore-bad-tests, r=lqd
Ignore tests that hang in new solver

This makes it easier to run `--compare-mode=next-solver`, and we can revisit these tests later to find out how to make them less overflowy 😅

r? `@lcnr`
2023-06-10 11:20:11 +02:00
Matthias Krüger
299929e035
Rollup merge of #112468 - GuillaumeGomez:change-rustdoc-js-formats, r=notriddle
Change format of rustdoc-js tests by putting query and correction directly alongside the expected values

As I was working on fixing merge conflicts in #108537, I faced quite a big issue when trying to update the `rustdoc-js*` tests. To make it much simpler, this PR moves the `query` and `correction` directly alongside the expected data so now we know what is the query that is being run without needing to add comments or going back to the top of the file.

r? ```@notriddle```
2023-06-10 11:20:10 +02:00
Matthias Krüger
2baebad063
Rollup merge of #110141 - petrochenkov:cratecfg2, r=WaffleLapkin
expand: Change how `#![cfg(FALSE)]` behaves on crate root

Previously it removed all other attributes from the crate root.
Now it removes only attributes below itself (during both regular expansion and pre-configuration).

So it becomes possible to configure some global crate properties even for fully unconfigured crates.

Fixes https://github.com/rust-lang/rust/issues/104633
Part of https://github.com/rust-lang/rust/issues/110082
2023-06-10 11:20:09 +02:00
Urgau
3e91349c42 Uplift improved version of clippy::cmp_nan to rustc 2023-06-10 11:12:55 +02:00
许杰友 Jieyou Xu (Joe)
80176a120e
Adjust span labels for HIDDEN_GLOB_REEXPORTS 2023-06-10 17:11:38 +08:00
bors
d0ee1908ed Auto merge of #112452 - MU001999:fix/issue-112439, r=petrochenkov
Make "consider importing" consistent for macros

Fixes #112439
2023-06-10 05:07:53 +00:00
bors
29611778b7 Auto merge of #112426 - Bryanskiy:full_priv_ev, r=petrochenkov
increase the accuracy of effective visibilities calculation

Effective visibilities are calculated lazily due to performance restrictions.  Therefore

- crate should be walked at least 1 time in `compute_effective_visibilities` pass
- Impl's should always be in the effective visibilities table

to ensure that the table is filled in correctly.

r? `@petrochenkov`
2023-06-10 02:16:24 +00:00
Michael Goulet
3152ac34bd Ignore tests that hang in new solver 2023-06-09 21:57:37 +00:00
Vadim Petrochenkov
46becfdf9c expand: Change how #![cfg(FALSE)] behaves on crate root
Previously it removed all other attributes from the crate root.
Now it removes only attributes below itself.

So it becomes possible to configure some global crate properties even for fully unconfigured crates.
2023-06-10 00:35:21 +03:00
bors
43062c43d2 Auto merge of #112216 - est31:offset_of_deep_tuple, r=petrochenkov
Support float-like tuple indices in offset_of!()

Supports invocations like `offset_of!((((), ()), ()), 0.0)`. This `0.0` gets tokenized as float literal, so it has to be broken up again.

The code that did the breaking up was returning a finished `Expr`, while we need a `Ident`, so this PR splits up the `parse_expr_tuple_field_access_float` function into:

* a function that breaks up the float literal (similar to `TokenKind::break_two_token_op`, but we do access the parser during this splitting operation, so we keep it as an inherent function on the parser)
* and a function that constructs an `Expr` from it

The former we can then re-use in `offset_of` parsing. The edge cases especially involving whitespaces are tricky so this adds a bunch of new tests as well.

fixes #112204
2023-06-09 18:53:58 +00:00
Mu001999
5bd8ba8493 Make "consider importing" consistent for macros 2023-06-10 00:06:34 +08:00
bors
397641f3bd Auto merge of #112465 - GuillaumeGomez:rollup-gyh5buc, r=GuillaumeGomez
Rollup of 3 pull requests

Successful merges:

 - #112260 (Improve document of `unsafe_code` lint)
 - #112429 ([rustdoc] List matching impls on type aliases)
 - #112442 (Deduplicate identical region constraints in new solver)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-09 15:37:22 +00:00
Guillaume Gomez
9803651ee8 Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
Guillaume Gomez
4ef7257018
Rollup merge of #112442 - compiler-errors:next-solver-deduplicate-region-constraints, r=lcnr
Deduplicate identical region constraints in new solver

the new solver doesn't track whether we've already proven a goal like the fulfillment context's obligation forest does, so we may be instantiating a canonical response (and specifically, its nested region obligations) quite a few times.

This may lead to exponentially gathering up identical region constraints for things like auto traits, so let's deduplicate region constraints when in `compute_external_query_constraints`.

r? ``@lcnr``
2023-06-09 16:29:02 +02:00
Guillaume Gomez
f83c8e4317
Rollup merge of #112429 - GuillaumeGomez:ty-alias-impls, r=notriddle,lcnr
[rustdoc] List matching impls on type aliases

Fixes #32077.

Thanks a lot to ``@lcnr`` who helped me a lot with this fix!

cc ``@notriddle``
r? ``@lcnr``
2023-06-09 16:29:01 +02:00
bors
d7ad9d9797 Auto merge of #111530 - Urgau:uplift_undropped_manually_drops, r=compiler-errors
Uplift `clippy::undropped_manually_drops` lint

This PR aims at uplifting the `clippy::undropped_manually_drops` lint.

## `undropped_manually_drops`

(warn-by-default)

The `undropped_manually_drops` lint check for calls to `std::mem::drop` with a value of `std::mem::ManuallyDrop` which doesn't drop.

### Example

```rust
struct S;
drop(std::mem::ManuallyDrop::new(S));
```

### Explanation

`ManuallyDrop` does not drop it's inner value so calling `std::mem::drop` will not drop the inner value of the `ManuallyDrop` either.

-----

Mostly followed the instructions for uplifting an clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

`@rustbot` label: +I-lang-nominated
r? compiler

-----

For Clippy:

changelog: Moves: Uplifted `clippy::undropped_manually_drops` into rustc
2023-06-09 12:44:23 +00:00
bors
343ad6f059 Auto merge of #111626 - pjhades:output, r=b-naber
Write to stdout if `-` is given as output file

With this PR, if `-o -` or `--emit KIND=-` is provided, output will be written to stdout instead. Binary output (those of type `obj`, `llvm-bc`, `link` and `metadata`) being written this way will result in an error unless stdout is not a tty. Multiple output types going to stdout will trigger an error too, as they will all be mixded together.

This implements https://github.com/rust-lang/compiler-team/issues/431

The idea behind the changes is to introduce an `OutFileName` enum that represents the output - be it a real path or stdout - and to use this enum along the code paths that handle different output types.
2023-06-09 09:45:40 +00:00
Guillaume Gomez
6f552c800b Add regression test for #32077 2023-06-09 10:36:22 +02:00
bors
dcc9028c0c Auto merge of #112450 - matthiaskrgr:rollup-fdbazkr, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #112323 (Don't mention already-set fields in struct constructor missing field error)
 - #112395 (Add Terminator::InlineAsm conversion from MIR to SMIR)
 - #112411 (add programmerjake to portable-simd cc list)
 - #112428 (Structurally resolve pointee in `check_pat_lit`)
 - #112444 (Don't debug-print `Interned` or `PrivateZst`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-09 06:38:22 +00:00
Matthias Krüger
a4490b18a7
Rollup merge of #112428 - compiler-errors:next-solver-struct-resolv-pat, r=lcnr
Structurally resolve pointee in `check_pat_lit`

Gotta make sure to eager norm the pointee of the match scrutinee with the new solver.

r? ``@lcnr``
2023-06-09 08:15:57 +02:00
Matthias Krüger
17cc282880
Rollup merge of #112323 - compiler-errors:dont-mention-set-fields, r=WaffleLapkin
Don't mention already-set fields in struct constructor missing field error

Fixes #111149
2023-06-09 08:15:55 +02:00
bors
9c843d9fa3 Auto merge of #112116 - compiler-errors:misc-hir-typeck-mismatch-tweaks, r=WaffleLapkin
Misc HIR typeck type mismatch tweaks

These are all intended to improve #112104, but I couldn't get it to actually suggest adding `as_ref` to the LHS of the equality expr without some hacks that I may play around with some more.

Each commit's title should explain what it's doing except for perhaps the last one, which addresses the bogus suggestion on #112104 itself.
2023-06-09 03:20:22 +00:00
Michael Goulet
d5e25d40c9 deduplicate identical region constraints 2023-06-08 23:38:07 +00:00
est31
1b90f5efaf Support float-like tuple indices in offset_of!()
The tokenizer gives us whole float literal tokens, we have to split them up
in order to be able to create field access from them.
2023-06-08 23:42:58 +02:00
bors
8b35c0bb0f Auto merge of #112068 - WaffleLapkin:move-discrim-tests, r=compiler-errors
Move tests from `ui/discrim` dir

It seems that we already have a `enum-discriminant` with more tests, so it makes sense to merge them.
2023-06-08 21:06:43 +00:00
Michael Goulet
a9188226a8 Peel borrows before suggesting as_ref/as_deref 2023-06-08 16:30:05 +00:00
Michael Goulet
c92140e838 Don't suggest cyclic associated type constraint 2023-06-08 16:30:05 +00:00
Michael Goulet
acf257e62c Point at correct exprs for assert_eq type mismatch 2023-06-08 16:30:05 +00:00
Michael Goulet
af54d584b2 More robust as_ref/as_deref suggestions 2023-06-08 16:30:05 +00:00
Bryanskiy
5e917a6039 increase the accuracy of effective visibilities calculation 2023-06-08 19:22:30 +03:00
Michael Goulet
522ae84e03 Suggest type mismatches even when using ref syntax on binding 2023-06-08 16:17:30 +00:00
bors
a77659a1e1 Auto merge of #112420 - matthiaskrgr:rollup-spiavw5, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #109953 (Use 128 bits for TypeId hash)
 - #112333 (Don't hold the active queries lock while calling `make_query`)
 - #112339 (Fix rust-analyzer proc macro server)
 - #112410 (Do `fix_*_builtin_expr` hacks on the writeback results)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-08 13:30:52 +00:00
Maybe Waffle
70f28a9110 Move tests from ui/discrim dir 2023-06-08 12:33:17 +00:00
Matthias Krüger
909bfa31ed
Rollup merge of #112410 - compiler-errors:writeback, r=lcnr
Do `fix_*_builtin_expr` hacks on the writeback results

During writeback, we do `fix_{scalar,index}_builtin_expr` so that during MIR build we generate built-in MIR instructions instead of method calls for certain built-in arithmetic operations. We do this by checking the types of these built-in operations are scalar types, and remove the method def-id to essentially mark the operation as built-in and not "overloaded".

For lazy norm and the new trait solver, this is a problem, because we don't actually normalize all the types we end up seeing in the typeck results until they're copied over writeback's copy of the typeck results. To fix this, delay these fixup calls until after this normalization has been done.

This doesn't affect the old trait solver, but does simplify the code a bit IMO, since we can remove a few sets of calls to `resolve_vars_if_possible` and some `borrow_mut`s.

r? `@lcnr`
2023-06-08 12:36:19 +02:00
bors
e7409258db Auto merge of #112415 - GuillaumeGomez:rollup-5pa9frd, r=GuillaumeGomez
Rollup of 9 pull requests

Successful merges:

 - #112034 (Migrate `item_opaque_ty` to Askama)
 - #112179 (Avoid passing --cpu-features when empty)
 - #112309 (bootstrap: remove dependency `is-terminal`)
 - #112388 (Migrate GUI colors test to original CSS color format)
 - #112389 (Add a test for #105709)
 - #112392 (Fix ICE for while loop with assignment condition with LHS place expr)
 - #112394 (Remove accidental comment)
 - #112396 (Track more diagnostics in `rustc_expand`)
 - #112401 (Don't `use compile_error as print`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-08 10:31:52 +00:00
Urgau
52300bf8d8 Uplift clippy::undropped_manually_drops to rustc 2023-06-08 11:41:34 +02:00
Guillaume Gomez
80829ceaa7
Rollup merge of #112392 - jieyouxu:issue-112385, r=compiler-errors
Fix ICE for while loop with assignment condition with LHS place expr

Fixes #112385.
2023-06-08 10:15:12 +02:00
Guillaume Gomez
5b7eba6a29
Rollup merge of #112389 - TaKO8Ki:issue-105709, r=compiler-errors
Add a test for #105709

Closes #105709
2023-06-08 10:15:11 +02:00
Guillaume Gomez
53ee185855
Rollup merge of #112388 - GuillaumeGomez:migrate-gui-test-color-12, r=notriddle
Migrate GUI colors test to original CSS color format

Follow-up of https://github.com/rust-lang/rust/pull/111459.

r? `@notriddle`
2023-06-08 10:15:11 +02:00
bors
a0df04c0f2 Auto merge of #110040 - ndrewxie:issue-84447-partial-1, r=lcnr,michaelwoerister
Removed use of iteration through a HashMap/HashSet in rustc_incremental and replaced with IndexMap/IndexSet

This allows for the `#[allow(rustc::potential_query_instability)]` in rustc_incremental to be removed, moving towards fixing #84447 (although a LOT more modules have to be changed to fully resolve it). Only HashMaps/HashSets that are being iterated through have been modified (although many structs and traits outside of rustc_incremental had to be modified as well, as they had fields/methods that involved a HashMap/HashSet that would be iterated through)

I'm making a PR for just 1 module changed to test for performance regressions and such, for future changes I'll either edit this PR to reflect additional modules being converted, or batch multiple modules of changes together and make a PR for each group of modules.
2023-06-08 07:30:03 +00:00
Takayuki Maeda
5e57e27d7a add a test for #105709
replace build with check

Co-authored-by: Michael Goulet <michael@errs.io>

use appropriate test name
2023-06-08 15:24:09 +09:00
Michael Goulet
54fb5a48b9 Structurally resolve correctly in check_pat_lit 2023-06-08 04:22:47 +00:00
Michael Goulet
8efcb28d3c Do fix_*_builtin_expr hacks on the writeback results 2023-06-08 03:21:13 +00:00
许杰友 Jieyou Xu (Joe)
adbfd0da68
Fix ICE for while loop with assignment condition with LHS place expr 2023-06-08 02:38:12 +08:00
bors
a97c36dd2e Auto merge of #109005 - Nilstrieb:dont-forgor-too-much-from-cfg, r=petrochenkov
Remember names of `cfg`-ed out items to mention them in diagnostics

# Examples

## `serde::Deserialize` without the `derive` feature (a classic beginner mistake)

I had to slightly modify serde so that it uses explicit re-exports instead of a glob re-export. (Update: a serde PR was merged that adds the manual re-exports)

```
error[E0433]: failed to resolve: could not find `Serialize` in `serde`
   --> src/main.rs:1:17
    |
1   | #[derive(serde::Serialize)]
    |                 ^^^^^^^^^ could not find `Serialize` in `serde`
    |
note: crate `serde` has an item named `Serialize` but it is inactive because its cfg predicate evaluated to false
   --> /home/gh-Nilstrieb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.160/src/lib.rs:343:1
    |
343 | #[cfg(feature = "serde_derive")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
344 | pub use serde_derive::{Deserialize, Serialize};
    |                                     ^^^^^^^^^
    = note: the item is gated behind the `serde_derive` feature
    = note: see https://doc.rust-lang.org/cargo/reference/features.html for how to activate a crate's feature
```
(the suggestion is not ideal but that's serde's fault)

I already tested the metadata size impact locally by compiling the `windows` crate without any features. `800k`  -> `809k`

r? `@ghost`
2023-06-07 17:38:57 +00:00
Guillaume Gomez
3522baa8ba Migrate GUI colors test to original CSS color format 2023-06-07 17:42:04 +02:00
Dylan DPC
42cf6da6af
Rollup merge of #112345 - bvanjoi:fix-112342, r=nilstrieb,est31
fix(expand): prevent infinity loop in macro containing only "///"

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

Issue #112342 was caused by an infinity loop in `parse_tt_inner`, and the state of it is as follows:

- `matcher`: `[Sequence, Token(Doc), SequenceKleeneOpNoSep(op: ZeroOrMore), Eof]`

-  loop:

| Iteration | Action |
| - | - |
| 0   |  enter `Sequence`|
| 1    |  enter `Token(Doc)` and `mp.idx += 1` had been executed |
| 2   |  enter `SequenceKleeneOpNoSep` and reset `mp.idx` to `1` |
| 3   | enter `Token(Doc)` again|

To prevent the infinite loop, a check for whether it only contains `DocComment` in `check_lhs_no_empty_seq` had been added.
2023-06-07 18:01:30 +05:30