1
Fork 0
Commit graph

273912 commits

Author SHA1 Message Date
Esteban Küber
1549af29c3 Do not suggest foo.Bar 2024-12-21 03:02:07 +00:00
Esteban Küber
cbbc7becc8 Account for missing . in macros to avoid incorrect suggestion 2024-12-21 02:46:33 +00:00
Esteban Küber
1ce0fa98c7 Detect missing . in method chain in let bindings and statements
On parse errors where an ident is found where one wasn't expected, see if the next elements might have been meant as method call or field access.

```
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `map`
  --> $DIR/missing-dot-on-statement-expression.rs:7:29
   |
LL |     let _ = [1, 2, 3].iter()map(|x| x);
   |                             ^^^ expected one of `.`, `;`, `?`, `else`, or an operator
   |
help: you might have meant to write a method call
   |
LL |     let _ = [1, 2, 3].iter().map(|x| x);
   |                             +
```
2024-12-21 02:46:33 +00:00
Weihang Lo
a4b09c3105
Update cargo 2024-12-20 20:50:05 -05:00
Esteban Küber
d520b18316 Mention #[default] in E0655 code index 2024-12-21 01:31:20 +00:00
Kornel
7b42bc0c79
Less unwrap() in documentation 2024-12-21 01:26:47 +00:00
bors
13170cd787 Auto merge of #134590 - matthiaskrgr:rollup-8lz2s62, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #123604 (Abstract `ProcThreadAttributeList` into its own struct)
 - #128780 (Add `--doctest-compilation-args` option to add compilation flags to doctest compilation)
 - #133782 (Precedence improvements: closures and jumps)
 - #134509 (Arbitrary self types v2: niche deshadowing test)
 - #134524 (Arbitrary self types v2: no deshadow pre feature.)
 - #134539 (Restrict `#[non_exaustive]` on structs with default field values)
 - #134586 (Also lint on option of function pointer comparisons)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-21 01:17:43 +00:00
Matthias Krüger
b7ac8d78c5
Rollup merge of #134586 - Urgau:fn-ptr-lint-option, r=compiler-errors
Also lint on option of function pointer comparisons

This PR is the first part of #134536, ie. the linting on `Option<{fn ptr}>` in the `unpredictable_function_pointer_comparisons` lint, which isn't part of the lang nomination that the second part is going trough, and so should be able to be approved independently.

Related to https://github.com/rust-lang/rust/issues/134527
r? `@compiler-errors`
2024-12-21 01:30:18 +01:00
Matthias Krüger
fea6c4eb07
Rollup merge of #134539 - estebank:restrict-non_exhaustive, r=jieyouxu
Restrict `#[non_exaustive]` on structs with default field values

Do not allow users to apply `#[non_exaustive]` to a struct when they have also used default field values.
2024-12-21 01:30:17 +01:00
Matthias Krüger
3201fe9893
Rollup merge of #134524 - adetaylor:getref, r=compiler-errors
Arbitrary self types v2: no deshadow pre feature.

The arbitrary self types v2 work introduces a check for shadowed methods, whereby a method in some "outer" smart pointer type may called in preference to a method in the inner referent. This is bad if the outer pointer adds a method later, as it may change behavior, so we ensure we error in this circumstance.

It was intended that this new shadowing detection system only comes into play for users who enable the `arbitrary_self_types` feature (or of course everyone later if it's stabilized). It was believed that the new deshadowing code couldn't be reached without building the custom smart pointers that `arbitrary_self_types` enables, and therefore there was no risk of this code impacting existing users.

However, it turns out that cunning use of `Pin::get_ref` can cause this type of shadowing error to be emitted now. This commit adds a test for this case.

As we want this test to pass without arbitrary_self_types, but fail with it, I've split it into two files (one with run-pass and one without). If there's a better way I can amend it.

Part of #44874

r? ```@wesleywiser```
2024-12-21 01:30:16 +01:00
Matthias Krüger
aea7c1d8d7
Rollup merge of #134509 - adetaylor:niche-deshadowing-tests, r=wesleywiser
Arbitrary self types v2: niche deshadowing test

Arbitrary self types v2 attempts to detect cases where methods in an "outer" type (e.g. a smart pointer) might "shadow" methods in the referent.

There are a couple of cases where the current code makes no attempt to detect such shadowing. Both of these cases only apply if other unstable features are enabled.

Add a test, mostly for illustrative purposes, so we can see the shadowing cases that can occur.

Part of #44874
r? ```@wesleywiser```
2024-12-21 01:30:15 +01:00
Matthias Krüger
f3b19f54fa
Rollup merge of #133782 - dtolnay:closuresjumps, r=spastorino,traviscross
Precedence improvements: closures and jumps

This PR fixes some cases where rustc's pretty printers would redundantly parenthesize expressions that didn't need it.

<table>
<tr><th>Before</th><th>After</th></tr>
<tr><td><code>return (|x: i32| x)</code></td><td><code>return |x: i32| x</code></td></tr>
<tr><td><code>(|| -> &mut () { std::process::abort() }).clone()</code></td><td><code>|| -> &mut () { std::process::abort() }.clone()</code></td></tr>
<tr><td><code>(continue) + 1</code></td><td><code>continue + 1</code></td></tr>
</table>

Tested by `echo "fn main() { let _ = $AFTER; }" | rustc -Zunpretty=expanded /dev/stdin`.

The pretty-printer aims to render the syntax tree as it actually exists in rustc, as faithfully as possible, in Rust syntax. It can insert parentheses where forced by Rust's grammar in order to preserve the meaning of a macro-generated syntax tree, for example in the case of `a * $rhs` where $rhs is `b + c`. But for any expression parsed from source code, without a macro involved, there should never be a reason for inserting additional parentheses not present in the original.

For closures and jumps (return, break, continue, yield, do yeet, become) the unneeded parentheses came from the precedence of some of these expressions being misidentified. In the same order as the table above:

- Jumps and closures are supposed to have equal precedence. The [Rust Reference](https://doc.rust-lang.org/1.83.0/reference/expressions.html#expression-precedence) says so, and in Syn they do. There is no Rust syntax that would require making a precedence distinction between jumps and closures. But in rustc these were previously 2 distinct levels with the closure being lower, hence the parentheses around a closure inside a jump (but not a jump inside a closure).

- When a closure is written with an explicit return type, the grammar [requires](https://doc.rust-lang.org/1.83.0/reference/expressions/closure-expr.html) that the closure body consists of exactly one block expression, not any other arbitrary expression as usual for closures. Parsing of the closure body does not continue after the block expression. So in `|| { 0 }.clone()` the clone is inside the closure body and applies to `{ 0 }`, whereas in `|| -> _ { 0 }.clone()` the clone is outside and applies to the closure as a whole.

- Continue never needs parentheses. It was previously marked as having the lowest possible precedence but it should have been the highest, next to paths and loops and function calls, not next to jumps.
2024-12-21 01:30:15 +01:00
Matthias Krüger
472bbb9f0c
Rollup merge of #128780 - GuillaumeGomez:rustflags-doctests, r=rustdoc
Add `--doctest-compilation-args` option to add compilation flags to doctest compilation

Fixes #67533.
Tracking issue: https://github.com/rust-lang/rust/issues/134172

It's been something I meant to take a look at for a long time and actually completely forgot... The idea is to allow to give more control over how doctests are compiled to users. To do so, this PR adds a new `--doctest-compilation-args` option which provides extra compilation flags.

r? `@notriddle`
2024-12-21 01:30:14 +01:00
Matthias Krüger
758ad53005
Rollup merge of #123604 - michaelvanstraten:proc_thread_attribute_list, r=ChrisDenton
Abstract `ProcThreadAttributeList` into its own struct

As extensively discussed in issue #114854, the current implementation of the unstable `windows_process_extensions_raw_attribute` features lacks support for passing a raw pointer.

This PR wants to explore the opportunity to abstract away the `ProcThreadAttributeList` into its own struct to for one improve safety and usability and secondly make it possible to maybe also use it to spawn new threads.

try-job: x86_64-mingw
2024-12-21 01:30:13 +01:00
roife
56ced3b32f fix: only show debug lens with a valid root 2024-12-21 07:03:45 +08:00
roife
4f754f4fe7 fix: remove always! check for file_id in runnables 2024-12-21 07:00:49 +08:00
Urgau
9965ad7620 Also lint on option of function pointer comparisons 2024-12-20 23:48:46 +01:00
Guillaume Gomez
2d914bed2d Add test to ensure passing --doctest_compilation_args multiple times work 2024-12-20 22:35:00 +01:00
Guillaume Gomez
bc03e40a29 Move test into the tests.rs file 2024-12-20 22:35:00 +01:00
Guillaume Gomez
55653a5178 Add explanations on how arguments are split 2024-12-20 22:35:00 +01:00
Guillaume Gomez
cbb3df41fb Split arguments from --doctest-compilation-args like a shell would 2024-12-20 22:35:00 +01:00
Guillaume Gomez
24fafe7d14 Update run-make/rustdoc-default-output test 2024-12-20 22:35:00 +01:00
bors
5f23ef7d3f Auto merge of #134582 - matthiaskrgr:rollup-i0oyqjw, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #134556 ([tiny] fix missing ns units in bootstrap's benchmark rendering)
 - #134560 (mri: add track_caller to thread spawning methods for better backtraces)
 - #134561 (Reduce the amount of explicit FatalError.raise())
 - #134562 (tests/codegen/asm: Remove uses of rustc_attrs and lang_items features by using minicore)
 - #134567 (Remove some dead code around import library generation)
 - #134570 (remove reference to dangling from slice::Iter)
 - #134573 (unimplement `PointerLike` for trait objects)
 - #134574 (next-solver: disable unnecessary hack)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-20 21:00:14 +00:00
Matthias Krüger
10a7405fde
Rollup merge of #134574 - lcnr:opaque-ty-hack-yeet, r=compiler-errors
next-solver: disable unnecessary hack

the new solver never constrains inference variables to normalizeable aliases, so this is no longer necessary.
2024-12-20 21:32:33 +01:00
Matthias Krüger
0b1834d66b
Rollup merge of #134573 - lukas-code:unimpl-dyn-pointerlike, r=compiler-errors
unimplement `PointerLike` for trait objects

Values of type `dyn* PointerLike` or `dyn PointerLike` are not pointer-like so these types should not implement `PointerLike`.

After https://github.com/rust-lang/rust/pull/133226, `PointerLike` allows user implementations, so we can't just mark it with `#[rustc_deny_explicit_impl(implement_via_object = false)]`. Instead, this PR splits the `#[rustc_deny_explicit_impl(implement_via_object = ...)]` attribute into two separate attributes `#[rustc_deny_explicit_impl]` and `#[rustc_do_not_implement_via_object]` so that we opt out of the automatic `impl PointerLike for dyn PointerLike` and still allow user implementations.

For traits that are marked with `#[do_not_implement_via_object]` but not `#[rustc_deny_explicit_impl]` I've also made it possible to add a manual `impl Trait for dyn Trait`. There is no immediate need for this, but it was one line to implement and seems nice to have.

fixes https://github.com/rust-lang/rust/issues/134545
fixes https://github.com/rust-lang/rust/issues/134543

r? `@compiler-errors`
2024-12-20 21:32:33 +01:00
Matthias Krüger
04c804eb46
Rollup merge of #134570 - hkBst:patch-3, r=joboet
remove reference to dangling from slice::Iter

This aligns the comment with reality and with IterMut. Also dangling does not seem to take any arguments.
2024-12-20 21:32:32 +01:00
Matthias Krüger
9b4aa92fdc
Rollup merge of #134567 - bjorn3:remove_unused_code, r=compiler-errors
Remove some dead code around import library generation

This was missed when replacing the usage of LLVM for generating import libraries.

``@bors`` rollup
2024-12-20 21:32:31 +01:00
Matthias Krüger
17f6690eff
Rollup merge of #134562 - taiki-e:codegen-asm-minicore, r=jieyouxu
tests/codegen/asm: Remove uses of rustc_attrs and lang_items features by using minicore

Similar to https://github.com/rust-lang/rust/pull/134385 (for tests/ui/asm) and https://github.com/rust-lang/rust/pull/134436 (for tests/assembly/asm), but for tests/codegen/asm.

r? jieyouxu
2024-12-20 21:32:31 +01:00
Matthias Krüger
4a792fdce1
Rollup merge of #134561 - bjorn3:less_fatal_error_raise, r=compiler-errors
Reduce the amount of explicit FatalError.raise()

Instead use dcx.abort_if_error() or guar.raise_fatal() instead. These guarantee that an error actually happened previously and thus we don't silently abort.
2024-12-20 21:32:30 +01:00
Matthias Krüger
1a992573e6
Rollup merge of #134560 - RalfJung:miri-thread-spawn, r=jhpratt
mri: add track_caller to thread spawning methods for better backtraces

This is in preparation for https://github.com/rust-lang/miri/pull/4093
2024-12-20 21:32:30 +01:00
Matthias Krüger
94b1b48eee
Rollup merge of #134556 - the8472:restore-ns-units, r=jieyouxu
[tiny] fix missing ns units in bootstrap's benchmark rendering
2024-12-20 21:32:29 +01:00
Lukas Wirth
2d895a760e
Merge pull request #18731 from rust-lang/revert-18670-push-ylomnylswnxm
Revert "internal: Drop proc-macro server support for ~1.66.0 and older toolchains"
2024-12-20 20:06:24 +00:00
Lukas Wirth
b7bde823c0
Revert "internal: Drop proc-macro server support for ~1.66.0 and older toolchains" 2024-12-20 20:51:09 +01:00
Marijn Schouten
07ab203f34
Improve prose around into_slice example of IterMut 2024-12-20 19:57:20 +01:00
Marijn Schouten
3cfe66ab65
Improve prose around as_slice example of Iter 2024-12-20 19:19:34 +01:00
Michael Goulet
42d1a4c48b Handle DropKind::ForLint in coroutines correctly 2024-12-20 18:18:06 +00:00
bors
bad2aa4721 Auto merge of #134564 - Kobzol:revert-aarch64-runner, r=nikic
Revert "Auto merge of #133809 - mrkajetanp:ci-aarch64-dist, r=Kobzol"

This reverts https://github.com/rust-lang/rust/pull/133809, as it produced broken aarch64 artifacts (https://github.com/rust-lang/rust/issues/134563).

`@bors` p=1
2024-12-20 17:59:07 +00:00
Marijn Schouten
a8e7a6c1d8
Improve prose around basic examples of Iter and IterMut 2024-12-20 18:55:48 +01:00
lcnr
6bc1fe1c3a next-solver: rm opaque type hack 2024-12-20 18:36:39 +01:00
Marijn Schouten
496adcf36c
remove reference to dangling from slice::Iter
This aligns the comment with reality and with IterMut. Also dangling does not seem to take any arguments.
2024-12-20 18:20:40 +01:00
Esteban Küber
b3cc9b9620 Restrict #[non_exaustive] on structs with default field values
Do not allow users to apply `#[non_exaustive]` to a struct when they have also used default field values.
2024-12-20 17:18:54 +00:00
Lukas Markeffsky
159dba89ef fix PointerLike docs 2024-12-20 17:37:34 +01:00
Lukas Markeffsky
971a4f2d3b unimplement PointerLike for trait objects 2024-12-20 17:35:29 +01:00
Lukas Markeffsky
42c00cb647 split up #[rustc_deny_explicit_impl] attribute
This commit splits the `#[rustc_deny_explicit_impl(implement_via_object = ...)]` attribute
into two attributes `#[rustc_deny_explicit_impl]` and `#[rustc_do_not_implement_via_object]`.

This allows us to have special traits that can have user-defined impls but do not have the
automatic trait impl for trait objects (`impl Trait for dyn Trait`).
2024-12-20 16:57:14 +01:00
bjorn3
c02c311d84 Remove some dead code around import library generation
This was missed when replacing the usage of LLVM for generating import
libraries.
2024-12-20 15:20:15 +00:00
Jakub Beránek
a5dce0e16d Revert "Auto merge of #133809 - mrkajetanp:ci-aarch64-dist, r=Kobzol"
This reverts commit 023521e682, reversing
changes made to c434b4b4b6.
2024-12-20 16:04:39 +01:00
bors
fcc1615e47 Auto merge of #134559 - DianQK:rollup-22iraj9, r=DianQK
Rollup of 5 pull requests

Successful merges:

 - #134366 (Fix logical error with what text is considered whitespace.)
 - #134514 (Improve dependency_format a bit)
 - #134519 (ci: use ubuntu `24` instead of `latest`)
 - #134551 (coverage: Rename `basic_coverage_blocks` to just `graph`)
 - #134553 (add member constraints comment)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-20 15:02:34 +00:00
Taiki Endo
96edf41194 tests/codegen/asm: Remove uses of rustc_attrs and lang_items features by using minicore 2024-12-20 23:19:12 +09:00
Guillaume Gomez
d3c970a198 Add explanations about --doctest-compilation-args in rustdoc book 2024-12-20 15:17:47 +01:00
Guillaume Gomez
2bd869082b Add regression test for --doctest-compilation-args 2024-12-20 15:17:47 +01:00