Commit Graph

29983 Commits

Author SHA1 Message Date
Esteban Küber
a7e035ab89 Point at impl self ty on type error involving Self
When encountering a type error involving a `Self` literal, point at the
self type of the enclosing `impl`.

CC #76086.
2023-11-16 16:19:19 +00:00
Esteban Küber
4e418805da More detail when expecting expression but encountering bad macro argument
Partially address #71039.
2023-11-16 16:19:04 +00:00
bors
0ea7ddcc35 Auto merge of #117956 - saethlin:provenance-gc-access, r=RalfJung
Let Miri see the AllocId for all TyCtxt allocations

Per https://github.com/rust-lang/miri/pull/3103#discussion_r1391589896

r? `@RalfJung`
2023-11-16 15:15:54 +00:00
Ali MJ Al-Nasrawy
af79fd109b ignore implied bounds with placeholders 2023-11-16 14:25:35 +00:00
Ben Kimock
d7cecd3db2 Let Miri see the AllocId for all TyCtxt allocations 2023-11-16 08:30:49 -05:00
bors
1be1e84872 Auto merge of #117875 - Mark-Simulacrum:bootstrap-bump, r=clubby789
Bootstrap bump

Bumps bootstrap compiler to just-released beta.

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2023-11-16 12:45:27 +00:00
bors
48d8100543 Auto merge of #117930 - thomcc:const_str-unnamed, r=nikic
Ensure strings created with `const_str` get the `unnamed_addr` attribute

This function (`const_str`) is only used when we need to invent a string during codegen -- for example, for a panic message to pass when codegening some of the assert/panic/etc terminators (for stuff like divide by zero).

AFAICT all other consts, such as the user-defined ones from const eval, should already be getting this attribute (things that come from a ConstAllocation do, for example). Which means that the "unnamed" part is even more true than usual here, these aren't strings that even exist as far as the user can tell.

~~Setting this attribute allows LLVM to merge these constants, leading to significant binary size savings (much more than I would expect). On x86_64-unknown-linux-gnu, t takes a build of ripgrep (release without debug info) from 9.7MiB to 6.0MiB (a savings of over 30%!?), and a build of rustc_driver's shared object from 123MiB to 112MiB (less drastic, but still over 10% reduced).~~

~~The effect on ripgrep is substantially reduced on macOS for reasons beyond me (I may have fucked up the test), only saving around 0.2MiB, although rustc_driver is still around 10MB or smaller than it had been previously.~~

~~This raises some questions, such as "does that mean 1/3 of ripgrep was made of division by zero complaints?" I'm not sure, that may be the case. The output of `strings path/to/rg` is \~2MB smaller, so it seems like a lot of it was. Allowing these to be merged presumably also allow functions that contain them to be merged (if the addresses had semantic meaning, then it stands).~~

~~I intend to do some more analysis here, but I got this up as soon as I realized that this attribute was only missing for internal const strings, and all other ones already get it.~~

Edit: The wins are much more marginal, but there's some argument to do this for the sake of consistency.
2023-11-16 08:43:05 +00:00
Esteban Küber
890ce26213 When using existing fn as module, don't claim it doesn't exist
Tweak wording of module not found in resolve, when the name exists but
belongs to a non-`mod` item.

Fix #81232.
2023-11-16 06:07:33 +00:00
Nicholas Nethercote
8f669f558a Reduce exposure of things. 2023-11-16 16:49:22 +11:00
bors
6faa181015 Auto merge of #117948 - aeubanks:dibuilder, r=durin42
llvm-wrapper: Pass newly added param to DIBuilder::createStaticMemberType()

This was added in https://github.com/llvm/llvm-project/pull/72234.
DW_TAG_member was the implicit default before.

The LLVM change is quite sinister since due to weakly typed ints and default params, this was still successfully compiling against LLVM but was passing the wrong parameters.
2023-11-16 03:14:51 +00:00
Mark Rousskov
9e8edb6659 Add check-cfg to cranelift 2023-11-15 21:45:48 -05:00
Mark Rousskov
917f6540ed Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
Mark Rousskov
db3e2bacb6 Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
Mark Rousskov
efe54e24aa Substitute version placeholders 2023-11-15 19:40:51 -05:00
bors
9144d51175 Auto merge of #117954 - aeubanks:dibuilder2, r=durin42
llvm-wrapper: Pass newly added param to DIBuilder::createEnumerationType()

Added in LLVM in https://github.com/llvm/llvm-project/pull/72011.
2023-11-16 00:03:50 +00:00
Arthur Eubanks
7cde2cee35 llvm-wrapper: Pass newly added param to DIBuilder::createEnumerationType()
Added in LLVM in https://github.com/llvm/llvm-project/pull/72011.
2023-11-15 14:42:53 -08:00
Arthur Eubanks
e2c3e94be9 17 -> 18 2023-11-15 13:15:55 -08:00
Arthur Eubanks
984898da17 [llvm-wrapper] Pass newly added param to DIBuilder::createStaticMemberType()
This was added in https://github.com/llvm/llvm-project/pull/72234.
DW_TAG_member was the implicit default before.
2023-11-15 11:29:35 -08:00
bors
6b771f6b5a Auto merge of #117878 - gavinleroy:proper-depth-check, r=lcnr
Fix depth check in ProofTreeVisitor.

The hack to cutoff overflows and cycles in the new trait solver was incorrect. We want to inspect everything with depth [0..10].

This fix exposed a previously unseen bug, which caused the compiler to ICE when invoking `trait_ref` on a non-assoc type projection. I simply added the guard in the `AmbiguityCausesVisitor`, and updated the expected output for the `auto-trait-coherence` test which now includes the extra note:
```text
   |
   = note: upstream crates may add a new impl of trait `std::marker::Send` for type `OpaqueType` in future versions
```

r? `@lcnr`
2023-11-15 18:53:04 +00:00
bors
0b24479638 Auto merge of #116555 - paulmenage:llvm-module-flag, r=wesleywiser
Add -Z llvm_module_flag

Allow adding values to the `!llvm.module.flags` metadata for a generated module.  The syntax is

`-Z llvm_module_flag=<name>:<type>:<value>:<behavior>`

Currently only u32 values are supported but the type is required to be specified for forward compatibility.  The `behavior` element must match one of the named LLVM metadata behaviors.viors.

This flag is expected to be perma-unstable.
2023-11-15 16:54:31 +00:00
bors
d4559c01c2 Auto merge of #117819 - fmease:rustc_parse_format-stable-rustc, r=Nilstrieb
Make `rustc_parse_format` compile on stable again

Fixes [#115948 (review comment)](8222335596 (r1385932710)).
cc `@Veykril` `@notriddle`

r? compiler
2023-11-15 14:55:35 +00:00
bors
1500db7314 Auto merge of #117908 - lcnr:region-kind-rename, r=BoxyUwU
finish `RegionKind` renaming

second step of https://github.com/rust-lang/types-team/issues/95

continues the work from #117876. While working on this and I encountered a bunch of further cleanup which I'll either open a tracking issue for or will do in a separate PR:
- rewrite the `RegionKind` docs, they still talk about `ReEmpty` and are generally out of date
- rename `DescriptionCtx` to `DescriptionCtxt`
- what is `CheckRegions::Bound`?
- `collect_late_bound_regions` et al
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased`?
- `EraseEarlyRegions` visitor should be removed, feels duplicate

r? `@BoxyUwU`
2023-11-15 12:55:42 +00:00
bors
383bf020f2 Auto merge of #117848 - compiler-errors:method-ambiguity-no-rcvr, r=TaKO8Ki
Don't expect a rcvr in `print_disambiguation_help`

We don't necessarily have a receiver when we are both accidentally using the `.` operator *AND* we have more than one ambiguous method candidate.

Fixes #117728
2023-11-15 10:58:50 +00:00
Artyom Tetyukhin
a78720807c
Add arm64e-apple-darwin target 2023-11-15 14:56:27 +04:00
Artyom Tetyukhin
f5e3492194
Add arm64e-apple-ios target 2023-11-15 14:55:18 +04:00
bors
ee85f7fc48 Auto merge of #117814 - RalfJung:rustc-logger-without-set-var, r=TaKO8Ki
rustc_log: provide a way to init logging based on the values, not names, of the env vars

Miri wants to affect how rustc does logging. So far this required setting environment variables before calling `rustc_driver::init_rustc_env_logger`. However, `set_var` is a function one should really [avoid calling](https://github.com/rust-lang/rust/issues/90308), so this adds the necessary APIs to rustc such that Miri can just pass it the *values* of all the log-relevant environment variables, rather than having to change the global environment.
2023-11-15 08:03:07 +00:00
Thom Chiovoloni
268f5c57b9 Ensure strings created with const_str get the unnamed_addr attribute 2023-11-15 07:56:40 +00:00
bors
698fcc8219 Auto merge of #117517 - klinvill:smir-projections, r=ouz-a
Add richer structure for Stable MIR Projections

Resolves https://github.com/rust-lang/project-stable-mir/issues/49.

Projections in Stable MIR are currently just strings. This PR replaces that representation with a richer structure, namely projections become vectors of `ProjectionElem`s, just as in MIR. The `ProjectionElem` enum is heavily based off of the MIR `ProjectionElem`.

This PR is a draft since there are several outstanding issues to resolve, including:

- How should `UserTypeProjection`s be represented in Stable MIR? In MIR, the projections are just a vector of `ProjectionElem<(),()>`, meaning `ProjectionElem`s that don't have Local or Type arguments (for `Index`, `Field`, etc. objects). Should `UserTypeProjection`s be represented this way in Stable MIR as well? Or is there a more user-friendly representation that wouldn't drag along all the `ProjectionElem` variants that presumably can't appear?
- What is the expected behavior of a `Place`'s `ty` function? Should it resolve down the chain of projections so that something like `*_1.f` would return the type referenced by field `f`?
- Tests should be added for `UserTypeProjection`
2023-11-15 06:05:54 +00:00
Nicholas Nethercote
000767564e Remove unused features. 2023-11-15 15:40:57 +11:00
Kirby Linvill
c036a10ed5
Make UserTypeProjection projections Opaque
Also shifts comments explaining why Stable MIR drops an optional variant
name field, for `Downcast` projection elements, to the `Place::stable`
function.
2023-11-14 19:19:35 -07:00
bors
6d069a0ac7 Auto merge of #117359 - tmiasko:call-def, r=cjgillot
Fix def-use check for call terminators

Fixes #117331.
2023-11-15 01:31:46 +00:00
lcnr
18281d39cf fix doc link 2023-11-15 01:24:44 +00:00
Matthias Krüger
2e00c6ffd7
Rollup merge of #117911 - catandcoder:master, r=lqd
Fix some typos
2023-11-14 21:50:39 +01:00
Matthias Krüger
52f3a6fdb2
Rollup merge of #117893 - sjwang05:issue-52544-take-1, r=wesleywiser
Suggest dereferencing the LHS for binops such as `&T == T`

Fixes #52544
2023-11-14 21:50:39 +01:00
Matthias Krüger
7435887d6c
Rollup merge of #117834 - RalfJung:target-feature-stability, r=b-naber
target_feature: make it more clear what that 'Option' means

Reading those tables in compiler/rustc_codegen_ssa/src/target_features.rs, it's not immediately clear that `None` means "stable". Let's use an enum with appropriately named variants to make that more obvious.
2023-11-14 21:50:38 +01:00
Matthias Krüger
d2cdf6c479
Rollup merge of #117686 - compiler-errors:gen-body, r=wesleywiser
Build pre-coroutine-transform coroutine body on error

I was accidentally building the post-transform coroutine body, rather than the pre-transform coroutine body. There's no pinning expected here yet, and the return type isn't yet transformed into `CoroutineState`.

Fixes #117670
2023-11-14 21:50:38 +01:00
Tomasz Miąsko
6873465600 Fix def-use check for call terminators 2023-11-14 17:07:34 +01:00
bors
8d57ad1ade Auto merge of #117849 - compiler-errors:cycle, r=cjgillot
make `LayoutError::Cycle` carry `ErrorGuaranteed`

Addresses a FIXME, and also I think it's wise for error variants to carry their `ErrorGuaranteed` -- makes it easier to use that `ErrorGuaranteed` for creating, e.g. `TyKind::Error` and other error kinds. Splitting out from #117703.
2023-11-14 16:04:29 +00:00
cui fliter
a44a4edc0e Fix some typos
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-11-14 23:06:50 +08:00
lcnr
8fcbd1991f review + fix CI 2023-11-14 13:41:28 +00:00
lcnr
15f21562e6 finish RegionKind rename
- `ReFree` -> `ReLateParam`
- `ReEarlyBound` -> `ReEarlyParam`
2023-11-14 13:13:27 +00:00
bors
d97bb195bf Auto merge of #117787 - ouz-a:smir_coroutinewitness, r=celinval
Add CoroutineWitness to covered types in smir

Previously we accepted `CouroutineWitness` as `unreachable!` but https://github.com/rust-lang/project-stable-mir/issues/50 shows it is indeed reachable, this pr fixes that and covers `CouroutineWitness`
2023-11-14 13:10:25 +00:00
Gavin Gray
caae1e08ec Add guard checking for associated types before computing intercrate ambiguity of projections. Bless test with more specific notes on the ambiguity cause. 2023-11-14 13:55:59 +01:00
bors
fa14810f21 Auto merge of #117731 - nnethercote:rustc_macros, r=Nilstrieb
`rustc_macros` cleanups

Just some improvements I found while reading over this code.

r? `@Nilstrieb`
2023-11-14 10:55:42 +00:00
bors
5526682702 Auto merge of #117330 - tmiasko:custom-mir-cleanup-blocks, r=cjgillot
Custom MIR: Support cleanup blocks

Cleanup blocks are declared with `bb (cleanup) = { ... }`.

`Call` and `Drop` terminators take an additional argument describing the unwind action, which is one of the following:

* `UnwindContinue()`
* `UnwindUnreachable()`
* `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup`
* `UnwindCleanup(block)`

Also support unwind resume and unwind terminate terminators:

* `UnwindResume()`
* `UnwindTerminate(reason)`
2023-11-14 08:53:25 +00:00
Tomasz Miąsko
78da577650 Custom MIR: Support cleanup blocks
Cleanup blocks are declared with `bb (cleanup) = { ... }`.

`Call` and `Drop` terminators take an additional argument describing the
unwind action, which is one of the following:

* `UnwindContinue()`
* `UnwindUnreachable()`
* `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup`
* `UnwindCleanup(block)`

Also support unwind resume and unwind terminate terminators:

* `UnwindResume()`
* `UnwindTerminate(reason)`
2023-11-14 08:23:58 +01:00
bors
173b6e686b Auto merge of #117856 - estebank:issue-66023, r=compiler-errors
Always point at index span on index obligation failure

Use more targetted span for index obligation failures by rewriting the obligation cause span.

CC #66023
2023-11-14 06:20:25 +00:00
bors
5777f2c6bd Auto merge of #117801 - tmiasko:remove-zsts-fuel, r=cjgillot
Remove incorrect transformation from RemoveZsts

Partial removal of storage statements for a local is incorrect, so a decision to optimize cannot be make independently for each statement.

Avoid the issue by performing the transformation completely or not at all.
2023-11-14 04:22:56 +00:00
bors
d5375d0587 Auto merge of #117773 - nnethercote:rm-Zperf-stats, r=wesleywiser
Remove `-Zperf-stats`.

The included measurements have varied over the years. At one point there were quite a few more, but #49558 deleted a lot that were no longer used. Today there's just four, and it's a motley collection that doesn't seem particularly valuable.

I think it has been well and truly subsumed by self-profiling, which collects way more data.

r? `@wesleywiser`
2023-11-14 02:24:05 +00:00
Esteban Küber
f830fe313b Detect more => typos
Handle and recover `match expr { pat >= { arm } }`.
2023-11-14 00:46:37 +00:00
sjwang05
614ddc9695
Suggest lhs deref for binops 2023-11-13 16:25:16 -08:00
Michael Goulet
a8a2ee4e8f Recover dyn and impl after for<...> 2023-11-14 00:15:10 +00:00
bors
ba7c7a3019 Auto merge of #117887 - matthiaskrgr:rollup-rgur03f, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #114224 (rustc_llvm: Link to libkstat on Solaris/SPARC)
 - #117695 (Reorder checks to make sure potential missing expect on Option/Result…)
 - #117870 (`fn args_ref_X` to `fn args_X`)
 - #117879 (tests: update check for inferred nneg on zext)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-13 21:47:18 +00:00
Matthias Krüger
a87ad4e2a7
Rollup merge of #117870 - lcnr:rename-args_ref, r=compiler-errors
`fn args_ref_X` to `fn args_X`
2023-11-13 21:28:55 +01:00
Matthias Krüger
918c17acc3
Rollup merge of #117695 - 3tilley:prioritise-unwrap-expect-over-last-method-call, r=compiler-errors
Reorder checks to make sure potential missing expect on Option/Result…

… runs before removing last method call

Fixes #117669
2023-11-13 21:28:55 +01:00
Matthias Krüger
03d6e7ade0
Rollup merge of #114224 - inferiorhumanorgans:solaris-llvm-wrapper, r=cuviper
rustc_llvm: Link to libkstat on Solaris/SPARC

getHostCPUName calls into libkstat but as of
LLVM 16.0.6 libLLVMTargetParser is not explicitly
linked against libkstat causing builds to fail
due to undefined symbols.

See also: llvm/llvm-project#64186
2023-11-13 21:28:54 +01:00
Esteban Küber
5061c09c58 review comments: more targeted span setting approach 2023-11-13 19:57:15 +00:00
bors
85b8450466 Auto merge of #116866 - slanterns:inspect-stabilize, r=BurntSushi
Stabilize `result_option_inspect`

This PR stabilizes `result_option_inspect`:

```rust
// core::option

impl Option<T> {
    pub fn inspect<F: FnOnce(&T)>(self, f: F) -> Self;
}

// core::result

impl Result<T, E> {
    pub fn inspect<F: FnOnce(&T)>(self, f: F) -> Self;
    pub fn inspect_err<F: FnOnce(&E)>(self, f: F) -> Self;
}
```

<br>

Tracking issue: https://github.com/rust-lang/rust/issues/91345.
Implementation PR: https://github.com/rust-lang/rust/pull/91346.

Closes https://github.com/rust-lang/rust/issues/91345.
2023-11-13 19:46:18 +00:00
Josh Stone
855388e9a2
Mention LLVM 64186 in a comment 2023-11-13 11:04:53 -08:00
bors
531cb83fcf Auto merge of #117881 - TaKO8Ki:rollup-n7jtmgj, r=TaKO8Ki
Rollup of 5 pull requests

Successful merges:

 - #117737 (Remove `-Zkeep-hygiene-data`.)
 - #117830 (Small improvements in object lifetime default code)
 - #117858 (Compute layout with spans for better cycle errors in coroutines)
 - #117863 (Remove some unused stuff from `rustc_index`)
 - #117872 (Cranelift isn't available on non-nightly channels)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-13 17:29:00 +00:00
Takayuki Maeda
19bffe1ea6
Rollup merge of #117863 - nnethercote:rustc_index, r=Mark-Simulacrum
Remove some unused stuff from `rustc_index`

r? `@Mark-Simulacrum`
2023-11-14 00:54:17 +09:00
Takayuki Maeda
cf21b6ef28
Rollup merge of #117858 - compiler-errors:span, r=lcnr
Compute layout with spans for better cycle errors in coroutines

Split out from #117703, this PR at least gives us a nicer span to point at when we hit a cycle error in coroutine layout cycles.
2023-11-14 00:54:16 +09:00
Takayuki Maeda
826b181cef
Rollup merge of #117830 - Nilstrieb:object-lifetime-default-nits, r=cjgillot
Small improvements in object lifetime default code

I found those while trying to understand how the code works.
2023-11-14 00:54:16 +09:00
Takayuki Maeda
bf8cf456b6
Rollup merge of #117737 - nnethercote:rm-Zkeep-hygiene-data, r=petrochenkov
Remove `-Zkeep-hygiene-data`.

It was added way back in #28585 under the name `-Zkeep-mtwt-tables`. The justification was:

> This is so that the resolution results can be used after analysis,
> potentially for tool support.

There are no uses of significance in the code base, and various Google searches for both option names (and variants) found nothing of interest. I think this can safely be removed.

r? `@davidtwco`
2023-11-14 00:54:15 +09:00
Gavin Gray
60d99ab883 Fix overflow and cycle bound for ProofTreeVisitor. 2023-11-13 16:36:01 +01:00
bors
4bd2fd5c83 Auto merge of #117876 - lcnr:region-kind-rename, r=BoxyUwU
`ReLateBound` -> `ReBound`

first step of https://github.com/rust-lang/types-team/issues/95

already fairly large xx

there's some future work here I intentionally did not contribute as part of this PR, from my notes:
- `DescriptionCtx` to `DescriptionCtxt`
- what is `CheckRegions::Bound`?
- `collect_late_bound_regions` et al
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased`?
- `EraseEarlyRegions` should be removed, feels duplicate

r? `@BoxyUwU`
2023-11-13 15:33:01 +00:00
lcnr
8935a1be01 update type flags
- `HAS_RE_LATE_BOUND` -> `HAS_RE_BOUND`
- `HAS_TY_LATE_BOUND` -> `HAS_TY_BOUND`
- `HAS_CT_LATE_BOUND` -> `HAS_CT_BOUND`
- `HAS_LATE_BOUND` -> `HAS_BOUND_VARS`
- `fn has_late_bound_regions` -> `fn has_bound_regions`
- `fnhas_non_region_late_bound` -> `fn has_non_region_bound_vars`
- `fn has_late_bound_vars` -> `fn has_bound_vars`
2023-11-13 14:13:54 +00:00
lcnr
dd0739aabe continue renaming
- `RegionVariableOrigin::~~Late~~BoundRegion`
- `~~Late~~BoundRegionConversionTime`
2023-11-13 14:13:54 +00:00
lcnr
86fa1317a3 rename ReLateBound to ReBound
other changes:
- `Region::new_late_bound` -> `Region::new_bound`
- `Region::is_late_bound` -> `Region::is_bound`
2023-11-13 14:13:54 +00:00
lcnr
28328c8389 remove unnecessary _ in variable name 2023-11-13 14:13:54 +00:00
lcnr
85883503c3 add fixme to RegionCtxt 2023-11-13 14:13:54 +00:00
bors
1ab2bcda43 Auto merge of #117811 - MU001999:master, r=lcnr
Turn assert_eq into a delay_span_bug

Fixes #117789
2023-11-13 12:17:22 +00:00
lcnr
42945fc1e2 args~~_ref~~_may_unify 2023-11-13 11:27:15 +00:00
Ralf Jung
6dd2ea0f35 features must be additive 2023-11-13 09:41:45 +01:00
bors
c225c45bce Auto merge of #117862 - SpeedReach:patch-1, r=nnethercote
Fix comment in compiler/rustc_ast/src/token.rs.

Gt -> Greater than -> `>`
Ge -> Greater equal -> `>=`
2023-11-13 08:14:01 +00:00
bors
b5cdb9631f Auto merge of #117827 - Zalathar:bogus-macro-name-span, r=davidtwco
coverage: Avoid creating malformed macro name spans

This is a workaround for #117788. It detects a particular scenario where we would create malformed coverage spans that might cause `llvm-cov` to immediately exit with an error, preventing the user from processing coverage reports.

The patch has been kept as simple as possible so that it's trivial to backport to beta (or stable) if desired.

---

The `maybe_push_macro_name_span` method is trying to detect macro invocations, so that it can split a span into two parts just after the `!` of the invocation.

Under some circumstances (probably involving nested macros), it gets confused and produces a span that is larger than the original span, and possibly extends outside its enclosing function and even into an adjacent file.

In extreme cases, that can result in malformed coverage mappings that cause `llvm-cov` to fail. For now, we at least want to detect these egregious cases and avoid them, so that coverage reports can still be produced.
2023-11-13 06:16:27 +00:00
Nicholas Nethercote
82e396a4ba Remove unnecessary annotation. 2023-11-13 17:09:26 +11:00
Nicholas Nethercote
2433542b41 Remove IndexSlice::convert_index_type. 2023-11-13 17:00:48 +11:00
Nicholas Nethercote
8b18c16ecb Remove impl FiniteBitSetTy for {u64,u128}.
Only the impl for `u32` is used. These can be reinstated easily if
needed in the future.
2023-11-13 16:44:20 +11:00
Nicholas Nethercote
b7cf697a6d Remove BitSet::to_hybrid. 2023-11-13 16:26:26 +11:00
Nicholas Nethercote
06faf589ac Remove BitSet::words. 2023-11-13 16:24:16 +11:00
Sleep_AllDay
8c0ae83723
Fix comment
Gt => Greater than => `>`
Ge => Greater equal => `>=`
2023-11-13 13:15:55 +08:00
Michael Goulet
7994b5849c Compute layout with spans for better cycle errors in coroutines 2023-11-13 02:22:25 +00:00
bors
ea1e5cc91f Auto merge of #117770 - sjwang05:issue-117766, r=estebank,TaKO8Ki
Catch stray `{` in let-chains

Fixes #117766
2023-11-13 01:57:59 +00:00
Esteban Küber
69634f2077 Always point at index span on index obligation failure
Use more targetted span for index obligation failures by rewriting the
obligation cause span.

CC #66023
2023-11-13 00:52:10 +00:00
Mu001999
62b6529e03 Turn assert_eq into a delay_span_bug 2023-11-13 08:36:12 +08:00
sjwang05
274824b917
Fix is_keyword_ahead visibility
Co-authored-by: Takayuki Maeda <takoyaki0316@gmail.com>
2023-11-12 14:46:01 -08:00
Nicholas Nethercote
aefbb616af Remove -Zperf-stats.
The included measurements have varied over the years. At one point there
were quite a few more, but #49558 deleted a lot that were no longer
used. Today there's just four, and it's a motley collection that doesn't
seem particularly valuable.

I think it has been well and truly subsumed by self-profiling, which
collects way more data.
2023-11-13 09:45:20 +11:00
Michael Goulet
99664b0bbf Don't expect a rcvr in print_disambiguation_help 2023-11-12 19:59:13 +00:00
Michael Goulet
121d9f5b16 make LayoutError::Cycle carry ErrorGuaranteed 2023-11-12 18:59:18 +00:00
Nilstrieb
e5c330ac48 Note about object lifetime defaults in does not live long enough error
This is a aspect of Rust that frequently trips up people who are not
aware of it yet. This diagnostic attempts to explain what's happening
and why the lifetime constraint, that was never mentioned in the source,
arose.
2023-11-12 13:51:16 +01:00
Ralf Jung
31493c70fa interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch 2023-11-12 12:49:46 +01:00
Ralf Jung
5b5006916b target_feature: make it more clear what that 'Option' means 2023-11-12 12:46:05 +01:00
Nilstrieb
8bcd221b4c Small improvements in object lifetime default code
I found those while trying to understand how the code works.
2023-11-12 11:59:01 +01:00
Ralf Jung
f6a49ba416 patterns: don't ice when encountering a raw str slice 2023-11-12 09:43:08 +01:00
Zalathar
ed8298b825 coverage: Avoid creating malformed macro name spans
This method is trying to detect macro invocations, so that it can split a span
into two parts just after the `!` of the invocation.

Under some circumstances (probably involving nested macros), it gets confused
and produces a span that is larger than the original span, and possibly extends
outside its enclosing function and even into an adjacent file.

In extreme cases, that can result in malformed coverage mappings that cause
`llvm-cov` to fail. For now, we at least want to detect these egregious cases
and avoid them, so that coverage reports can still be produced.
2023-11-12 18:33:11 +11:00
bors
a04d56b36d Auto merge of #117817 - fmease:deny-more-tilde-const, r=fee1-dead
Deny more `~const` trait bounds

thereby fixing a family of ICEs (delayed bugs) for `feature(const_trait_impl, effects)` code.

As discussed
r? `@fee1-dead`
2023-11-12 04:40:44 +00:00
Paul Menage
2e6b57541d Add -Z llvm_module_flag
Allow adding values to the `!llvm.module.flags` metadata for a generated
module.  The syntax is

`-Z llvm_module_flag=<name>:<type>:<value>:<behavior>`

Currently only u32 values are supported but the type is required to be
specified for forward compatibility.  The `behavior` element must match
one of the named LLVM metadata behaviors.viors.

This flag is expected to be perma-unstable.
2023-11-11 19:48:47 -08:00
León Orell Valerian Liehr
8ce5d784a6
Deny more ~const trait bounds 2023-11-12 00:00:12 +01:00
sjwang05
f88cf0206f
Move unclosed delim errors to separate function 2023-11-11 13:39:08 -08:00
BlackHoleFox
b27c3b7f21 Remove legacy bitcode from all Apple specs 2023-11-11 15:12:21 -06:00
bors
2c1b65ee14 Auto merge of #115694 - clarfonthey:std-hash-private, r=dtolnay
Add `std:#️⃣:{DefaultHasher, RandomState}` exports (needs FCP)

This implements rust-lang/libs-team#267 to move the libstd hasher types to `std::hash` where they belong, instead of `std::collections::hash_map`.

<details><summary>The below no longer applies, but is kept for clarity.</summary>
This is a small refactor for #27242, which moves the definitions of `RandomState` and `DefaultHasher` into `std::hash`, but in a way that won't be noticed in the public API.

I've opened rust-lang/libs-team#267 as a formal ACP to move these directly into the root of `std::hash`, but for now, they're at least separated out from the collections code in a way that will make moving that around easier.

I decided to simply copy the rustdoc for `std::hash` from `core::hash` since I think it would be ideal for the two to diverge longer-term, especially if the ACP is accepted. However, I would be willing to factor them out into a common markdown document if that's preferred.
</details>
2023-11-11 21:12:20 +00:00
León Orell Valerian Liehr
732b4bb664
Make rustc_parse_format compile on stable again 2023-11-11 15:48:13 +01:00
Ralf Jung
581a317bbb rustc_log: provide a way to init logging based on the values, not names, of the env vars 2023-11-11 15:24:33 +01:00
Tomasz Miąsko
d7d2e761e0 Remove incorrect transformation from RemoveZsts
Partial removal of storage statements for a local is incorrect, so a
decision to optimize cannot be make independently for each statement.

Avoid the issue by performing the transformation completely or not at
all.
2023-11-11 01:51:09 +01:00
Kirby Linvill
ae1726bfce
Ignore FieldIdx and VariantIdx examples in docs 2023-11-10 17:18:59 -07:00
bors
edf0b1db0a Auto merge of #115229 - iSwapna:issue-115222-fix, r=estebank
On method chain expression failure, look for missing method in earlier segments of the chain

This PR tries to fix the issue: https://github.com/rust-lang/rust/issues/115222

As suggested by `@estebank` , I did the following:
1. Add new test `tests/ui/structs/method-chain-expression-failure.rs`
2. In `compiler/rusct_hir_tycheck/src/method/suggest.rs`
   walking up the method chain and calling `probe_for_name` with the method name. But the call fails to return `Ok`.
2023-11-10 21:10:30 +00:00
Swapna Iyer
56a109d15b Recurse over the method chain and maintain a stack to peek at previous receiver to align spans 2023-11-10 13:00:27 -08:00
sjwang05
a49368f00b
Correctly handle while-let-chains 2023-11-10 12:13:53 -08:00
Kirby Linvill
d517a1cbda
Add SMIR visitor for Places and projections 2023-11-10 11:25:58 -07:00
Oğuz Ağcayazı
6812f64c35 add CoroutineWitness to covered types 2023-11-10 17:02:08 +03:00
bjorn3
d186b49460 Merge commit 'c84d1871dc4456539b7b578830268ab3539915d0' into sync_cg_clif-2023-11-10 2023-11-10 11:30:51 +00:00
sjwang05
9455259450
Catch an edge case 2023-11-09 20:07:17 -08:00
Kirby Linvill
998aa383ba
Defer Place ty implementation in Stable Mir to later PR 2023-11-09 20:56:40 -07:00
Kirby Linvill
2e70d95cdb
Remove rich UserTypeProjection projections in SMIR
It's not clear to me (klinvill) that UserTypeProjections are produced
anymore with the removal of type ascriptions as per
https://github.com/rust-lang/rfcs/pull/3307. Furthermore, it's not clear
to me which variants of ProjectionElem could appear in such projections.
For these reasons, I'm reverting projections in UserTypeProjections to
simple strings until I can get more clarity on UserTypeProjections.
2023-11-09 20:56:40 -07:00
Kirby Linvill
b1585983cc
Add stable MIR Projections support based on MIR structure
This commit includes richer projections for both Places and
UserTypeProjections. However, the tests only touch on Places. There are
also outstanding TODOs regarding how projections should be resolved to
produce Place types, and regarding if UserTypeProjections should just
contain ProjectionElem<(),()> objects as in MIR.
2023-11-09 20:56:35 -07:00
Nicholas Nethercote
2e40d11f8c Remove -Zkeep-hygiene-data.
It was added way back in #28585 under the name `-Zkeep-mtwt-tables`. The
justification was:

> This is so that the resolution results can be used after analysis,
> potentially for tool support.

There are no uses of significance in the code base, and various Google
searches for both option names (and variants) found nothing of interest.

@petrochenkov says removing this part (and it's only part) of the
hygiene data is dubious. It doesn't seem that big, so let's just keep it
around.
2023-11-10 14:00:08 +11:00
sjwang05
0094238157
Catch stray { in let-chains 2023-11-09 18:47:49 -08:00
Matthias Krüger
7607597d3a
Rollup merge of #117743 - sjwang05:issue-117720, r=estebank
Suggest removing `;` for `;` within let-chains

Fixes #117720
2023-11-10 01:50:25 +01:00
Matthias Krüger
7fd7719ca1
Rollup merge of #117741 - eltociear:patch-23, r=compiler-errors
Fix typo in internal.rs

covert -> convert
2023-11-10 01:50:25 +01:00
Nicholas Nethercote
dd6bab9eff Factor out some duplicated code. 2023-11-10 10:54:26 +11:00
Nicholas Nethercote
316ffba3c8 Update instructions in a comment.
And avoid duplication.
2023-11-10 10:54:26 +11:00
Nicholas Nethercote
b35e576657 Minor cleanups.
- Reduce some function exposure.
- Fix some comment formatting.
2023-11-10 10:54:26 +11:00
Nicholas Nethercote
49908b4d90 Simplify the current_rustc_version macro.
It currently has the syntax
`current_rustc_version!(env!("CFG_RELEASE"))` where the
`env!("CFG_RELEASE")` part looks like a normal expression but it is
actually parsed and processed by the `current_rustc_version` macro.

The documented rationale for this is that you'll find it if you grep for
`env!("CFG_RELEASE")`. But I think that's of very little use -- I would
personally grep for just "CFG_RELEASE" -- and it complicates the macro,
requiring the use of `syn`.

This commit simplifies the macro.
2023-11-10 10:54:21 +11:00
bors
0f44eb32f1 Auto merge of #117727 - saethlin:inline-derived-fmt, r=nnethercote
Emit #[inline] on derive(Debug)

While working on https://github.com/rust-lang/rust/pull/116583 I noticed that the `cross_crate_inlinable` query identifies a lot of derived `Debug` impls as a MIR body that's little more than a call, which suggests they may be a good candidate for `#[inline]`. So here I've implemented that change specifically.

It seems to provide a nice improvement to build times.
2023-11-09 21:34:14 +00:00
Ben Kimock
d32d9238cf Emit #[inline] on derive(Debug) 2023-11-09 10:40:55 -05:00
bors
b7583d38b7 Auto merge of #117712 - lcnr:expand-coroutine, r=jackh726
generator layout: ignore fake borrows

fixes #117059

We emit fake shallow borrows in case the scrutinee place uses a `Deref` and there is a match guard. This is necessary to prevent the match guard from mutating the scrutinee: fab1054e17/compiler/rustc_mir_build/src/build/matches/mod.rs (L1250-L1265)

These fake borrows end up impacting the generator witness computation in `mir_generator_witnesses`, which causes the issue in #117059. This PR now completely ignores fake borrows during this computation. This is sound as thse are always removed after analysis and the actual computation of the generator layout happens afterwards.

Only the second commit impacts behavior, and could be backported by itself.

r? types
2023-11-09 14:23:45 +00:00
bors
e7998aa21f Auto merge of #117734 - nnethercote:rm-Zstrip, r=davidtwco
Remove `-Z strip`.

It was stabilized as `-C strip` in November 2021. The unstable option was kept around as a temporary measure to ease the transition. Two years is more than enough!

r? `@tmandry`
2023-11-09 12:26:28 +00:00
lcnr
fce71adf31 remove stability assert in evaluate_goal 2023-11-09 11:32:51 +01:00
lcnr
442e112d17 update overflow handling for norm, add test 2023-11-09 11:32:51 +01:00
lcnr
e3850f404d rework alias-relate to norm(lhs) == norm(rhs) 2023-11-09 11:32:50 +01:00
lcnr
1c54494888 only instantiate opaques with rigid types 2023-11-09 11:32:12 +01:00
lcnr
1f12f1cc83 try_normalize_ty end with rigid alias on failure 2023-11-09 11:31:22 +01:00
bors
287ae4db75 Auto merge of #117632 - Nilstrieb:icup, r=davidtwco
Update ICU4X

This updates all ICU4X crates and regenerates rustc_baked_icu_data.

Since the new unicode license under which they are licensed does not have an SPDX identifier yet, we define some exceptions. The license has to be reviewed to make sure it is still fine to use here, but I assume that is the case.

I also added an exception for rustc_icu_data to the unexplained ignore doctest tidy lint. This is a bit hacky but the whole style.rs in tidy is a mess so I didn't want to touch it more than this small hack.

part of #112865

r? `@davidtwco` `@wesleywiser` `@Manishearth`
2023-11-09 09:00:57 +00:00
sjwang05
5693a34db2
Suggest fix for ; within let-chains 2023-11-09 00:31:42 -08:00
Ikko Eltociear Ashimine
b8648216a5
Fix typo in internal.rs
covert -> convert
2023-11-09 16:10:37 +09:00
Takayuki Maeda
b4fa5b7004
Rollup merge of #117694 - jmillikin:core-io-borrowed-buf, r=m-ou-se
Move `BorrowedBuf` and `BorrowedCursor` from `std:io` to `core::io`

Tracking issue: https://github.com/rust-lang/rust/issues/117693

ACP: https://github.com/rust-lang/libs-team/issues/290
2023-11-09 11:36:52 +09:00
Takayuki Maeda
4cc549811f
Rollup merge of #117645 - compiler-errors:auto-trait-subst, r=petrochenkov
Extend builtin/auto trait args with error when they have >1 argument

Reuse `extend_with_error` to add error args to any auto trait (or built-in trait like `Copy` that is defined incorrectly) that has additional non-`Self` args.

Fixes #117628
2023-11-09 11:36:52 +09:00
bors
d8dbf7ca0e Auto merge of #117557 - Zoxc:panic-prio, r=petrochenkov
Make `FatalErrorMarker` lower priority than other panics

This makes `FatalErrorMarker` lower priority than other panics in a parallel sections. If any other panics occur, they will be unwound instead of `FatalErrorMarker`. This ensures `rustc` will exit with the correct error code on ICEs.

This fixes https://github.com/rust-lang/rust/issues/116659.
2023-11-09 00:39:02 +00:00
Nicholas Nethercote
ecc936b155 Remove -Z strip.
It was stabilized as `-C strip` in November 2021. The unstable option
was kept around as a temporary measure to ease the transition. Two years
is more than enough!
2023-11-09 11:36:02 +11:00
John Millikin
341c85648c Move BorrowedBuf and BorrowedCursor from std:io to core::io
Assigned new feature name `core_io_borrowed_buf` to distinguish from the
`Read::read_buf` functionality in `std::io`.
2023-11-09 07:10:11 +09:00
lcnr
992d93f687 rename BorrowKind::Shallow to Fake
also adds some comments
2023-11-08 22:55:28 +01:00
lcnr
a42eca42df generator layout: ignore fake borrows 2023-11-08 22:55:28 +01:00
bors
fdaaaf9f92 Auto merge of #116930 - RalfJung:raw-ptr-match, r=davidtwco
patterns: reject raw pointers that are not just integers

Matching against `0 as *const i32` is fine, matching against `&42 as *const i32` is not.

This extends the existing check against function pointers and wide pointers: we now uniformly reject all these pointer types during valtree construction, and then later lint because of that. See [here](https://github.com/rust-lang/rust/pull/116930#issuecomment-1784654073) for some more explanation and context.

Also fixes https://github.com/rust-lang/rust/issues/116929.

Cc `@oli-obk` `@lcnr`
2023-11-08 20:42:32 +00:00
Ralf Jung
30588657b7 avoid unnecessary nested conditionals 2023-11-08 20:37:08 +01:00
bors
90fdc1fc27 Auto merge of #117716 - GuillaumeGomez:rollup-83gnhll, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #117263 (handle the case when the change-id isn't found)
 - #117282 (Recover from incorrectly ordered/duplicated function keywords)
 - #117679 (tests/rustdoc-json: Avoid needless use of `no_core` and `lang_items`)
 - #117702 (target: move base and target specifications)
 - #117713 (Add test for reexported hidden item with `--document-hidden-items`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-08 18:33:23 +00:00
Guillaume Gomez
d8c52b378d
Rollup merge of #117702 - davidtwco:target-tier-refactors, r=petrochenkov
target: move base and target specifications

Follow-up to #116004.

In anticipation of later PRs where we'll want to add tidy checks to ensure that, for each target, we have a test or a platform support document or something like that, this PR moves target specifications into a directory on their own so that we can just list the files in this directory to get a list of all targets.

- Base specifications are moved to `rustc_target::spec::base`.
- Target specifications are moved to `rustc_target::spec::targets`.
- All the other source files containing types used in the target specs remain in `rustc_target::spec`.
  - `rustc_target/src/spec/abi.rs` is moved to `rustc_target/src/spec/abi/mod.rs` (where there was already a `tests.rs`) for uniformity.

r? ``@petrochenkov``
2023-11-08 17:14:37 +01:00
Guillaume Gomez
c828371179
Rollup merge of #117282 - clubby789:recover-wrong-function-header, r=TaKO8Ki
Recover from incorrectly ordered/duplicated function keywords

Fixes #115714
2023-11-08 17:14:36 +01:00
bors
341efb1017 Auto merge of #117560 - lqd:issue-117146, r=matthewjasper
Compute polonius loan scopes over the region graph

In issue #117146 a loan flows into an SCC containing a placeholder, and whose representative is an existential region. Since we currently compute loan scopes by looking at SCCs and their representatives only, polonius would compute kill points for this loan here whereas NLLs would not of course.

There are a few ways to fix this:
- don't try to be efficient by doing the computation over SCCs, and simply look for free regions and placeholders in the successors of the issuing region.
- change how the SCC representatives are picked, biasing towards placeholders over existential regions. They *shouldn't* matter much, but some downstream code may subtly depend on the current scheme (though no tests fail if we do such a change). This is for unrelated reasons also the way #116891 changes the representative computation. So that PR would also fix issue #117146.
- try to remove placeholders from the main path, and contain them to a pre-pass + a post-pass kind of polonius leak check. If possible, it would fix this issue by turning an outlives constraints to a placeholder into a constraint to 'static. This should also fix the issue, as the representative would be the free region in the SCC. We want to prototype this change to see if it's possible to try to simplify the borrowck main path from having to deal with placeholders and higher-ranked subtyping 🤞.

I'd like to take advantage of fuzzing and a crater run sooner rather than later, so that we grow more confidence that the 2 models are indeed equivalent empirically. Therefore this PR implements option 1 to fix the issue now.

We can take care of efficiency later after validation, and once we implement option 3 (which could also impact option 2 and that associated PR, maybe the lack of placeholders could remove the need to change the representative computation) to traverse SCCs and their representative again.

(Or we maybe will have some kind of naive position-dependent outlives propagation by then and this code would have been changed)

Fixes #117146.

r? `@matthewjasper`
2023-11-08 16:13:37 +00:00
Max Tilley
1854776fa9 Reorder type mismatch suggestions
Suggestions are reordered to to make sure potential missing expect on Option/Result runs
before the suggestion to remove the last method call
2023-11-08 14:15:25 +00:00
bors
755629fe59 Auto merge of #117706 - matthiaskrgr:rollup-lscx7dg, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #114316 (Add AIX platform support document)
 - #117531 (rustdoc: properly elide cross-crate host effect args)
 - #117650 (Add -Zcross-crate-inline-threshold=yes)
 - #117663 (bump some deps)
 - #117667 (Document clippy_config in nightly-rustc docs)
 - #117698 (Clarify `space_between`)
 - #117700 (coverage: Rename the `run-coverage` test mode to `coverage-run`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-08 12:06:04 +00:00
lcnr
bf360d407e instrument constituent types computation 2023-11-08 12:24:42 +01:00
Matthias Krüger
55306535dd
Rollup merge of #117698 - nnethercote:space_between-2, r=petrochenkov
Clarify `space_between`

r? ``@petrochenkov``
2023-11-08 11:25:56 +01:00
Matthias Krüger
8198864377
Rollup merge of #117650 - saethlin:inline-me-please, r=davidtwco
Add -Zcross-crate-inline-threshold=yes

``@thomcc`` says this would be useful for

>  seeing if it makes a difference in some code if i do it when building the sysroot, since -Zbuild-std + lto helps more than it seems like it should

And I've changed the possible values as a reference to ``@Manishearth`` saying

> LLVM's inlining heuristic is "yes".
2023-11-08 11:25:54 +01:00
bors
fab1054e17 Auto merge of #117542 - compiler-errors:only-normalize-predicate, r=lcnr
Only use `normalize_param_env` when normalizing predicate in `check_item_bounds`

Only use the `normalize_param_env` when normalizing the item bound predicate in `check_item_bounds`, instead of using it when processing this obligation as well. This causes <BUG> to reoccur, but hopefully with better caching in the future, we can fix this would having such bad effects on perf.

This PR also fixes #117598. It turns out that the GAT predicate that we install is actually wrong -- given code like:

```
impl<'r> HasValueRef<'r> for Any {
    type Database = Any;
}
```

We currently generate a predicate that looks like `<Any as HasValueRef<'r>>::Database = Any`, where `'r` is an early-bound variable. Really this GAT assumption should be universally quantified over the impl's args, i.e. `for<'r> <Any as HasValueRef<'r>>::Database = Any`, but then we'd need the binder to also include all the WC of the impl as well, which we don't support yet, lol.
2023-11-08 10:08:44 +00:00
David Wood
ef7ebaa788
rustc_target: move file for uniformity
Signed-off-by: David Wood <david@davidtw.co>
2023-11-08 14:37:54 +08:00
David Wood
1af256fe8a
targets: move target specs to spec/targets
Signed-off-by: David Wood <david@davidtw.co>
2023-11-08 14:25:45 +08:00
David Wood
76aa83e3e1
target: move base specs to spec/base
Signed-off-by: David Wood <david@davidtw.co>
2023-11-08 14:15:26 +08:00
Nicholas Nethercote
783d4b8b26 Clarify space_between.
To avoid `!matches!(...)`, which is hard to think about. Instead every
case now uses direct pattern matching and returns true or false.

Also add a couple of cases to the `stringify.rs` test that currently
print badly.
2023-11-08 14:39:59 +11:00
Michael Goulet
97c9d8f405 Only use normalize_param_env when normalizing predicate in check_item_bounds 2023-11-08 02:35:25 +00:00
Matthias Krüger
f72e974e3f
Rollup merge of #117655 - compiler-errors:method-tweaks, r=estebank
Method suggestion code tweaks

I was rummaging around the method suggestion code after https://github.com/rust-lang/rust/pull/117006#discussion_r1384153722 and saw a few things to simplify.

This is two unrelated commits, both in the same file. Review them separately, if you'd like.

r? estebank
2023-11-08 00:47:52 +01:00
Matthias Krüger
7552dd19ad
Rollup merge of #117625 - nnethercote:clippy-perf, r=cuviper
Fix some clippy perf lints

`@matthiaskrgr` gave me the output of a clippy run with perf lints enabled. This PR fixes ones that I thought were worth fixing.

r? `@cuviper`
2023-11-08 00:47:51 +01:00
Matthias Krüger
3c6307240c
Rollup merge of #116399 - WaffleLapkin:erase_small_things, r=cjgillot
Small changes w/ `query::Erase<_>`

r? `@cjgillot`
cc `@Zoxc`
2023-11-08 00:47:51 +01:00
Matthias Krüger
b724d9c90e
Rollup merge of #113925 - clubby789:const-ctor-repeat, r=estebank
Improve diagnostic for const ctors in array repeat expressions

Fixes #113912
2023-11-08 00:47:50 +01:00
Ben Kimock
fcdd99edca Add -Zcross-crate-inline-threshold=yes 2023-11-07 18:45:11 -05:00
Nicholas Nethercote
1b3733e5a4 rustc: minor changes suggested by clippy perf lints. 2023-11-08 08:57:57 +11:00
Michael Goulet
0ba7d19769 Build pre-coroutine-transform coroutine body 2023-11-07 21:14:43 +00:00
Maybe Waffle
eca9a1533f Add an explanation for transmute_unchecked 2023-11-07 20:31:55 +00:00
Matthias Krüger
518fe492f1
Rollup merge of #117675 - zmodem:vectorize_h, r=durin42
llvm-wrapper: Remove include of non-existant Vectorize.h

LLVM recently removed the header: 2400c54c37

It only contained a declaration of `createLoadStoreVectorizerPass()`, which Rust doesn't reference.
2023-11-07 19:29:57 +01:00
Matthias Krüger
f8c67704f2
Rollup merge of #117616 - RalfJung:unstable-target-features, r=compiler-errors
warn when using an unstable feature with -Ctarget-feature

Setting or unsetting the wrong target features can cause ABI incompatibility (https://github.com/rust-lang/rust/issues/116344, https://github.com/rust-lang/rust/issues/116558). We need to carefully audit features for their ABI impact before stabilization. I just learned that we currently accept arbitrary unstable features on stable and if they are in the list of Rust target features, even unstable, then we don't even warn about that!1 That doesn't seem great, so I propose we introduce a warning here.

This has an obvious loophole via `-Ctarget-cpu`. I'm not sure how to best deal with that, but it seems better to fix what we can and think about the other cases later, maybe once we have a better idea for how to resolve the general mess that are ABI-affecting target features.
2023-11-07 19:29:56 +01:00
Matthias Krüger
cd5b5e08fe
Rollup merge of #115485 - DaniPopes:rustdoc-macro-consts, r=jackh726,fmease
Format macro const literals with pretty printer

Fixes #115295
2023-11-07 19:29:56 +01:00
Ralf Jung
0865a2ec78 test and fix some more targets 2023-11-07 17:21:02 +01:00
Hans Wennborg
752a6132e5 llvm-wrapper: Remove include of non-existant Vectorize.h 2023-11-07 16:40:35 +01:00
bors
187d1afa9d Auto merge of #117297 - clubby789:fn-trait-missing-paren, r=TaKO8Ki
Give a better diagnostic for missing parens in Fn* bounds

Fixes #108109

It would be nice to try and recover here, but I'm not sure it's worth the effort, especially as the bounds on the recovered function would be incorrect.
2023-11-07 13:04:56 +00: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
Michael Goulet
0add056dee Rework print_disambiguation_help 2023-11-07 05:23:09 +00:00
Michael Goulet
88a37acb26 Yeet MethodCallComponents 2023-11-07 05:13:22 +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
Michael Goulet
c17d33f1df Extend builtin/auto trait args with error when they have >1 argument 2023-11-06 21:29:08 +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
Nilstrieb
ffffc2038f Update ICU4X
This updates all ICU4X crates and regenerates rustc_baked_icu_data.

Since the new unicode license under which they are licensed does not
have an SPDX identifier yet, we define some exceptions. The license has
to be reviewed to make sure it is still fine to use here, but I assume
that is the case.

I also added an exception for rustc_icu_data to the unexplained ignore
doctest tidy lint. This is a bit hacky but the whole style.rs in tidy is
a mess so I didn't want to touch it more than this small hack.
2023-11-06 13:42:20 +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