Commit Graph

270824 Commits

Author SHA1 Message Date
Matthias Krüger
506f52c7f3
Rollup merge of #132933 - compiler-errors:never-lint-arg-bug, r=WaffleLapkin
Make sure that we suggest turbofishing the right type arg for never suggestion

I had a bug where rust would suggest the wrong arg to turbofish `()` if there were any early-bound lifetimes...

r? WaffleLapkin
2024-11-12 06:27:20 +01:00
Matthias Krüger
119b939c18
Rollup merge of #132929 - cuviper:check-alloc_zeroed, r=tgross35
Check for null in the `alloc_zeroed` example

We should demonstrate good behavior, just like #99198 did for `alloc`.
2024-11-12 06:27:20 +01:00
Matthias Krüger
0555bb2a1b
Rollup merge of #132869 - lolbinarycat:library-fix-too_long_first_doc_paragraph, r=tgross35
split up the first paragraph of doc comments for better summaries

used `./x clippy -Aclippy::all '-Wclippy::too_long_first_doc_paragraph' library/core library/alloc` to find these issues.
2024-11-12 06:27:19 +01:00
Matthias Krüger
953064f00a
Rollup merge of #132847 - RalfJung:addr-dont-expose, r=Mark-Simulacrum
elem_offset / subslice_range: use addr() instead of 'as usize'

There's no reason to use ptr-to-int casts with their subtle semantics here.
2024-11-12 06:27:19 +01:00
Matthias Krüger
52bb9fafd0
Rollup merge of #132793 - ehuss:update-mdbook, r=Mark-Simulacrum
Update mdbook to 0.4.42

This updates mdbook to 0.4.42
Changelog: https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-0441

There were some significant changes that I would like to get early testing on.

This also updates rust-by-example which was required due to an update to the theme file.
2024-11-12 06:27:18 +01:00
Matthias Krüger
b7dc4813a8
Rollup merge of #132653 - BoxyUwU:const_arg_stmt_mac_call, r=compiler-errors
Don't use `maybe_unwrap_block` when checking for macro calls in a block expr

Fixes #131915

Using `maybe_unwrap_block` to determine if we are looking at a `{ mac_call!{} }` will fail sometimes as `mac_call!{}` could be a `StmtKind::MacCall` not a `StmtKind::Expr`. This caused the def collector to think that `{ mac_call!{} }` was a non-trivial const argument and create a definition for it even though it should not.

r? `@compiler-errors`  cc `@camelid`
2024-11-12 06:27:17 +01:00
Matthias Krüger
2ad4a3568d
Rollup merge of #132627 - adwinwhite:thir_body_cleanup, r=compiler-errors
cleanup: Remove outdated comment of `thir_body`

When typeck fails, `thir_body` returns `ErrorGuaranteed` rather than empty body.

No other code follows this outdated description except `check_unsafety`, which is also cleaned up in this PR.
2024-11-12 06:27:17 +01:00
Matthias Krüger
9098e03fb2
Rollup merge of #132487 - dianne:include-trait-args-in-suggestion, r=fmease
Provide placeholder generics for traits in "no method found for type parameter" suggestions

In the diagnostics for the error ``no method named `method` found for type parameter `T` in the current scope [E0599]``, the compiler will suggest adding bounds on `T` for traits that define a method named `method`. However, these suggestions didn't include any generic arguments, so applying them would result in a `missing generics for trait` or `missing lifetime specifier` error. This PR adds placeholder arguments to the suggestion in such cases. Specifically, I tried to base the placeholders off of what's done in suggestions for when generics are missing or too few are provided:
- The placeholder for a parameter without a default is the name of the parameter.
- Placeholders are not provided for parameters with defaults.

Placeholder arguments are enclosed in `/*` and `*/`, and the applicability of the suggestion is downgraded to `Applicability::HasPlaceholders` if any placeholders are provided.

Fixes #132407
2024-11-12 06:27:16 +01:00
ismailarilik
1ba72db242 test(configure): cover parse_args in src/bootstrap/configure.py 2024-11-12 07:28:23 +03:00
Michael Goulet
0dc6c1e594 Make precise capturing suggestion machine-applicable only if it has not APITs 2024-11-12 04:08:34 +00:00
Michael Goulet
8473e3f6af Make sure that we suggest turbofishing the right type arg 2024-11-12 03:02:23 +00:00
Boxy
bea0148ac6 Consolidate type system const evaluation under traits::evaluate_const
mew
2024-11-12 02:54:03 +00:00
bors
67f21277cd Auto merge of #132919 - matthiaskrgr:rollup-ogghyvp, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #120077 (Add Set entry API )
 - #132144 (Arbitrary self types v2: (unused) Receiver trait)
 - #132297 (Document some `check_expr` methods, and other misc `hir_typeck` tweaks)
 - #132820 (Add a default implementation for CodegenBackend::link)
 - #132881 (triagebot: Autolabel rustdoc book)
 - #132912 (Simplify some places that deal with generic parameter defaults)
 - #132916 (Unvacation fmease)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-12 02:51:21 +00:00
Michael Goulet
d128c80c7a Make sure to ignore elided lifetimes when pointing at args for fulfillment errors 2024-11-12 02:08:39 +00:00
Josh Stone
2ddb91acd1 Check for null in the alloc_zeroed example
We should demonstrate good behavior, just like #99198 did for `alloc`.
2024-11-11 16:30:37 -08:00
León Orell Valerian Liehr
5b7423c2fc
Triagebot: Consolidate the T-compiler ad hoc groups 2024-11-12 00:33:23 +01:00
Matthias Krüger
2d026525db
Rollup merge of #132916 - fmease:unvac-me, r=fmease
Unvacation fmease

It's become a hindrance.
r? ghost
2024-11-11 21:58:34 +01:00
Matthias Krüger
b41baf8c81
Rollup merge of #132912 - fmease:simplify-gen-param-default-users, r=compiler-errors
Simplify some places that deal with generic parameter defaults
2024-11-11 21:58:33 +01:00
Matthias Krüger
f344169e7d
Rollup merge of #132881 - aDotInTheVoid:docs-for-docs, r=jieyouxu
triagebot: Autolabel rustdoc book

Inspired by #132876 not getting labeled as https://github.com/rust-lang/rust/labels/T-rustdoc

r? `@GuillaumeGomez`
2024-11-11 21:58:32 +01:00
Matthias Krüger
35225d61f4
Rollup merge of #132820 - bjorn3:default_backend_link_impl, r=jieyouxu
Add a default implementation for CodegenBackend::link

As a side effect this should add raw-dylib support to cg_gcc as the default ArchiveBuilderBuilder that is used implements create_dll_import_lib. I haven't tested if the raw-dylib support actually works however.
2024-11-11 21:58:32 +01:00
Matthias Krüger
517e8bed96
Rollup merge of #132297 - compiler-errors:check-expr-tweaks, r=lcnr
Document some `check_expr` methods, and other misc `hir_typeck` tweaks

Most importantly, make sure that all of the expression checking functions that are called from `check_expr_kind` start with `check_expr_*`. This is super useful to me personally, since I grep these functions all the time, and the ones that *aren't* named consistently are incredibly hard to find.

Also document more of the `check_expr_*` functions, and squash two args for passing data about a call expr into one `Option`.
2024-11-11 21:58:31 +01:00
Matthias Krüger
9d7faccffc
Rollup merge of #132144 - adetaylor:receiver-trait-itself, r=wesleywiser
Arbitrary self types v2: (unused) Receiver trait

This commit contains a new `Receiver` trait, which is the basis for the Arbitrary Self Types v2 RFC. This allows smart pointers to be method receivers even if they're not Deref.

This is currently unused by the compiler - a subsequent PR will start to use this for method resolution if the `arbitrary_self_types` feature gate is enabled. This is being landed first simply to make review simpler: if people feel this should all be in an atomic PR let me know.

This is a part of the arbitrary self types v2 project, https://github.com/rust-lang/rfcs/pull/3519
https://github.com/rust-lang/rust/issues/44874

r? `@wesleywiser`
2024-11-11 21:58:29 +01:00
Matthias Krüger
3ab4477ba7
Rollup merge of #120077 - SUPERCILEX:set-entry, r=Amanieu
Add Set entry API

See https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/HashSet.3A.3Aentry/near/413224639 and https://github.com/rust-lang/rust/issues/60896#issuecomment-678708111

Closes https://github.com/rust-lang/rfcs/issues/1490
2024-11-11 21:58:28 +01:00
dianne
02add7d0fb Provide placeholder generic arguments for traits in "no method found for type parameter" suggestions 2024-11-11 12:33:15 -08:00
León Orell Valerian Liehr
d0ddba3d5b
Simplify some places that deal with generic parameter defaults 2024-11-11 21:29:18 +01:00
bors
81eef2d362 Auto merge of #132902 - matthiaskrgr:rollup-43qgg3t, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #129627 (Ensure that tail expr receive lifetime extension)
 - #130999 (Implement file_lock feature)
 - #132873 (handle separate prefixes in clippy rules)
 - #132891 (Remove `rustc_session::config::rustc_short_optgroups`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-11 19:25:06 +00:00
PonasKovas
7c0a7f78a0 remove attributes from generics in built-in derive macros
add a test

add github issue link to description of the test

replace new ThinVec with clear()

Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2024-11-11 21:20:02 +02:00
León Orell Valerian Liehr
0a88d517c0
Unvacation fmease 2024-11-11 19:30:05 +01:00
Ryan Roden-Corrent
0d3a58e576
Update grammar in std::cell docs.
Using "having" in both the leading sentence and the bullets is unnecessary.
It makes it read as "it is only possible to have having several immutable...".
2024-11-11 13:22:03 -05:00
Laurențiu Nicola
61dba0292d
Merge pull request #18503 from SomeoneToIgnore/kb/better-resolve-indexing
Use completion item indices instead of property matching when searching for the completion item to resolve
2024-11-11 16:31:11 +00:00
bors
de27914e8e Auto merge of #132720 - jieyouxu:do-not-strip, r=davidtwco
Only copy, rename and link `llvm-objcopy` if llvm tools are enabled

Fixes #132719.

cc `@bjorn3` who reported the bootstrapping problem for cg_clif.
cc `@davidtwco` in case this might be problematic for linux -> macOS cross-compile builds, but seems very unlikely.
cc `@albertlarsan68` (co-reviewed #131405)

r? bootstrap
2024-11-11 16:07:15 +00:00
Kirill Bulatov
e646263abc Update the file hash 2024-11-11 16:06:55 +01:00
Kirill Bulatov
572ae698be Use completion item indices instead of property matching when searching for the completion item to resolve 2024-11-11 15:50:04 +01:00
León Orell Valerian Liehr
46603166d7
[perf] rustdoc: Perform less work when cleaning parenthesized generic args 2024-11-11 15:35:30 +01:00
Matthias Krüger
bcd85e5434
Rollup merge of #132891 - Zalathar:short-opt-groups, r=jieyouxu
Remove `rustc_session::config::rustc_short_optgroups`

Follow-up to https://github.com/rust-lang/rust/pull/132754#discussion_r1835427349.

The name `rustc_short_optgroups` has always been confusing, because it is unrelated to the distinction between short and long options (i.e. `-s` vs `--long`), and instead means something like “the subset of command-line options that are printed by `rustc --help` without `-v`”.

So let's merge that function into the main `rustc_optgroups`, and store the relevant bit of information in a boolean field in `RustcOptGroup` instead.

---

This PR also modifies `RustcOptGroup` to store its various strings directly, instead of inside a boxed `apply` closure. That turned out to not be necessary for the main change, but is a worthwhile cleanup in its own right.
2024-11-11 15:23:34 +01:00
Matthias Krüger
7319666923
Rollup merge of #132873 - onur-ozkan:132867, r=jieyouxu
handle separate prefixes in clippy rules

Fixes https://github.com/rust-lang/rust/issues/132867
2024-11-11 15:23:33 +01:00
Matthias Krüger
95175f851e
Rollup merge of #130999 - cberner:flock_pr, r=joboet
Implement file_lock feature

This adds lock(), lock_shared(), try_lock(), try_lock_shared(), and unlock() to File gated behind the file_lock feature flag

This is the initial implementation of https://github.com/rust-lang/rust/issues/130994 for Unix and Windows platforms. I will follow it up with an implementation for WASI preview 2
2024-11-11 15:23:33 +01:00
Matthias Krüger
d4abc3183d
Rollup merge of #129627 - dingxiangfei2009:ensure-tail-expr-in-let-block-works, r=jieyouxu
Ensure that tail expr receive lifetime extension

cc `@jieyouxu` `@traviscross`

It just came to me that we should add a test to make sure that we honor the contract from the temporary lifetime rule #121346. We should continue to implement this rule in Edition 2021 onward and shorter tail expression lifetime should not override it.

This is a small PR to improve our assurance and establish a stronger contract.

Tracked by rust-lang/rust#123739
2024-11-11 15:23:32 +01:00
Eric Huss
e04acff14f Feature gate yield expressions not in 2024 2024-11-11 06:17:11 -08:00
Ding Xiang Fei
aee8152805
ensure that tail expr receive lifetime extension 2024-11-11 20:34:36 +08:00
bors
d4822c2d84 Auto merge of #127589 - notriddle:notriddle/search-sem-3, r=GuillaumeGomez
rustdoc-search: simplify rules for generics and type params

**Heads up!**: This PR is a follow-up that depends on #124544. It adds 12dc24f460, a change to the filtering behavior, and 9900ea48b5, a minor ranking tweak.

Part of https://github.com/rust-lang/rust-project-goals/issues/112

This PR overturns https://github.com/rust-lang/rust/pull/109802

## Preview

* no results: [`Box<[A]> -> Vec<B>`](http://notriddle.com/rustdoc-html-demo-12/search-sem-3/std/index.html?search=Box%3C%5BA%5D%3E%20-%3E%20Vec%3CB%3E)
* results: [`Box<[A]> -> Vec<A>`](http://notriddle.com/rustdoc-html-demo-12/search-sem-3/std/index.html?search=Box%3C%5BA%5D%3E%20-%3E%20Vec%3CA%3E)
* [`T -> U`](http://notriddle.com/rustdoc-html-demo-12/search-sem-3/std/index.html?search=T%20-%3E%20U)
* [`Cx -> TyCtxt`](http://notriddle.com/rustdoc-html-demo-12/search-sem-3-compiler/rustdoc/index.html?search=Cx%20-%3E%20TyCtxt)

![image](https://github.com/user-attachments/assets/015ae28c-7469-4f7f-be03-157d28d7ec97)

## Description

This commit is a response to feedback on the displayed type signatures results, by making generics act stricter.

- Order within generics is significant. This means `Vec<Allocator>` now matches only with a true vector of allocators, instead of matching the second type param. It also makes unboxing within generics stricter, so `Result<A, B>` only matches if `B` is in the error type and `A` is in the success type. The top level of the function search is unaffected.
- Generics are only "unboxed" if a type is explicitly opted into it. References and tuples are hardcoded to allow unboxing, and Box, Rc, Arc, Option, Result, and Future are opted in with an unstable attribute. Search result unboxing is the process that allows you to search for `i32 -> str` and get back a function with the type signature `&Future<i32> -> Box<str>`.
- Instead of ranking by set overlap, it ranks by the number of items in the type signature. This makes it easier to find single type signatures like transmute.

## Find the discussion on

* <https://rust-lang.zulipchat.com/#narrow/stream/393423-t-rustdoc.2Fmeetings/topic/meeting.202024-07-08/near/449965149>
* <https://github.com/rust-lang/rust/pull/124544#issuecomment-2204272265>
* <https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/deciding.20on.20semantics.20of.20generics.20in.20rustdoc.20search>
2024-11-11 12:26:00 +00:00
Zalathar
8b4701d74c Remove rustc_session::config::rustc_short_optgroups 2024-11-11 22:46:38 +11:00
Zalathar
3250c1c246 Store option strings directly, not in a boxed apply closure 2024-11-11 22:46:38 +11:00
Bastian Kersting
c2102259a0 CFI: Append debug location to CFI blocks 2024-11-11 09:17:43 +00:00
bors
71042b4b20 Auto merge of #132880 - RalfJung:implied-features, r=workingjubilee
target_features: explain what exacty 'implied' means here
2024-11-11 09:12:03 +00:00
onur-ozkan
2d143ab30c update "if-unchanged" comments in config.example.toml
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-11-11 11:27:53 +03:00
onur-ozkan
4dfc05237f Revert "do not trust download-rustc=if-unchanged on CI for now"
This reverts commit b3c212103b.
2024-11-11 11:19:14 +03:00
onur-ozkan
bc7531089e move src/tools/build_helper into src/build_helper
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-11-11 11:19:11 +03:00
onur-ozkan
6b38a159e5 reduce RUSTC_IF_UNCHANGED_ALLOWED_PATHS significantly
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-11-11 11:19:01 +03:00
Scott McMurray
fb26ba88f8 Generalize NonNull::from_raw_parts per ACP362
I did the raw pointers in 125701, but apparently forgot `NonNull`.
2024-11-11 00:05:17 -08:00