Commit Graph

256000 Commits

Author SHA1 Message Date
Oneirical
dd7e68b356 rewrite and rename issue-53964 2024-05-22 16:30:42 -04:00
Oneirical
f377ea165f rewrite issue-30063 2024-05-22 16:25:36 -04:00
David Barsky
f2c3ef77b1 fix: ensure implied bounds from associated types are considered in autocomplete 2024-05-22 16:16:20 -04:00
bors
04a9a1a531 Auto merge of #3614 - devnexen:illumos_time_support, r=oli-obk
solaris/illumos localtime_r / clock_getime support enabled.

clock_gettime support CLOCK_REALTIME/CLOCK_MONOTONIC clockid_t. localtime_r is supported only tm struct is more limited than other
 supported platforms.
2024-05-22 20:14:42 +00:00
bors
0916e72a34 Auto merge of #17251 - roife:fix-issue-17057, r=Veykril
fix: resolve extern prelude for local mods in block modules

fix https://github.com/rust-lang/rust-analyzer/issues/17057, https://github.com/rust-lang/rust-analyzer/issues/17032.

We should use `ModuleOrigin` to check if the current module is a pseudo-module introduced by blocks (where names might be shadowed), rather than checking `block_def_map`.
2024-05-22 20:11:24 +00:00
Nicholas Nethercote
4d513cb4bf Add some comments. 2024-05-23 06:03:17 +10:00
Nicholas Nethercote
a1b6d46e04 Use JointHidden in a couple of suitable places.
This has no notable effect, but it's appropriate because the relevant
tokens are followed by delimiters.
2024-05-23 06:03:17 +10:00
Nicholas Nethercote
c679a55102 Convert some token_joint_hidden calls to token_joint.
This has no noticeable effect, but it makes these cases follow the
guidelines in the comments on `Spacing`, which say that `Joint` should
be used "for each token that (a) should be pretty-printed without a
space after it, and (b) is followed by a punctuation token".

These two tokens are both followed by a comma, which is a punctuation
token.
2024-05-23 06:03:17 +10:00
Nicholas Nethercote
b6de782198 Clarify a comment. 2024-05-23 06:03:17 +10:00
Nicholas Nethercote
3fc8f8998c Clarify parse a little.
- Name the colon span as `colon_span` to distinguish it from the other
  `span` local variable.
- Just use basic pattern matching, which is easier to read than `map_or`.
2024-05-23 06:00:57 +10:00
Nicholas Nethercote
c8844dfdc0 Clarify the meaning of the span within mbe::TokenTree::MetaVar. 2024-05-23 06:00:28 +10:00
bors
56ce7e0e06 Auto merge of #17252 - davidbarsky:david/refactor-standalone-bools-into-struct, r=Veykril
internal: refactor `prefer_no_std`/`prefer_prelude` bools into a struct

I noticed that there's a large number of functions/arguments during an unrelated change that take two booleans and realized they're _probably_ better off being in a single struct—less error-prone, etc.

Feel free to suggest a better name than `ImportPathConfig`/close this entirely! I can also make these args enums; just hopefully making this a little more misuse-resistant.
2024-05-22 19:59:04 +00:00
Lukas Wirth
f50f8fbcb9 Simplify 2024-05-22 21:57:44 +02:00
bors
93e7cb835a Auto merge of #125415 - fmease:rollup-n2bg7q5, r=fmease
Rollup of 5 pull requests

Successful merges:

 - #124896 (miri: rename intrinsic_fallback_checks_ub to intrinsic_fallback_is_spec)
 - #125015 (Pattern types: Prohibit generic args on const params)
 - #125049 (Disallow cast with trailing braced macro in let-else)
 - #125259 (An async closure may implement `FnMut`/`Fn` if it has no self-borrows)
 - #125296 (Fix `unexpected_cfgs` lint on std)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-22 19:31:53 +00:00
Oneirical
d4e5426256 rewrite and rename issue-24445 to rmake 2024-05-22 15:25:43 -04:00
Urgau
1c7859e117 Don't suggest adding the unexpected cfgs the build-script it-self 2024-05-22 20:58:57 +02:00
David Barsky
7a21dff517 internal: refactor prefer_no_std/prefer_prelude bools into a struct 2024-05-22 20:46:30 +02:00
Oneirical
c24d1c7ff8 Rewrite core-no-oom-handling as rmake.rs 2024-05-22 14:40:41 -04:00
roife
4e9b12870c fix: check pseudo-block by local_id instead of ModuleOrigin 2024-05-23 02:39:53 +08:00
bors
ad810a51f0 Auto merge of #17277 - Veykril:find-path-fixes, r=Veykril
fix: Various find path fixes

Fixes https://github.com/rust-lang/rust-analyzer/issues/17271
2024-05-22 18:22:32 +00:00
Augie Fackler
03d5556ced cleanup: remove leftover extra block
This was needed in an older version of this patch, but never got edited
out when it became obsolete.
2024-05-22 14:04:22 -04:00
Augie Fackler
aa91871539 rustc_codegen_llvm: add support for writing summary bitcode
Typical uses of ThinLTO don't have any use for this as a standalone
file, but distributed ThinLTO uses this to make the linker phase more
efficient. With clang you'd do something like `clang -flto=thin
-fthin-link-bitcode=foo.indexing.o -c foo.c` and then get both foo.o
(full of bitcode) and foo.indexing.o (just the summary or index part of
the bitcode). That's then usable by a two-stage linking process that's
more friendly to distributed build systems like bazel, which is why I'm
working on this area.

I talked some to @teresajohnson about naming in this area, as things
seem to be a little confused between various blog posts and build
systems. "bitcode index" and "bitcode summary" tend to be a little too
ambiguous, and she tends to use "thin link bitcode" and "minimized
bitcode" (which matches the descriptions in LLVM). Since the clang
option is thin-link-bitcode, I went with that to try and not add a new
spelling in the world.

Per @dtolnay, you can work around the lack of this by using `lld
--thinlto-index-only` to do the indexing on regular .o files of
bitcode, but that is a bit wasteful on actions when we already have all
the information in rustc and could just write out the matching minimized
bitcode. I didn't test that at all in our infrastructure, because by the
time I learned that I already had this patch largely written.
2024-05-22 14:04:22 -04:00
León Orell Valerian Liehr
8219fd2bc1
Rollup merge of #125296 - tesuji:checkcfg-buildstd, r=Nilstrieb,michaelwoerister
Fix `unexpected_cfgs` lint on std

closes #125291

r? rust-lang/compiler
2024-05-22 19:04:45 +02:00
León Orell Valerian Liehr
44c7a2dbff
Rollup merge of #125259 - compiler-errors:fn-mut-as-a-treat, r=oli-obk
An async closure may implement `FnMut`/`Fn` if it has no self-borrows

There's no reason that async closures may not implement `FnMut` or `Fn` if they don't actually borrow anything with the closure's env lifetime. Specifically, #123660 made it so that we don't always need to borrow captures from the closure's env.

See the doc comment on `should_reborrow_from_env_of_parent_coroutine_closure`:

c00957a3e2/compiler/rustc_hir_typeck/src/upvar.rs (L1777-L1823)

If there are no such borrows, then we are free to implement `FnMut` and `Fn` as permitted by our closure's inferred `ClosureKind`.

As far as I can tell, this change makes `async || {}` work in precisely the set of places they used to work before #120361.
Fixes #125247.

r? oli-obk
2024-05-22 19:04:45 +02:00
León Orell Valerian Liehr
5b485f04de
Rollup merge of #125049 - dtolnay:castbrace, r=compiler-errors
Disallow cast with trailing braced macro in let-else

This fixes an edge case I noticed while porting #118880 and #119062 to syn.

Previously, rustc incorrectly accepted code such as:

```rust
let foo = &std::ptr::null as &'static dyn std::ops::Fn() -> *const primitive! {
    8
} else {
    return;
};
```

even though a right curl brace `}` directly before `else` in a `let...else` statement is not supposed to be valid syntax.
2024-05-22 19:04:44 +02:00
León Orell Valerian Liehr
b3604de1df
Rollup merge of #125015 - fmease:pat-tys-proh-gen-args-on-ct-params, r=spastorino
Pattern types: Prohibit generic args on const params

Addresses https://github.com/rust-lang/rust/pull/123689/files#r1562676629.

NB: Technically speaking, *not* prohibiting generics args on const params is not a bug as `pattern_types` is an *internal* feature and as such any uncaught misuses of it are considered to be the fault of the user. However, permitting this makes me slightly uncomfortable esp. since we might want to make pattern types available to the public at some point and I don't want this oversight to be able to slip into the language (for comparison, ICEs triggered by the use of internal features are like super fine).

Furthermore, this is an ad hoc fix. A more general fix would be changing the representation of the pattern part of pattern types in such a way that it can reuse preexisting lowering routines for exprs / anon consts. See also this [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/pattern.20type.20HIR.20nodes/near/432410768) and #124650.

Also note that we currently don't properly typeck the pattern of pat tys. This however is out of scope for this PR.

cc ``@oli-obk``
r? ``@spastorino`` as discussed
2024-05-22 19:04:44 +02:00
León Orell Valerian Liehr
76d4bfb1c6
Rollup merge of #124896 - RalfJung:miri-intrinsic-fallback, r=oli-obk
miri: rename intrinsic_fallback_checks_ub to intrinsic_fallback_is_spec

Checking UB is not the only concern, we also have to make sure we are not losing out on non-determinism.

r? ``@oli-obk`` (not urgent, take your time)
2024-05-22 19:04:43 +02:00
Michael Goulet
8369dbba43 Use correct param-env in MissingCopyImplementations 2024-05-22 12:46:08 -04:00
Rémy Rakic
5da41f59da self-contained linker: retry without -fuse-ld=lld on older GCCs 2024-05-22 16:37:12 +00:00
David Carlier
3f638a9291 solaris/illumos localtime_r / clock_getime support enabled.
clock_gettime support CLOCK_REALTIME/CLOCK_MONOTONIC clockid_t.
localtime_r is supported only tm struct is more limited than other
 supported platforms.
2024-05-22 16:06:26 +00:00
bors
22f5bdc42b Auto merge of #124686 - saethlin:rust-file-footer, r=fmease
Add a footer in FileEncoder and check for it in MemDecoder

We have a few reports of ICEs due to decoding failures, where the fault does not lie with the compiler. The goal of this PR is to add some very lightweight and on-by-default validation to the compiler's outputs. If validation fails, we emit a fatal error for rmeta files in general that mentions the path that didn't load, and for incremental compilation artifacts we emit a verbose warning that tries to explain the situation and treat the artifacts as outdated.

The validation currently implemented here is very crude, and yet I think we have 11 ICE reports currently open (you can find them by searching issues for `1002111927320821928687967599834759150`) which this simple validation would have detected. The structure of the code changes here should permit the addition of further validation code, such as a checksum, if it is merited. I would like to have code to detect corruption such as reported in https://github.com/rust-lang/rust/issues/124719, but I'm not yet sure how to do that efficiently, and this PR is already a good size.

The ICE reports I have in mind that this PR would have smoothed over are:
https://github.com/rust-lang/rust/issues/124469
https://github.com/rust-lang/rust/issues/123352
https://github.com/rust-lang/rust/issues/123376 [^1]
https://github.com/rust-lang/rust/issues/99763
https://github.com/rust-lang/rust/issues/93900.

---

[^1]: This one might be a compiler bug, but even if it is I think the workflow described is pushing the envelope of what we can support. This issue is one of the reasons this warning still asks people to file an issue.
2024-05-22 15:59:56 +00:00
Vadim Petrochenkov
711338bd9f rustc: Use tcx.used_crates(()) more
And explain when it should be used.
2024-05-22 18:02:51 +03:00
Tobias Bucher
72968e5198 Rename FrameworkOnlyWindows to RawDylibOnlyWindows
Frameworks are Apple-specific, no idea why it had "framework" in the
name before.
2024-05-22 16:29:27 +02:00
bors
d9dda8f84f Auto merge of #17279 - Veykril:format_args-escape, r=Veykril
fix: Fix format_args lowering passing incorrect parameters to `rustc_parse_format`
2024-05-22 14:12:22 +00:00
Lukas Wirth
2ff9bab2eb fix: Fix format_args lowering passing incorrect parameters to rustc_parse_format 2024-05-22 16:11:06 +02:00
bors
5d328a1f62 Auto merge of #117329 - RalfJung:offset-by-zero, r=oli-obk,scottmcm
offset: allow zero-byte offset on arbitrary pointers

As per prior `@rust-lang/opsem` [discussion](https://github.com/rust-lang/opsem-team/issues/10) and [FCP](https://github.com/rust-lang/unsafe-code-guidelines/issues/472#issuecomment-1793409130):

- Zero-sized reads and writes are allowed on all sufficiently aligned pointers, including the null pointer
- Inbounds-offset-by-zero is allowed on all pointers, including the null pointer
- `offset_from` on two pointers derived from the same allocation is always allowed when they have the same address

This removes surprising UB (in particular, even C++ allows "nullptr + 0", which we currently disallow), and it brings us one step closer to an important theoretical property for our semantics ("provenance monotonicity": if operations are valid on bytes without provenance, then adding provenance can't make them invalid).

The minimum LLVM we require (v17) includes https://reviews.llvm.org/D154051, so we can finally implement this.

The `offset_from` change is needed to maintain the equivalence with `offset`: if `let ptr2 = ptr1.offset(N)` is well-defined, then `ptr2.offset_from(ptr1)` should be well-defined and return N. Now consider the case where N is 0 and `ptr1` dangles: we want to still allow offset_from here.

I think we should change offset_from further, but that's a separate discussion.

Fixes https://github.com/rust-lang/rust/issues/65108
[Tracking issue](https://github.com/rust-lang/rust/issues/117945) | [T-lang summary](https://github.com/rust-lang/rust/pull/117329#issuecomment-1951981106)

Cc `@nikic`
2024-05-22 13:04:14 +00:00
bors
39e6032445 Auto merge of #17248 - mladedav:dm/delay-clear, r=Veykril
Clear diagnostics only after new ones were received

Closes #15934

This adds a flag inside the global state which controls when old diagnostics are cleared. Now, old diagnostics should be cleared only after at least one new diagnostic is available.
2024-05-22 13:01:08 +00:00
bors
24bf53d993 Auto merge of #17268 - Veykril:signatures, r=Veykril
feat: More callable info

With this PR we retain more info about callables other than functions, allowing for closure parameter type inlay hints to be linkable as well as better signature help around closures and `Fn*` implementors.
2024-05-22 12:48:17 +00:00
Lukas Wirth
b1830a5fe6 Update assists test fixtures 2024-05-22 14:46:33 +02:00
Lukas Wirth
b29c755572 expectify find_path tests 2024-05-22 14:05:24 +02:00
Lukas Wirth
5992af6506 fix: Fix general find-path inconsistencies 2024-05-22 14:05:24 +02:00
surechen
8fde7e3b64 For OutsideLoop we should not suggest add 'block label in if block, or we wiil get another err: block label not supported here.
fixes #123261
2024-05-22 19:47:32 +08:00
Jakub Beránek
ab73bb25cf
Add a comment 2024-05-22 13:04:14 +02:00
bors
f0038a7c8f Auto merge of #124227 - compiler-errors:hack-check-method-res, r=estebank
Make sure that the method resolution matches in `note_source_of_type_mismatch_constraint`

`note_source_of_type_mismatch_constraint` is a pile of hacks that I implemented to cover up another pile of hacks.

It does a bunch of re-confirming methods, but it wasn't previously checking that the methods it was looking (back) up were equal to the methods we previously had. This PR adds those checks.

Fixes #118185
2024-05-22 10:57:59 +00:00
Guillaume Gomez
fc76015dcb Migrate run-make/rustdoc-scrape-examples-macros to rmake.rs 2024-05-22 11:49:21 +02:00
Ralf Jung
cb5319483e clarify comment
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
2024-05-22 11:19:04 +02:00
bors
7fd1429754 Auto merge of #3623 - RalfJung:rustup, r=RalfJung
Rustup
2024-05-22 09:10:54 +00:00
Ralf Jung
abbe244a81 clippy 2024-05-22 11:09:34 +02:00
Scott McMurray
8ee3d29cd9 Stop using to_hir_binop in codegen 2024-05-22 01:34:26 -07:00
bors
bec10295d4 Auto merge of #125335 - compiler-errors:binder, r=lcnr
Uplift `Binder`, `OutlivesPredicate` into `rustc_type_ir`

Almost done with all the types 🙏

r? lcnr
2024-05-22 08:33:34 +00:00