Commit Graph

240784 Commits

Author SHA1 Message Date
Urgau
3f0369e0f2 Remove deprecated --check-cfg names() and values() syntax 2023-12-05 13:25:11 +01:00
Urgau
9a942390bf Update unexpected_cfgs lint definition with new syntax and diagnostics 2023-12-05 13:25:11 +01:00
Urgau
9b4fe38903 Use new check-cfg syntax in rustc_llvm build script 2023-12-05 13:25:11 +01:00
Urgau
801bc561bc Update bootstrap libc to 0.2.150
Version 0.2.150 include support for the new check-cfg syntax
2023-12-05 13:25:11 +01:00
bors
154f645d76 Auto merge of #118362 - RalfJung:panic_nounwind, r=thomcc
make sure panic_nounwind_fmt can still be fully inlined (e.g. for panic_immediate_abort)

Follow-up to https://github.com/rust-lang/rust/pull/110303.
2023-12-05 12:05:22 +00:00
Igor Matuszewski
a0ba895f2d
bootstrap(builder.rs): Don't explicitly warn against semicolon_in_expressions_from_macros
This already wasn't passed in bootstrap.py and the lint itself already warns-by-default for 2 years now and has already been added to the future-incompat group in Rust 1.68.

See https://github.com/rust-lang/rust/issues/79813 for the tracking issue.
2023-12-05 12:11:29 +01:00
Scott Mabin
1a7b610da3 Add riscv32 imafc bare metal target
- riscv32imac-unknown-none-elf
- Add platform support docs for rv32
2023-12-05 11:05:52 +00:00
long-long-float
15a8e9d59b Fix x not to quit when x prints settings.json
Use `while` instead of `loop`

Co-authored-by: Onur Özkan <onurozkan.dev@outlook.com>

Update prompt message
2023-12-05 19:39:06 +09:00
Zalathar
242bff3cda coverage: Be more strict about what counts as a "visible macro" 2023-12-05 21:21:05 +11:00
Zalathar
ff3af59f2b coverage: Clean up maybe_push_macro_name_span 2023-12-05 21:21:05 +11:00
bors
f536185ed8 Auto merge of #118640 - RalfJung:miri, r=RalfJung
Miri subtree update

needed to fix some errors in miri-test-libstd
2023-12-05 08:32:36 +00:00
Harold Dost
1b503042b8 Remove mention of rust to make the error message generic.
The deprecation notice is used when in crates as well. This applies to versions Rust or Crates.

Fixes #118148

Signed-off-by: Harold Dost <h.dost@criteo.com>
2023-12-05 09:18:41 +01:00
bors
73db2e48d7 Auto merge of #3211 - RalfJung:promise, r=RalfJung
fix promising a very large alignment

Also make use of https://github.com/rust-lang/rust/pull/118565 to simplify some SIMD intrinsics, while we are at it
2023-12-05 07:12:28 +00:00
Ralf Jung
1fa8fd800f simd numeric intrinsics: share code with scalar intrinsic 2023-12-05 07:42:13 +01:00
Ralf Jung
ff95f8b872 fix miri_promise_symbolic_alignment for huge alignments 2023-12-05 07:39:52 +01:00
bors
f67523d0b3 Auto merge of #118076 - estebank:issue-109429, r=davidtwco
Tweak `.clone()` suggestion to work in more cases

When going through auto-deref, the `<T as Clone>` impl sometimes needs to be specified for rustc to actually clone the value and not the reference.

```
error[E0507]: cannot move out of dereference of `S`
  --> $DIR/needs-clone-through-deref.rs:15:18
   |
LL |         for _ in self.clone().into_iter() {}
   |                  ^^^^^^^^^^^^ ----------- value moved due to this method call
   |                  |
   |                  move occurs because value has type `Vec<usize>`, which does not implement the `Copy` trait
   |
note: `into_iter` takes ownership of the receiver `self`, which moves value
  --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
help: you can `clone` the value and consume it, but this might not be your desired behavior
   |
LL |         for _ in <Vec<usize> as Clone>::clone(&self.clone()).into_iter() {}
   |                  ++++++++++++++++++++++++++++++            +
```

When encountering a move error, look for implementations of `Clone` for the moved type. If there is one, check if all its obligations are met. If they are, we suggest cloning without caveats. If they aren't, we suggest cloning while mentioning the unmet obligations, potentially suggesting `#[derive(Clone)]` when appropriate.

```
error[E0507]: cannot move out of a shared reference
  --> $DIR/suggest-clone-when-some-obligation-is-unmet.rs:20:28
   |
LL |     let mut copy: Vec<U> = map.clone().into_values().collect();
   |                            ^^^^^^^^^^^ ------------- value moved due to this method call
   |                            |
   |                            move occurs because value has type `HashMap<T, U, Hash128_1>`, which does not implement the `Copy` trait
   |
note: `HashMap::<K, V, S>::into_values` takes ownership of the receiver `self`, which moves value
  --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
help: you could `clone` the value and consume it, if the `Hash128_1: Clone` trait bound could be satisfied
   |
LL |     let mut copy: Vec<U> = <HashMap<T, U, Hash128_1> as Clone>::clone(&map.clone()).into_values().collect();
   |                            ++++++++++++++++++++++++++++++++++++++++++++           +
help: consider annotating `Hash128_1` with `#[derive(Clone)]`
   |
LL + #[derive(Clone)]
LL | pub struct Hash128_1;
   |
```

Fix #109429.

When encountering multiple mutable borrows, suggest cloning and adding
derive annotations as needed.

```
error[E0596]: cannot borrow `sm.x` as mutable, as it is behind a `&` reference
  --> $DIR/accidentally-cloning-ref-borrow-error.rs:32:9
   |
LL |     foo(&mut sm.x);
   |         ^^^^^^^^^ `sm` is a `&` reference, so the data it refers to cannot be borrowed as mutable
   |
help: `Str` doesn't implement `Clone`, so this call clones the reference `&Str`
  --> $DIR/accidentally-cloning-ref-borrow-error.rs:31:21
   |
LL |     let mut sm = sr.clone();
   |                     ^^^^^^^
help: consider annotating `Str` with `#[derive(Clone)]`
   |
LL + #[derive(Clone)]
LL | struct Str {
   |
help: consider specifying this binding's type
   |
LL |     let mut sm: &mut Str = sr.clone();
   |               ++++++++++
```

Fix #34629. Fix #76643. Fix #91532.
2023-12-05 06:34:44 +00:00
Ralf Jung
6237f2381d fix typo in comment 2023-12-05 07:32:49 +01:00
l00846161
3f8487a099 Add safe compilation options
Add two options when building rust: strip and stack protector.
If set `strip = true`, symbols will be stripped using `-Cstrip=symbols`.
Also can set `stack-protector` and stack protectors will be used.
2023-12-05 14:22:08 +08:00
bors
88d905cb3a Auto merge of #3210 - rust-lang:rustup-2023-12-05, r=RalfJung
Automatic Rustup
2023-12-05 06:19:41 +00:00
Martin Nordholts
d7d867d9a4 rustc_symbol_mangling: Address all rustc::potential_query_instability lints
Instead of allowing `rustc::potential_query_instability` on the whole
crate we go over each lint and allow it individually if it is safe to
do. Turns out there were no instances of this lint in this crate.
2023-12-05 06:41:23 +01:00
Martin Nordholts
ae2427d1e4 rustc_interface: Address all rustc::potential_query_instability lints
Instead of allowing `rustc::potential_query_instability` on the whole
crate we go over each lint and allow it individually if it is safe to
do. Turns out all instances were safe to allow in this crate.
2023-12-05 06:33:38 +01:00
Nicholas Nethercote
35ac2816a0 Factor out some repeated code. 2023-12-05 16:24:23 +11:00
Martin Nordholts
0e3e16cb5e rustc_driver_impl: Address all rustc::potential_query_instability lints
Instead of allowing `rustc::potential_query_instability` on the whole
crate we go over each lint and allow it individually if it is safe to
do. Turns out there were no instances of this lint in this crate.
2023-12-05 06:19:14 +01:00
The Miri Conjob Bot
0d5fdcca6c fmt 2023-12-05 05:17:10 +00:00
The Miri Conjob Bot
cf1ef1300e Merge from rustc 2023-12-05 05:15:52 +00:00
The Miri Conjob Bot
d651eb9e23 Preparing for merge from rustc 2023-12-05 05:09:34 +00:00
bors
9358642e3b Auto merge of #118066 - estebank:structured-use-suggestion, r=b-naber
Structured `use` suggestion on privacy error

When encoutering a privacy error on an item through a re-export that is accessible in an alternative path, provide a structured suggestion with that path.

```
error[E0603]: module import `mem` is private
  --> $DIR/private-std-reexport-suggest-public.rs:4:14
   |
LL |     use foo::mem;
   |              ^^^ private module import
   |
note: the module import `mem` is defined here...
  --> $DIR/private-std-reexport-suggest-public.rs:8:9
   |
LL |     use std::mem;
   |         ^^^^^^^^
note: ...and refers to the module `mem` which is defined here
  --> $SRC_DIR/std/src/lib.rs:LL:COL
   |
   = note: you could import this
help: import `mem` through the re-export
   |
LL |     use std::mem;
   |         ~~~~~~~~
```

Fix #42909.
2023-12-05 04:34:57 +00:00
Celina G. Val
1720b108f7 Add FieldDef to StableMIR and methods to get type 2023-12-04 20:08:25 -08:00
bors
317d14a56c Auto merge of #118230 - nnethercote:streamline-dataflow-cursors, r=cjgillot
Streamline MIR dataflow cursors

`rustc_mir_dataflow` has two kinds of results (`Results` and `ResultsCloned`) and three kinds of results cursor (`ResultsCursor`, `ResultsClonedCursor`, `ResultsRefCursor`). I found this quite confusing.

This PR removes `ResultsCloned`, `ResultsClonedCursor`, and `ResultsRefCursor`, leaving just `Results` and `ResultsCursor`. This makes the relevant code shorter and easier to read, and there is no performance penalty.

r? `@cjgillot`
2023-12-05 02:36:50 +00:00
Deadbeef
65212a07e7 Remove #[rustc_host], use internal desugaring 2023-12-05 01:15:21 +00:00
Eric Holk
2c8dbd959f
Fix build 2023-12-04 16:46:45 -08:00
bors
25dca40751 Auto merge of #117088 - lcnr:generalize-alias, r=compiler-errors
generalize: handle occurs check failure in aliases

mostly fixes #105787, except for the `for<'a> fn(<<?x as OtherTrait>::Assoc as Trait<'a>>::Assoc) eq ?x` case in https://github.com/rust-lang/trait-system-refactor-initiative/issues/8.

r? `@compiler-errors`
2023-12-05 00:37:58 +00:00
Eric Holk
ac4d0f240f
Update doctest 2023-12-04 16:37:45 -08:00
DianQK
ca0738f981
Consider only #[no_mangle] as builtin functions 2023-12-05 07:50:14 +08:00
Eric Holk
09f0741449
Remove bad merge 2023-12-04 14:38:10 -08:00
Eric Holk
50ef8006eb
Address code review feedback 2023-12-04 14:33:46 -08:00
bors
da1da3f1a0 Auto merge of #118618 - GuillaumeGomez:rollup-24ur21r, r=GuillaumeGomez
Rollup of 4 pull requests

Successful merges:

 - #118508 (rustdoc: do not escape quotes in body text)
 - #118565 (interpret: make numeric_intrinsic accessible from Miri)
 - #118591 (portable-simd: fix test suite build)
 - #118600 ([rustdoc] Don't generate the "Fields" heading if there is no field displayed)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-04 22:26:41 +00:00
Esteban Küber
beaf31581a Structured use suggestion on privacy error
When encoutering a privacy error on an item through a re-export that is
accessible in an alternative path, provide a structured suggestion with
that path.

```
error[E0603]: module import `mem` is private
  --> $DIR/private-std-reexport-suggest-public.rs:4:14
   |
LL |     use foo::mem;
   |              ^^^ private module import
   |
note: the module import `mem` is defined here...
  --> $DIR/private-std-reexport-suggest-public.rs:8:9
   |
LL |     use std::mem;
   |         ^^^^^^^^
note: ...and refers to the module `mem` which is defined here
  --> $SRC_DIR/std/src/lib.rs:LL:COL
   |
   = note: you could import this
help: import `mem` through the re-export
   |
LL |     use std::mem;
   |         ~~~~~~~~
```

Fix #42909.
2023-12-04 22:26:08 +00:00
Esteban Küber
a8faa8288c Fix rebase 2023-12-04 22:00:34 +00:00
Esteban Küber
cc80106cb5 Provide more suggestions for cloning immutable bindings
When encountering multiple mutable borrows, suggest cloning and adding
derive annotations as needed.

```
error[E0596]: cannot borrow `sm.x` as mutable, as it is behind a `&` reference
  --> $DIR/accidentally-cloning-ref-borrow-error.rs:32:9
   |
LL |     foo(&mut sm.x);
   |         ^^^^^^^^^ `sm` is a `&` reference, so the data it refers to cannot be borrowed as mutable
   |
help: `Str` doesn't implement `Clone`, so this call clones the reference `&Str`
  --> $DIR/accidentally-cloning-ref-borrow-error.rs:31:21
   |
LL |     let mut sm = sr.clone();
   |                     ^^^^^^^
help: consider annotating `Str` with `#[derive(Clone)]`
   |
LL + #[derive(Clone)]
LL | struct Str {
   |
help: consider specifying this binding's type
   |
LL |     let mut sm: &mut Str = sr.clone();
   |               ++++++++++
```

```
error[E0596]: cannot borrow `*inner` as mutable, as it is behind a `&` reference
  --> $DIR/issue-91206.rs:14:5
   |
LL |     inner.clear();
   |     ^^^^^ `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable
   |
help: you can `clone` the `Vec<usize>` value and consume it, but this might not be your desired behavior
  --> $DIR/issue-91206.rs:11:17
   |
LL |     let inner = client.get_inner_ref();
   |                 ^^^^^^^^^^^^^^^^^^^^^^
help: consider specifying this binding's type
   |
LL |     let inner: &mut Vec<usize> = client.get_inner_ref();
   |              +++++++++++++++++
```
2023-12-04 21:54:34 +00:00
Esteban Küber
210a672005 Deduplicate some logic 2023-12-04 21:54:33 +00:00
Esteban Küber
a754fcaa43 On "this .clone() is on the reference", provide more info
When encountering a case where `let x: T = (val: &T).clone();` and
`T: !Clone`, already mention that the reference is being cloned. We now
also suggest `#[derive(Clone)]` not only on `T` but also on type
parameters to satisfy blanket implementations.

```
error[E0308]: mismatched types
  --> $DIR/assignment-of-clone-call-on-ref-due-to-missing-bound.rs:17:39
   |
LL |             let mut x: HashSet<Day> = v.clone();
   |                        ------------   ^^^^^^^^^ expected `HashSet<Day>`, found `&HashSet<Day>`
   |                        |
   |                        expected due to this
   |
   = note: expected struct `HashSet<Day>`
           found reference `&HashSet<Day>`
note: `HashSet<Day>` does not implement `Clone`, so `&HashSet<Day>` was cloned instead
  --> $DIR/assignment-of-clone-call-on-ref-due-to-missing-bound.rs:17:39
   |
LL |             let mut x: HashSet<Day> = v.clone();
   |                                       ^
   = help: `Clone` is not implemented because the trait bound `Day: Clone` is not satisfied
help: consider annotating `Day` with `#[derive(Clone)]`
   |
LL + #[derive(Clone)]
LL | enum Day {
   |
```

Case taken from # #41825.
2023-12-04 21:54:33 +00:00
Esteban Küber
1c69c6ab08 Mark more tests as run-rustfix 2023-12-04 21:54:32 +00:00
Esteban Küber
90db536741 Tweak output on specific case 2023-12-04 21:54:32 +00:00
Esteban Küber
98cfed7b97 Suggest cloning and point out obligation errors on move error
When encountering a move error, look for implementations of `Clone` for
the moved type. If there is one, check if all its obligations are met.
If they are, we suggest cloning without caveats. If they aren't, we
suggest cloning while mentioning the unmet obligations, potentially
suggesting `#[derive(Clone)]` when appropriate.

```
error[E0507]: cannot move out of a shared reference
  --> $DIR/suggest-clone-when-some-obligation-is-unmet.rs:20:28
   |
LL |     let mut copy: Vec<U> = map.clone().into_values().collect();
   |                            ^^^^^^^^^^^ ------------- value moved due to this method call
   |                            |
   |                            move occurs because value has type `HashMap<T, U, Hash128_1>`, which does not implement the `Copy` trait
   |
note: `HashMap::<K, V, S>::into_values` takes ownership of the receiver `self`, which moves value
  --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
help: you could `clone` the value and consume it, if the `Hash128_1: Clone` trait bound could be satisfied
   |
LL |     let mut copy: Vec<U> = <HashMap<T, U, Hash128_1> as Clone>::clone(&map.clone()).into_values().collect();
   |                            ++++++++++++++++++++++++++++++++++++++++++++           +
help: consider annotating `Hash128_1` with `#[derive(Clone)]`
   |
LL + #[derive(Clone)]
LL | pub struct Hash128_1;
   |
```

Fix #109429.
2023-12-04 21:54:32 +00:00
Esteban Küber
03c88aaf21 Tweak .clone() suggestion to work in more cases
When going through auto-deref, the `<T as Clone>` impl sometimes needs
to be specified for rustc to actually clone the value and not the
reference.

```
error[E0507]: cannot move out of dereference of `S`
  --> $DIR/needs-clone-through-deref.rs:15:18
   |
LL |         for _ in self.clone().into_iter() {}
   |                  ^^^^^^^^^^^^ ----------- value moved due to this method call
   |                  |
   |                  move occurs because value has type `Vec<usize>`, which does not implement the `Copy` trait
   |
note: `into_iter` takes ownership of the receiver `self`, which moves value
  --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
help: you can `clone` the value and consume it, but this might not be your desired behavior
   |
LL |         for _ in <Vec<usize> as Clone>::clone(&self.clone()).into_iter() {}
   |                  ++++++++++++++++++++++++++++++            +
```

CC #109429.
2023-12-04 21:54:32 +00:00
Eric Holk
26f9954971
Fix some broken tests 2023-12-04 13:03:41 -08:00
Eric Holk
f9d1f922dc
Option<CoroutineKind> 2023-12-04 13:03:37 -08:00
Eric Holk
48d5f1f0f2
Merge Async and Gen into CoroutineKind 2023-12-04 12:48:01 -08:00
Guillaume Gomez
baa3f96b42
Rollup merge of #118600 - GuillaumeGomez:fields-heading, r=notriddle
[rustdoc] Don't generate the "Fields" heading if there is no field displayed

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

If no field is displayed, we should not generate the `Fields` heading in enum struct variants.

r? ``@notriddle``
2023-12-04 20:46:10 +01:00