Commit Graph

240158 Commits

Author SHA1 Message Date
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
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
bors
ec1f21cb04 Auto merge of #118433 - matthiaskrgr:rollup-fi9lrwg, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #116839 (Implement thread parking for xous)
 - #118265 (remove the memcpy-on-equal-ptrs assumption)
 - #118269 (Unify `TraitRefs` and `PolyTraitRefs` in `ValuePairs`)
 - #118394 (Remove HIR opkinds)
 - #118398 (Add proper cfgs in std)
 - #118419 (Eagerly return `ExprKind::Err` on `yield`/`await` in wrong coroutine context)
 - #118422 (Fix coroutine validation for mixed panic strategy)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-29 08:51:01 +00:00
bors
e9b7bf0114 Auto merge of #118434 - matthiaskrgr:rollup-k1upt8b, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #118342 (Dont suggest `!` for path in function call if it has generic args)
 - #118383 (Address unused tuple struct fields in the standard library)
 - #118401 (`rustc_ast_lowering` cleanups)
 - #118409 (format_foreign.rs: unwrap return Option value for `fn position`, as it always returns Some)
 - #118413 (Fix the issue of suggesting unwrap/expect for shorthand field)
 - #118425 (Update cargo)
 - #118429 (Fix a typo in a `format_args!` note)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-29 06:23:14 +00:00
Matthias Krüger
0687dcb056
Rollup merge of #118429 - cuviper:its-arguments, r=compiler-errors
Fix a typo in a `format_args!` note
2023-11-29 04:23:31 +01:00
Matthias Krüger
9c93effa77
Rollup merge of #118425 - weihanglo:update-cargo, r=weihanglo
Update cargo

7 commits in 9b13310ca596020a737aaa47daa4ed9ff8898a2f..26333c732095d207aa05932ce863d850fb309386
2023-11-24 16:20:51 +0000 to 2023-11-28 20:07:39 +0000
- docs: link to the packages lint table from the related workspace table (rust-lang/cargo#13057)
- Add more doc comments for gc changes. (rust-lang/cargo#13055)
- docs: Provide pointers for MSRV (rust-lang/cargo#13056)
- Fixed typo in SemVer Compatibility documentation page (rust-lang/cargo#13054)
- refactor: use custom error instead of anyhow (rust-lang/cargo#13050)
- review and remove ignored tests in rustfix (rust-lang/cargo#13047)
- docs: add doc comments for rustfix (rust-lang/cargo#13048)

r? ghost
2023-11-29 04:23:30 +01:00
Matthias Krüger
872753895f
Rollup merge of #118413 - chenyukang:yukang-fix-118145-unwrap-for-shorthand, r=compiler-errors
Fix the issue of suggesting unwrap/expect for shorthand field

Fixes #118145
2023-11-29 04:23:30 +01:00
Matthias Krüger
69e48d0f6e
Rollup merge of #118409 - klensy:position-opt, r=compiler-errors
format_foreign.rs: unwrap return Option value for `fn position`, as it always returns Some

Trivial cleanup.

It will be nice to have way to run exhaustiveness analysis on similar cases to see dead code.
2023-11-29 04:23:29 +01:00
Matthias Krüger
82eda5865a
Rollup merge of #118401 - nnethercote:rustc_ast_lowering, r=compiler-errors
`rustc_ast_lowering` cleanups

Just some cleanups I found while looking through this code.

r? `@spastorino`
2023-11-29 04:23:29 +01:00
Matthias Krüger
f8628a179d
Rollup merge of #118383 - shepmaster:unused-tuple-struct-field-cleanup-stdlib, r=m-ou-se
Address unused tuple struct fields in the standard library
2023-11-29 04:23:28 +01:00
Matthias Krüger
5e7f770a0d
Rollup merge of #118342 - compiler-errors:macro-generic-bang, r=estebank
Dont suggest `!` for path in function call if it has generic args

Fixes #118335
2023-11-29 04:23:28 +01:00
Matthias Krüger
e8d0c56331
Rollup merge of #118422 - tmiasko:mix, r=compiler-errors
Fix coroutine validation for mixed panic strategy

Validation introduced in #113124 allows `UnwindAction::Continue` and `TerminatorKind::Resume` to occur only in functions with ABI that can unwind. The function ABI depends on the panic strategy, which can vary across crates.

Usually MIR is built and validated in the same crate. The coroutine drop glue thus far was an exception. As a result validation could fail when mixing different panic strategies.

Avoid the problem by executing `AbortUnwindingCalls` along with the validation.

Fixes #116953.
2023-11-29 04:23:24 +01:00