Commit Graph

29631 Commits

Author SHA1 Message Date
Santiago Pastorino
8cf94c955f
Fix occurrences of old fn names in comment and tracing 2023-11-20 22:45:28 -03:00
bors
61a3eea804 Auto merge of #117229 - matthewjasper:thir-unsafeck-fixes, r=cjgillot
Thir unsafeck fixes

- Recognise thread local statics in THIR unsafeck
- Add suggestion for unsafe_op_in_unsafe_fn
- Fix unsafe checking of let expressions
2023-11-07 10:41:10 +00:00
bors
114f1f6838 Auto merge of #117610 - compiler-errors:object-hmm, r=aliemjay
Only instantiate binder during dyn's built-in trait candidate probe once

See UI test for demonstration of the issue.

This was "caused" by #117131, but only because we're using the `normalize_param_env` (which has been augmented with a projection clause used to normalize GATs) which features non-lifetime bound vars in it.

Fixes #117602 technically, though that's also fixed by #117542.

r? types
2023-11-07 08:43:08 +00:00
bors
504f63efb0 Auto merge of #117418 - compiler-errors:better_error_body, r=oli-obk
Build a better MIR body when errors are encountered

Doesn't really have much of an effect on its own, but it does lead to a less confusing phony MIR body being generated when an error is detected during THIR/MIR/match building. This was quite confusing when I hacked `-Zunpretty=mir` to emit `mir_built` rather than `instance_mir`.

This coincidentually also fixes #117413, but not as generally as #117416.

cc `@Nadrieril`
2023-11-07 06:42:20 +00:00
bors
4e0fb98a5c Auto merge of #117006 - estebank:issue-69512, r=compiler-errors
When not finding assoc fn on type, look for builder fn

When we have a resolution error when looking at a fully qualified path on a type, look for all associated functions on inherent impls that return `Self` and mention them to the user.

```
error[E0599]: no function or associated item named `new` found for struct `TcpStream` in the current scope
   --> tests/ui/resolve/fn-new-doesnt-exist.rs:4:28
    |
4   |    let stream = TcpStream::new();
    |                            ^^^ function or associated item not found in `TcpStream`
    |
note: if you're trying to build a new `TcpStream` consider using one of the following associated functions:
      TcpStream::connect
      TcpStream::connect_timeout
   --> /home/gh-estebank/rust/library/std/src/net/tcp.rs:156:5
    |
156 |     pub fn connect<A: ToSocketAddrs>(addr: A) -> io::Result<TcpStream> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
172 |     pub fn connect_timeout(addr: &SocketAddr, timeout: Duration) -> io::Result<TcpStream> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
Fix #69512.
2023-11-07 02:05:30 +00:00
Esteban Küber
f926031ea5 When not finding assoc fn on type, look for builder fn
When we have a resolution error when looking at a fully qualified path
on a type, look for all associated functions on inherent impls that
return `Self` and mention them to the user.

Fix #69512.
2023-11-07 00:54:10 +00:00
bors
7b97a5ca84 Auto merge of #117511 - gurry:117406-err-packed-structs, r=compiler-errors
Emit explanatory note for move errors in packed struct derives

Derive expansions for packed structs with non-`Copy` fields cause move errors because they prefer copying over borrowing since borrowing the fields of a packed struct can result in unaligned access.

This underlying cause of the errors, however, is not apparent to the user. This PR adds a diagnostic note to make it clear to the user (the new note is on the second last line):

```
tests/ui/derives/deriving-with-repr-packed-move-errors.rs:13:16
   |
12 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)]
   |          ----- in this derive macro expansion
13 | struct StructA(String);
   |                ^^^^^^ move occurs because `self.0` has type `String`, which does not implement the `Copy` trait
   |
   = note: `#[derive(Debug)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
   = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
```

Fixes #117406

Partially addresses #110777
2023-11-07 00:03:53 +00:00
Michael Goulet
5a9f07cc97 Build a better MIR body when errors are encountered 2023-11-06 23:54:53 +00:00
Michael Goulet
171d5587ca Don't instantiate the binder twice when assembling object candidate 2023-11-06 23:41:33 +00:00
Michael Goulet
24e14dd8b4 Only check predicates for late-bound non-lifetime vars in object candidate assembly 2023-11-06 23:25:32 +00:00
bors
189d6c71f3 Auto merge of #117641 - matthiaskrgr:rollup-f9c12td, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #117190 (add test for #113381)
 - #117516 (add test for #113375)
 - #117631 (Documentation cleanup for core::error::Request.)
 - #117637 (Check binders with bound vars for global bounds that don't hold)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-06 21:43:55 +00:00
Matthias Krüger
9efe60b1eb
Rollup merge of #117637 - lqd:trivial-bounds-with-binder-vars, r=compiler-errors
Check binders with bound vars for global bounds that don't hold

This fixes `soa_derive-0.13.0` from #117589's crater run.

r? `@compiler-errors`
2023-11-06 20:31:56 +01:00
bors
fb61292105 Auto merge of #117292 - estebank:issue-80446, r=davidtwco
Detect misparsed binop caused by missing semi

When encountering

```rust
foo()
*bar = baz;
```

We currently emit potentially two errors, one for the return type of
`foo` not being multiplicative by the type of `bar`, and another for
`foo() * bar` not being assignable.

We now check for this case and suggest adding a semicolon in the right
place and emit only a single error.

Fix #80446.
2023-11-06 18:46:04 +00:00
Esteban Küber
4b7aacaa4f Silence redundant error on typo resulting on binop 2023-11-06 17:38:06 +00:00
Matthew Jasper
868de8e76b Visit patterns in THIR let expressions
This fixes some THIR unsafety checking errors not being emitted for
let expressions in these situations.
2023-11-06 16:23:09 +00:00
Matthew Jasper
2b59992736 Add suggestion to THIR unsafe_op_in_unsafe_fn lint 2023-11-06 16:23:09 +00:00
Matthew Jasper
931692fa13 Recognise thread local statics in THIR unsafeck 2023-11-06 16:23:08 +00:00
bors
aea82b268a Auto merge of #117603 - HKalbasi:make-feature-additive, r=Nilstrieb
Make the randomize feature of rustc_abi additive

The goal here is to make rust-analyzer able to build with the `rustc_private` versions of the rustc crates it depends on. See #116847
2023-11-06 16:17:49 +00:00
Rémy Rakic
2beca157c9 check binders with bound vars for global bounds that don't hold
(instead of just late bound vars)
2023-11-06 15:46:17 +00:00
bors
e1fcecb1b9 Auto merge of #117630 - matthiaskrgr:rollup-v0d5p3f, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #117592 (Use the correct span when emitting the `env!` result)
 - #117613 (Remove from vacation and compiler review group)
 - #117615 (Couple of small changes)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-06 12:08:40 +00:00
Matthias Krüger
b88d62e222
Rollup merge of #117615 - bjorn3:misc_changes, r=davidtwco
Couple of small changes

These are unrelated to each other, but they are each small enough that opening separate PR's doesn't make sense to me either.

* Remove a place where the parse driver query is stolen.
* Update an outdated doc comment
* Use correct crate name in `-Zprint-vtable-sizes` when using `#![crate_name = "..."]`.
2023-11-06 11:28:19 +01:00
Matthias Krüger
60dca87cff
Rollup merge of #117592 - thomcc:env-span-wrong, r=davidtwco
Use the correct span when emitting the `env!` result

The span used for the `env!` resut changed in 1.73, due to 75df62d4a2 (from https://github.com/rust-lang/rust/pull/114014).

This prevents [a lint in `plrustc`](https://github.com/tcdi/plrust/blob/main/plrustc/plrustc/src/lints/builtin_macros.rs#L54-L60)[^1] from working well, because the resulting span is not inside the  region where the lint is `#[deny()]`ed.

[^1]: Perhaps worth noting that the `env_macro` diagnostic item comes from [the std fork used with PL/Rust](https://github.com/tcdi/postgrestd/blob/rust-1.73.0/library/core/src/macros/mod.rs#L944).

Unfortunately, I have no idea how to write a test for this since I don't think we can have a custom lint in a test. A suggestion was made to use a custom proc macro for it, but that seems pretty involved (frankly, I might not have time to do it).

r? ``@davidtwco`` (since they're the author of the PR with the regression)

P.S. We generally try to avoid bothering upstream about PL/Rust-specific stuff (we don't want to nag), but this seems like an actual bug, since the other similar macros, such as `option_env` use the other span (and are lintable as a result).
2023-11-06 11:28:18 +01:00
bors
6bf2fb3679 Auto merge of #117578 - compiler-errors:derive-encode-in-rustc_type_ir, r=davidtwco
Derive `TyEncodable`/`TyDecodable` in `rustc_type_ir`

when `derive(TyEncodable)` or `derive(TyDecodable)` sees an `I` type parameter on a struct that has no `'tcx`, then parameterize the `TyEncoder`/`TyDecoder`'s interner over that variable rather than `TyCtxt<'tcx>`.

Also, emit where clauses for fields rather than generics.
2023-11-06 10:10:52 +00:00
bors
f9b644636f Auto merge of #117435 - SparrowLii:nightly_parallel, r=oli-obk,davidtwco
enable parallel rustc front end in nightly builds

Refers to the [MCP](https://github.com/rust-lang/compiler-team/issues/681), this pr does:
1. Enable the parallel front end in nightly builds, and keep the default number of threads as 1. Then users can use the parallel rustc front end via -Z threads=n option.

2. Set it up to serial front end for beta/stable builds via bootstrap.

3. Switch over the alt builders from parallel rustc to serial, so we have artifacts without parallel to test against the artifacts with parallel.

r? `@oli-obk`

cc `@cjgillot` `@nnethercote` `@bjorn3` `@Kobzol`
2023-11-06 07:41:22 +00:00
bors
152a4e90d1 Auto merge of #117585 - dnbln:feat/move-kw-span, r=cjgillot
Add the `Span` of the `move` keyword to the HIR.

This is required to implement a lint like the one described here: https://github.com/rust-lang/rust-clippy/issues/11721
2023-11-06 02:07:34 +00:00
SparrowLii
f2a40e99ff use portable AtomicU64 for powerPC and MIPS 2023-11-06 09:58:51 +08:00
hkalbasi
c8a25eddfe Make the randomize feature of rustc_abi additive 2023-11-05 21:51:47 +03:30
bjorn3
ec29a02071 Update doc comment for CodegenBackend::link 2023-11-05 16:29:16 +00:00
bjorn3
ba82056a14 Use the actual computed crate name for -Zprint-vtable-sizes 2023-11-05 16:29:15 +00:00
bjorn3
1a1b10fa63 Don't steal the parse query when using --pretty
This is the only place aside from the global_ctxt query where it is
stolen.
2023-11-05 16:29:15 +00:00
bors
992943dbae Auto merge of #117537 - GKFX:offset-of-enum-feature, r=cjgillot
Feature gate enums in offset_of

As requested at https://github.com/rust-lang/rust/issues/106655#issuecomment-1790815262, put enums in offset_of behind their own feature gate.

`@rustbot` label F-offset_of
2023-11-05 13:44:59 +00:00
Matthias Krüger
629ee74337
Rollup merge of #117588 - bjorn3:remove_unused_error_variant, r=cjgillot
Remove unused LoadResult::DecodeIncrCache variant
2023-11-05 12:41:47 +01:00
bors
f64d028196 Auto merge of #117589 - compiler-errors:global-vars-bug, r=jackh726
Make sure that predicates with unmentioned bound vars are still considered global in the old solver

In the old solver, we consider predicates with late-bound vars to not be "global":
9c8a2694fa/compiler/rustc_trait_selection/src/traits/select/mod.rs (L1840-L1844)

The implementation of `has_late_bound_vars` was modified in #115834 so that we'd properly anonymize binders that had late-bound vars but didn't reference them. This fixed an ICE.

However, this also led to a behavioral change in https://github.com/rust-lang/rust/issues/117056#issuecomment-1775014545 for a couple of crates, which now consider `for<'a> GL33: Shader` (note the binder var that is *not* used in the predicate) to not be "global". This forces associated types to not be normalizable due to the old trait solver being dumb.

This PR distinguishes types which *reference* late-bound vars and binders which *have* late-bound vars. The latter is represented with the new type flag `TypeFlags::HAS_BINDER_VARS`, which is used when we only care about knowing whether binders have vars in their bound var list (even if they're not used, like for binder anonymization).

This should fix (after beta backport) the `luminance-gl` and `luminance-webgl` crates in #117056.

r? types
**(priority is kinda high on a review here given beta becomes stable on November 16.)**
2023-11-05 03:58:09 +00:00
bors
4b85902b43 Auto merge of #117590 - matthiaskrgr:rollup-9cqh1q8, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #110340 (Deref docs: expand and remove "smart pointer" qualifier)
 - #116894 (Guarantee that `char` has the same size and alignment as `u32`)
 - #117534 (clarify that the str invariant is a safety, not validity, invariant)
 - #117562 (triagebot no-merges: exclude different case)
 - #117570 (fallback for `construct_generic_bound_failure`)
 - #117583 (Remove `'tcx` lifetime on `PlaceholderConst`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-04 21:15:09 +00:00
Thom Chiovoloni
86fca873ba
Use the correct span when emitting the env! result 2023-11-04 14:04:01 -07:00
Matthias Krüger
8912a2b551
Rollup merge of #117583 - compiler-errors:placeholderconst-lifetime, r=cjgillot
Remove `'tcx` lifetime on `PlaceholderConst`

The `'tcx` lifetime is not needed for anything, so this is a continuation of #117139.
2023-11-04 21:38:30 +01:00
Matthias Krüger
a47c137f3a
Rollup merge of #117570 - bvanjoi:fix-117547, r=cjgillot
fallback for `construct_generic_bound_failure`

Fixes #117547

This case regressed at #115882.

In this context, `generic_param_scope` is produced by `RPITVisitor` and not included by `hir_owner`. Therefore, I've added a fallback to address this.
2023-11-04 21:38:29 +01:00
Michael Goulet
32294fc0ed Make sure that predicates with unmentioned bound vars are still considered global in the old solver 2023-11-04 20:36:21 +00:00
bjorn3
a3b964b9ea Remove unused LoadResult::DecodeIncrCache variant 2023-11-04 20:16:03 +00:00
Dinu Blanovschi
876f698790 Add the vis.visit_capture_by() in noop_visit_expr 2023-11-04 21:11:03 +01:00
Dinu Blanovschi
54ce0346c0 add fn visit_capture_by to MutVisitor and fix pprust-expr-roundtrip.rs 2023-11-04 21:04:54 +01:00
George Bateman
00a9ed34b1
De-indent closing bracket
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2023-11-04 19:50:21 +00:00
Dinu Blanovschi
df85b28b72 fixes for rustfmt + ast visitor 2023-11-04 20:39:15 +01:00
bors
a42d94ebb8 Auto merge of #113343 - saethlin:looser-alignment, r=RalfJung
Update the alignment checks to match rust-lang/reference#1387

Previously, we had a special case to not check `Rvalue::AddressOf` in this pass because we weren't quite sure if pointers needed to be aligned in the Place passed to it: https://github.com/rust-lang/rust/pull/112026

Since https://github.com/rust-lang/reference/pull/1387 merged, this PR updates this pass to match. The behavior of the check is nearly unchanged, except we also avoid inserting a check for creating references. Most of the changes in this PR are cleanup and new tests.
2023-11-04 19:17:02 +00:00
Dinu Blanovschi
a6b41aa6ba fmt 2023-11-04 20:04:02 +01:00
Dinu Blanovschi
241a654c07 Fix remaining uses of CaptureBy::Value 2023-11-04 19:48:44 +01:00
Dinu Blanovschi
8de489918b feat(hir): Store the Span of the move keyword 2023-11-04 19:39:32 +01:00
Michael Goulet
bcb97ea221 No lifetime on PlaceholderConst 2023-11-04 17:36:44 +00:00
Ben Kimock
f9bd7dabcf Check alignment of pointers only when read/written through 2023-11-04 13:01:32 -04:00
Michael Goulet
bee7b5889e Derive TyEncodable/TyDecodable implementations that are parameterized over interner 2023-11-04 16:44:42 +00:00