Commit Graph

240440 Commits

Author SHA1 Message Date
Nicholas Nethercote
c5408b6617 Remove unused FileMatch. 2023-11-30 17:05:56 +11:00
Nicholas Nethercote
99ac405b96 Move MetadataLoader{,Dyn} to rustc_metadata.
They're not used in `rustc_session`, and `rustc_metadata` is a more
obvious location.

`MetadataLoader` was originally put into `rustc_session` in #41565 to
avoid a dependency on LLVM, but things have changed a lot since then and
that's no longer relevant, e.g. `rustc_codegen_llvm` depends on
`rustc_metadata`.
2023-11-30 17:05:54 +11:00
Nicholas Nethercote
3521abde39 Reorder some use items. 2023-11-30 16:59:28 +11:00
Nicholas Nethercote
866aa2db66 Remove unused features. 2023-11-30 16:59:22 +11:00
bors
e55544c804 Auto merge of #118379 - compiler-errors:const-params-for-partialeq, r=fee1-dead
Fix `PartialEq` args when `#[const_trait]` is enabled

This is based off of your PR that enforces effects on all methods, so just see the last commits.

r? fee1-dead
2023-11-30 05:24:53 +00:00
Nine
605381ad47 Capitalize ToC in README.md 2023-11-29 23:03:31 -06:00
Nine
b80d0749f4 Fix typo in README.md 2023-11-29 23:02:47 -06:00
bors
74fccd0b50 Auto merge of #117565 - estebank:issue-100825, r=Nilstrieb
Tweak parsing recovery of enums, for exprs and match arm patterns

Tweak recovery of `for (pat in expr) {}` for more accurate spans.

When encountering `match` arm `(pat if expr) => {}`, recover and suggest removing parentheses. Fix #100825.

When encountering malformed enums, try more localized per-variant parse recovery.

Move parser recovery tests to subdirectory.
2023-11-30 02:14:01 +00:00
Wesley Wiser
1011078715 Update compiler/rustc_codegen_llvm/src/lib.rs
Co-authored-by: Josh Stone <cuviper@gmail.com>
2023-11-29 18:12:53 -06:00
Wesley Wiser
3323e4dc04 Dispose llvm::TargetMachines prior to llvm::Context being disposed
If the TargetMachine is disposed after the Context is disposed, it can
lead to use after frees in some cases.

I've observed this happening occasionally on code compiled for
aarch64-pc-windows-msvc using `-Zstack-protector=strong` but other users
have reported AVs from host aarch64-pc-windows-msvc compilers as well.
2023-11-29 18:12:53 -06:00
bors
c9c760fc20 Auto merge of #114499 - taiki-e:riscv-forced-atomics, r=Amanieu
Pass +forced-atomics feature for riscv32{i,im,imc}-unknown-none-elf

As said in https://github.com/rust-lang/rust/pull/98333#issuecomment-1666375293, `forced-atomics` target feature is also needed to enable atomic load/store on these targets (otherwise, libcalls are generated): https://godbolt.org/z/433qeG7vd

~~This PR is currently marked as a draft because:~~
- ~~`forced-atomics` target feature is currently broken (https://github.com/rust-lang/rust/issues/114153).~~ EDIT: Fixed
- ~~`forced-atomics` target feature has been added in LLVM 16 (f5ed0cb217), but the current minimum LLVM version [is 15](90f0b24ad3/src/bootstrap/llvm.rs (L557)). In LLVM 15, the atomic load/store of these targets generates libcalls anyway.~~ EDIT: LLVM 15 has been dropped

Depending on the policy on the minimum LLVM version for these targets, this may be blocked until the minimum LLVM version is increased to 16.

r? `@Amanieu`
2023-11-30 00:10:11 +00:00
Eric Huss
b07e3160a0 Update mdbook to 0.4.36 2023-11-29 15:52:16 -08:00
bors
475f6f85a8 Auto merge of #118454 - lcnr:overflow-yay, r=compiler-errors
new solver: improve instrument annotations
2023-11-29 22:11:41 +00:00
Michael Howell
c910a49b05 rustdoc: remove small from small-section-header
There's no such thing as a big section header, so I don't know why the
name was used.
2023-11-29 13:40:07 -07:00
Esteban Küber
25c75bc156 review comments and rebase fixes 2023-11-29 20:24:21 +00:00
Alona Enraght-Moony
32c035c8c8 rustc_span: Remove unused symbols. 2023-11-29 20:22:18 +00:00
Esteban Küber
dfe32b6a43 On Fn arg mismatch for a fn path, suggest a closure
When encountering a fn call that has a path to another fn being passed
in, where an `Fn` impl is expected, and the arguments differ, suggest
wrapping the argument with a closure with the appropriate arguments.
2023-11-29 18:55:00 +00:00
Esteban Küber
88453aaccf Avoid unnecessary pattern parse errors on ref box 2023-11-29 18:47:32 +00:00
Esteban Küber
cb0863475f fix rebase 2023-11-29 18:47:32 +00:00
Esteban Küber
4e524386e9 Always emit help when failing to parse enum variant 2023-11-29 18:47:32 +00:00
Esteban Küber
1575e6e96e review comment: rework parse_for_head to reduce branching 2023-11-29 18:47:32 +00:00
Esteban Küber
147faa54d5 Fix tidy 2023-11-29 18:47:32 +00:00
Esteban Küber
bd1feb8cef Fix test and move to more appropriate directory 2023-11-29 18:47:32 +00:00
Esteban Küber
0ff331bc78 Change how for (x in foo) {} is handled
Use the same approach used for match arm patterns.
2023-11-29 18:47:32 +00:00
Esteban Küber
c47318983b Account for (pat if expr) => {}
When encountering match arm (pat if expr) => {}, recover and suggest removing parentheses. Fix #100825.
2023-11-29 18:47:32 +00:00
Esteban Küber
db39068ad7 Change enum parse recovery 2023-11-29 18:47:31 +00:00
Esteban Küber
1994abed74 Bubble parse error when expecting ) 2023-11-29 18:47:31 +00:00
Esteban Küber
075c599188 More accurate span for unnecessary parens suggestion 2023-11-29 18:47:31 +00:00
Esteban Küber
ed084a9343 When parsing patterns, bubble all errors except reserved idents that aren't likely to appear in for head or match arm 2023-11-29 18:47:31 +00:00
Esteban Küber
44fd3b4d46 Make parse_pat_ident not recover bad name 2023-11-29 18:47:31 +00:00
Samuel Tardieu
e3c73f17ec option_if_let_else: do not trigger on expressions returning ()
Fix #11893

Trigerring on expressions returning `()` uses the arguments of the
`map_or_else()` rewrite only for their side effects. This does lead
to code which is harder to read than the original.
2023-11-29 19:38:02 +01:00
lcnr
0ec2bf3e0a new solver: improve instrument annotations 2023-11-29 19:27:04 +01:00
Esteban Küber
4be07075b3 Tweak message on ADT with private fields building
When trying to create an inaccessible ADT due to private fields, handle
the case when no fields were passed.

```
error: cannot construct `Foo` with struct literal syntax due to private fields
  --> $DIR/issue-76077.rs:8:5
   |
LL |     foo::Foo {};
   |     ^^^^^^^^
   |
   = note: private field `you_cant_use_this_field` that was not provided
```
2023-11-29 18:11:57 +00:00
Michael Howell
930cba8061 rustdoc-search: replace TAB/NL/LF with SP first
This way, most of the parsing code doesn't need to be designed to handle
it, since they should always be treated exactly the same anyhow.
2023-11-29 11:02:56 -07:00
Michael Howell
93f17117ed rustdoc-search: removed dead parser code
This is already covered by the normal unexpected char path.
2023-11-29 11:02:56 -07:00
Michael Howell
c28de27a73 rustdoc-search: allow :: and ::
This restriction made sense back when spaces separated function
parameters, but now that they separate path components, there's
no real ambiguity any more.

Additionally, the Rust language allows it.
2023-11-29 11:02:50 -07:00
bors
b10cfcd65f Auto merge of #118132 - onur-ozkan:stdlib-assertion-status-to-compiletest, r=wesleywiser
utilize stdlib debug assertion status in compiletest

Implemented a new flag `--with-debug-assertions` on compiletest to pass the stdlib debug assertion status from bootstrap.

Resolves #115171
2023-11-29 17:41:27 +00:00
belovdv
45e6342346 jobserver: check file descriptors 2023-11-29 18:00:03 +03:00
bors
abe34e9ab1 Auto merge of #118315 - WaffleLapkin:don't-repeat_byte, r=m-ou-se
Use `usize::repeat_u8` instead of implementing `repeat_byte` in `memchr.rs`

It's simpler that way and the tricks don't actually make a difference: https://godbolt.org/z/zrvYY1dGx
2023-11-29 13:39:19 +00:00
bors
8b0bf6423d Auto merge of #11818 - y21:more_redundant_guards, r=llogiq
[`redundant_guards`]: catch `is_empty`, `starts_with` and `ends_with` on slices and `str`s

Fixes #11807

Few things worth mentioning:
- Taking `snippet`s is now done at callsite, instead of passing a span and doing it in `emit_redundant_guards`. This is because we now need custom suggestion strings in certain places, like `""` for `str::is_empty`.
- This now uses `snippet` instead of `snippet_with_applicability`. I don't think this really makes any difference for `MaybeIncorrect`, though?
- This could also lint byte strings, as they're of type `&[u8; N]`, but that can be ugly so I decided to leave it out for now

changelog: [`redundant_guards`]: catch `str::is_empty`, `slice::is_empty`, `slice::starts_with` and `slice::ends_with`
2023-11-29 13:20:59 +00:00
bors
ce4727f723 Auto merge of #118443 - matthiaskrgr:rollup-mp8o3m4, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #118157 (Add `never_patterns` feature gate)
 - #118191 (Suggest `let` or `==` on typo'd let-chain)
 - #118231 (also add is_empty to const raw slices)
 - #118333 (Print list of missing target features when calling a function with target features outside an unsafe block)
 - #118426 (ConstProp: Correctly remove const if unknown value assigned to it.)
 - #118428 (rustdoc: Move `AssocItemRender` and `RenderMode` to `html::render`.)
 - #118438 (Update nto-qnx.md)

Failed merges:

 - #118268 (Pretty print `Fn<(..., ...)>` trait refs with parentheses (almost) always)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-29 11:42:03 +00:00
Matthias Krüger
6094cb5d36
Rollup merge of #118438 - AkhilTThomas:patch-1, r=JohnTitor
Update nto-qnx.md

x.py does not support specifying multiple `--target` keywords. The targets must be specified comma separated.

Error:
`error: the argument '--target <TARGET>' cannot be used multiple times`
2023-11-29 12:34:51 +01:00
Matthias Krüger
1e8ecec9f2
Rollup merge of #118428 - aDotInTheVoid:doc-cleanup, r=GuillaumeGomez
rustdoc: Move `AssocItemRender` and `RenderMode` to `html::render`.

They're only used for HTML, so it makes more sense for them to live their.
2023-11-29 12:34:51 +01:00
Matthias Krüger
434232f7b2
Rollup merge of #118426 - aDotInTheVoid:const-wat, r=compiler-errors,cjgillot
ConstProp: Correctly remove const if unknown value assigned to it.

Closes #118328

The problematic sequence of MIR is:

```rust
          _1 = const 0_usize;
          _1 = const _; // This is an associated constant we can't know before monomorphization.
          _0 = _1;
```

1. When `ConstProp::visit_assign` happens on `_1 = const 0_usize;`, it records that `0x0usize` is the value for `_1`.
2. Next `visit_assign` happens on `_1 = const _;`. Because the rvalue `.has_param()`, it can't be const evaled.
3. Finaly, `visit_assign` happens on `_0 = _1;`. Here it would think the value of `_1` was `0x0usize` from step 1.

The solution is to remove consts when checking the RValue fails, as they may have contained values that should now be invalidated, as that local was overwritten.

This should probably be back-ported to beta. Stable is more iffy, as it's gone unidentified since 1.70, so I only think it's worthwhile if there's another reason for a 1.74.1 release anyway.
2023-11-29 12:34:50 +01:00
Matthias Krüger
911a5ee7ff
Rollup merge of #118333 - eduardosm:print-missing-target-features, r=est31
Print list of missing target features when calling a function with target features outside an unsafe block

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

Supersedes https://github.com/rust-lang/rust/pull/109710. I used the same wording for the messages, but the implementation is different.

r? `@est31`
2023-11-29 12:34:50 +01:00
Matthias Krüger
afe2d7392f
Rollup merge of #118231 - RalfJung:const-raw-slice-empty, r=cuviper
also add is_empty to const raw slices

We have this on mutable raw slices but not const raw slices, which makes little sense.

Cc https://github.com/rust-lang/rust/issues/71146
2023-11-29 12:34:49 +01:00
Matthias Krüger
aab61d0b9a
Rollup merge of #118191 - estebank:let-chain-typo, r=compiler-errors
Suggest `let` or `==` on typo'd let-chain

When encountering a bare assignment in a let-chain, suggest turning the
assignment into a `let` expression or an equality check.

```
error: expected expression, found `let` statement
  --> $DIR/bad-if-let-suggestion.rs:5:8
   |
LL |     if let x = 1 && i = 2 {}
   |        ^^^^^^^^^
   |
   = note: only supported directly in conditions of `if` and `while` expressions
help: you might have meant to continue the let-chain
   |
LL |     if let x = 1 && let i = 2 {}
   |                     +++
help: you might have meant to compare for equality
   |
LL |     if let x = 1 && i == 2 {}
   |                        +
```
2023-11-29 12:34:48 +01:00
Matthias Krüger
071f8f610d Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors
Add `never_patterns` feature gate

This PR adds the feature gate and most basic parsing for the experimental `never_patterns` feature. See the tracking issue (https://github.com/rust-lang/rust/issues/118155) for details on the experiment.

`@scottmcm` has agreed to be my lang-team liaison for this experiment.
2023-11-29 12:34:47 +01:00
Matthias Krüger
c03f8917ee
Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors
Add `never_patterns` feature gate

This PR adds the feature gate and most basic parsing for the experimental `never_patterns` feature. See the tracking issue (https://github.com/rust-lang/rust/issues/118155) for details on the experiment.

`@scottmcm` has agreed to be my lang-team liaison for this experiment.
2023-11-29 12:34:47 +01:00
AkhilTThomas
e4121c5343
Update nto-qnx.md
x.py does not support specify multiple --target keywords. The targets must be specified comma separated.
2023-11-29 14:31:32 +05:30