Commit Graph

22672 Commits

Author SHA1 Message Date
bors
81be7b86d3 Auto merge of #108821 - matthiaskrgr:rollup-cmkbgpr, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #107801 (const_eval: `implies_by` in `rustc_const_unstable`)
 - #108750 (Fix `ObligationCtxt::sub`)
 - #108780 (Add regression tests for issue 70919)
 - #108786 (Check for free regions in MIR validation)
 - #108790 (Do not ICE when interpreting a cast between non-monomorphic types)
 - #108803 (Do not ICE when failing to normalize in ConstProp.)
 - #108807 (Emit the suspicious_auto_trait_impls for negative impls as well)
 - #108812 (Add regression test for #98444)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-06 22:15:55 +00:00
Michael Goulet
16e2b9f662 Place binder correctly for arbitrary trait bound suggestion 2023-03-06 16:37:34 +00:00
Nikita Popov
2c7beeda90 Remove references to PassManagerBuilder
This is a legacy PM concept that we no longer use.
2023-03-06 16:55:52 +01:00
Matthias Krüger
3279f7ed77
Rollup merge of #108807 - MU001999:lint/suspicious_auto_trait_impls, r=lcnr
Emit the suspicious_auto_trait_impls for negative impls as well

Fixes #108804
2023-03-06 16:42:00 +01:00
Matthias Krüger
ab7dd09fc2
Rollup merge of #108803 - cjgillot:const-prop-normalize, r=oli-obk
Do not ICE when failing to normalize in ConstProp.

There is no reason to delay a bug there, as we bubble up the failure as TooGeneric.

Fixes https://github.com/rust-lang/rust/issues/97728
2023-03-06 16:41:59 +01:00
Matthias Krüger
3ae047b8f1
Rollup merge of #108790 - cjgillot:mono-cast, r=oli-obk
Do not ICE when interpreting a cast between non-monomorphic types

Fixes https://github.com/rust-lang/rust/issues/101596
2023-03-06 16:41:59 +01:00
Matthias Krüger
4bd6f7fe16
Rollup merge of #108786 - saethlin:free-regions-check, r=oli-obk
Check for free regions in MIR validation

This turns https://github.com/rust-lang/rust/issues/108720 into a MIR validation failure that will reproduce without debug-assertions enabled.

```
error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:296 ~ futures_util[3805]::future::future::remote_handle::{impl#3}::poll), const_param_did: None }) (after pass ScalarReplacementOfAggregates) at bb0[0]:
                                Free regions in optimized runtime-post-cleanup MIR
  --> /home/ben/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/future/future/remote_handle.rs:96:13
   |
96 |         let this = self.project();
   |             ^^^^
```
2023-03-06 16:41:58 +01:00
Matthias Krüger
6240b54966
Rollup merge of #108750 - compiler-errors:aaaaaaaa, r=lcnr
Fix `ObligationCtxt::sub`

typo it seems
2023-03-06 16:41:57 +01:00
Matthias Krüger
9c99a4ca2b
Rollup merge of #107801 - davidtwco:stability-implies-const, r=Nilstrieb
const_eval: `implies_by` in `rustc_const_unstable`

Fixes #107605.

Extend support for `implies_by` (from `#[stable]` and `#[unstable]`) to `#[rustc_const_stable]` and `#[rustc_const_unstable]`.

cc ``@steffahn``
2023-03-06 16:41:56 +01:00
bors
f63ccaf25f Auto merge of #108402 - clubby789:diag-bool-not-unit, r=davidtwco
Allow using `bool` instead of `Option<()>` in diagnostics

~~Disallow the unit type for `#[help]`, `#[note]` etc, instead using `bool` to express optional annotations without a span which I believe is more intuitive.~~

~~Test output ordering has changed in a few places, where a field was of type `()` and the annotation has been moved to the struct itself. If any of these changes are an issue, this can be restricted to allowing specifically `()`, and not `Option<()>`~~

~~Actual changes here: https://github.com/rust-lang/rust/pull/108402/files#diff-815b1d8debfc564112bd51093791d7c3f2ee288a37a8f5c0e89c11d1f609b4c0~~

Allows using `bool` in derive diagnostics to indicate an optional subdiagnostic without a span, where previously `Option<()>` had to be used

`@rustbot` label +A-diagnostics
2023-03-06 13:00:32 +00:00
Mu42
2fe288fd29 emit the suspicious_auto_trait_impls for negative impls as well 2023-03-06 20:04:33 +08:00
Camille GILLOT
8c0cbd8767 Do not ICE when failing to normalize in ConstProp. 2023-03-06 09:28:49 +00:00
bors
ac4379fea9 Auto merge of #108787 - cjgillot:sroa-lifetime, r=compiler-errors
Erase regions even when failing to normalize type in MIR opts

The first commit just moves the tests around.

Fixes https://github.com/rust-lang/rust/issues/108720

cc `@saethlin`
2023-03-06 08:31:28 +00:00
Camille GILLOT
858eab6391 Do not ICE when casting polymorphic values. 2023-03-05 20:55:32 +00:00
Matthias Krüger
5c49f0885e
Rollup merge of #108775 - cjgillot:issue-107860, r=compiler-errors
Use the correct bound vars in return type suggestion.

Fixes https://github.com/rust-lang/rust/issues/107860
2023-03-05 20:57:23 +01:00
Matthias Krüger
970f263156
Rollup merge of #108770 - GuillaumeGomez:improve-doc-and-naming, r=cjgillot
Improve documentation and argument naming of some TyCtxt methods

I got bit by this recently so better prevent others to end up the same as me.
2023-03-05 20:57:22 +01:00
Matthias Krüger
1c2f641e15
Rollup merge of #108764 - cjgillot:dpm-adapt, r=compiler-errors
Tweaks to -Zdrop-tracking-mir

Split from https://github.com/rust-lang/rust/pull/107421

3 commits: 1 diagnostic improvement and 2 ICEs.
2023-03-05 20:57:21 +01:00
Matthias Krüger
b8762321a2
Rollup merge of #108746 - compiler-errors:rpitit-dont-project-default-w-no-valu, r=cjgillot
Don't project to RPITIT that has no default value

Replicates this behavior, but for RPITIT projection logic (which currently is separate)

b1719530f4/compiler/rustc_trait_selection/src/traits/project.rs (L2105-L2115)

Fixes #108738
2023-03-05 20:57:20 +01:00
clubby789
3eeb3fd05a Remove allow(potential_query_instability) from borrowck 2023-03-05 18:59:19 +00:00
Ben Kimock
cb4ebc1453 Check for free regions in MIR validation 2023-03-05 13:46:20 -05:00
Camille GILLOT
fc1a861558 Erase lifetimes in SROA. 2023-03-05 18:35:30 +00:00
Antoni Boucher
2c0c25dcc1 Fix for diagnostics 2023-03-05 12:31:16 -05:00
Antoni Boucher
fce7053567 Update gccjit 2023-03-05 12:16:33 -05:00
Antoni Boucher
6bb2af0e6d Merge commit '08a6d6e16b5efe217123e780398969946266268f' into sync-cg_gcc-2023-03-04 2023-03-05 12:03:19 -05:00
Camille GILLOT
1e9b58bdf8 Use the correct bound vars in return type suggestion. 2023-03-05 16:08:06 +00:00
Matthias Krüger
ec162703dc
Rollup merge of #108744 - compiler-errors:non_lifetime_binders-bad-copy-clone, r=jackh726
Don't ICE when encountering bound var in builtin copy/clone bounds

Fixes #108742
2023-03-05 14:29:10 +01:00
Guillaume Gomez
1836fe44b5 Improve documentation and argument naming of some TyCtxt methods 2023-03-05 13:35:13 +01:00
bors
0d439f8181 Auto merge of #108351 - petrochenkov:rmdit, r=cjgillot
rustc_middle: Remove trait `DefIdTree`

This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-05 10:37:02 +00:00
Ali MJ Al-Nasrawy
bfd35016e4 fix the new unsoundness 2023-03-05 12:49:01 +03:00
Ali MJ Al-Nasrawy
79dca7b7ba s/unification_table/unification_table_mut
Give a more clear name.
2023-03-05 12:49:01 +03:00
Ali MJ Al-Nasrawy
f3dfa52fd1 resolve to universal regions when possible 2023-03-05 12:00:22 +03:00
Camille GILLOT
fba5d3dd03 drop_tracking_mir: support new solver. 2023-03-05 08:29:35 +00:00
Camille GILLOT
135db79bc8 drop_tracking_mir: avoid good path bug. 2023-03-05 08:29:35 +00:00
Camille GILLOT
0916616fec drop_tracking_mir: diagnose recursive generator. 2023-03-05 08:29:35 +00:00
bors
14c54b637b Auto merge of #107844 - Zeegomo:no-drop-and-rep, r=cjgillot
Desugaring of drop and replace at MIR build

This commit desugars the drop and replace deriving from an
assignment at MIR build, avoiding the construction of the
`DropAndReplace` terminator (which will be removed in a following PR).

In order to retain the same error messages for replaces a new
`DesugaringKind::Replace` variant is introduced.

The changes in the borrowck are also useful for future work in moving drop elaboration
before borrowck, as no `DropAndReplace` would be present there anymore.

Notes on test diffs:
*  `tests/ui/borrowck/issue-58776-borrowck-scans-children`: the assignment deriving from the desugaring kills the borrow.
*  `tests/ui/async-await/async-fn-size-uninit-locals.rs`, `tests/mir-opt/issue_41110.test.ElaborateDrops.after.mir`,  `tests/mir-opt/issue_41888.main.ElaborateDrops.after.mir`:  drop elaboration generates (or reads from) a useless drop flag due to an issue with the dataflow analysis. Will be fixed independently by https://github.com/rust-lang/rust/pull/106430.

See https://github.com/rust-lang/rust/pull/104488 for more context
2023-03-05 07:56:26 +00:00
bors
a512c6c771 Auto merge of #101550 - CraftSpider:link-dead-windows, r=wesleywiser
Make compressed rmeta contain compressed data length after header

Fixes #90056, which is caused by link.exe introducing padding to the `.rustc` section, since it assumes this will have no effect besides allowing it to possibly use the extra space in future links.
2023-03-05 02:00:58 +00:00
Michael Goulet
118afdf071 Retry pred_known_to_hold_modulo_regions with fulfillment if ambiguous 2023-03-04 23:47:50 +00:00
Obei Sideg
44eb974b23 migrate rustc_hir_analysis to session diagnostic
part two
files list:
rustc_hir_analysis/variance/*
rustc_hir_analysis/missing_cast_for_variadic_arg.rs
rustc_hir_analysis/sized_unsized_cast.rs
2023-03-05 00:01:55 +03:00
Michael Goulet
1f92c61e73 sub is not sup 2023-03-04 20:57:34 +00:00
Ezra Shaw
aaaffa9a3e
feat: impl better help for .poll() not found on impl Future 2023-03-05 09:34:00 +13:00
Matthias Krüger
ff95645e2c
Rollup merge of #108736 - clubby789:ast-passes-unstable, r=Nilstrieb
Remove `allow(potential_query_instability)` from `ast_passes`

cc #84447
2023-03-04 20:48:19 +01:00
Matthias Krüger
76490b9235
Rollup merge of #108724 - tshepang:de-public, r=compiler-errors
field is not used outside the crate

See b61a28b2a1
2023-03-04 20:48:18 +01:00
Matthias Krüger
dd6f03de9a
Rollup merge of #108715 - chenyukang:yukang/cleanup-parser-delims, r=compiler-errors
Remove unclosed_delims from parser

After landing https://github.com/rust-lang/rust/pull/108297
we could remove `unclosed_delims` from the parser now.
2023-03-04 20:48:17 +01:00
Matthias Krüger
60f54b1025
Rollup merge of #108627 - estebank:suggestion-hightlight, r=WaffleLapkin
Properly colorize multi-part suggestions in the same line

Fix #108547.
2023-03-04 20:48:16 +01:00
Michael Goulet
7634c5916a Don't project to RPITIT that has no default value 2023-03-04 18:36:02 +00:00
Michael Goulet
32f1f01499 Don't ICE when encountering bound var in builtin copy/clone bounds 2023-03-04 17:53:51 +00:00
bors
b1719530f4 Auto merge of #108692 - nnethercote:dont-call-temporary_scope-twice, r=cjgillot
Don't call `temporary_scope` twice.

`mirror_expr_inner` calls `temporary_scope`. It then calls `make_mirror_unadjusted` which makes an identical call to `temporary_scope`.

This commit changes the `mirror_expr_inner` to get the `temp_lifetime` out of the expression produced by `make_mirror_unadjusted`, similar to how it currently gets the type.

r? `@cjgillot`
2023-03-04 15:10:04 +00:00
clubby789
ee41ba5d3c Remove allow(potential_query_instability) from ast_passes 2023-03-04 12:39:54 +00:00
bors
276b75a843 Auto merge of #108732 - Dylan-DPC:rollup-dy1l8sx, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #108298 (Fix ICE: check if snippet is `)`)
 - #108405 (Lazily compute crate name for consider_optimizing)
 - #108656 (Rustdoc search: Emit an error for unclosed generic)
 - #108660 (Remove ne implementations from strings)
 - #108669 (Allow checking whether a type allows being uninitialized)
 - #108727 (rustc_expand: make proc-macro derive error translatable)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-04 11:44:02 +00:00
Dylan DPC
0965c7e0a9
Rollup merge of #108727 - tshepang:example-translatable-diagnostic, r=Nilstrieb
rustc_expand: make proc-macro derive error translatable

kept this tiny so as to point to it as an example in rustc-dev-guide

`@rustbot` label +A-translation
2023-03-04 15:24:40 +05:30
Dylan DPC
6ce78a31d8
Rollup merge of #108669 - Nilstrieb:query-my-uninitness, r=compiler-errors
Allow checking whether a type allows being uninitialized

This is useful for clippy ([rust-lang/clippy#10407](https://github.com/rust-lang/rust-clippy/issues/10407)) and for the future `MaybeUninit::assume_init` panics (#100423).
2023-03-04 15:24:39 +05:30
Dylan DPC
832dab3798
Rollup merge of #108405 - Nilstrieb:lazy-crate-name-optimization-fuel, r=WaffleLapkin
Lazily compute crate name for consider_optimizing

The extra query is unnecessary in the common case of not having fuel.
2023-03-04 15:24:37 +05:30
Dylan DPC
035aa2816a
Rollup merge of #108298 - TaKO8Ki:fix-104440, r=cjgillot
Fix ICE: check if snippet is `)`

Fixes #107705
2023-03-04 15:24:37 +05:30
Ali MJ Al-Nasrawy
427dc18c25 tweak debug output and bless tests 2023-03-04 12:10:42 +03:00
bors
01b7a6a9ea Auto merge of #108689 - compiler-errors:normalization-error-smaller, r=lcnr
Remove `NormalizationError::ConstantKind`

No longer in use by `TryNormalizeAfterErasingRegionsFolder` (as of #102355 / e8150fa60c it seems). It's making `LayoutError`, etc. kinda large -- that was noticed by `@zoxc.`
2023-03-04 09:03:23 +00:00
Ali MJ Al-Nasrawy
97381d2f1e tweak ClosureOutlivesSubjectTy 2023-03-04 11:19:56 +03:00
Tshepang Mbambo
7fe4f0701c rustc_expand: make proc-macro derive error translatable 2023-03-04 07:54:29 +02:00
Tshepang Mbambo
34063c5706 infer: fix and improve comments 2023-03-04 07:38:37 +02:00
Tshepang Mbambo
4b92024cf1 field is not used outside the crate
See b61a28b2a1
2023-03-04 07:01:08 +02:00
Celina G. Val
40185dba54 Delete old re-exports from rustc_smir
This approach didn't seem to work well.
2023-03-03 16:56:07 -08:00
Esteban Küber
6fd175185e Properly colorize multi-part suggestions in the same line
Fix #108547.
2023-03-04 00:29:52 +00:00
yukang
d1073fab35 Remove unclosed_delims from parser 2023-03-03 23:09:36 +00:00
bors
70adb4e5b4 Auto merge of #108709 - matthiaskrgr:rollup-j2tjbyx, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #104549 (add -Zexport-executable-symbols to unstable book)
 - #108292 (Label opaque type for 'captures lifetime' error message)
 - #108540 (Add `Atomic*::from_ptr`)
 - #108634 (Add link to component dashboard)
 - #108647 (Remove dead pgo.sh file)
 - #108678 (Use `Option::as_slice` where applicable)
 - #108681 (Improve comments in `needs_process_obligation`.)
 - #108688 (Match unmatched backticks in library/)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-03 22:45:58 +00:00
Matthias Krüger
37bd50eddd
Rollup merge of #108681 - nnethercote:needs_process_obligation-comments, r=lqd
Improve comments in `needs_process_obligation`.

And a couple of other places.

r? `@lqd`
2023-03-03 20:45:02 +01:00
Matthias Krüger
efc79bc654
Rollup merge of #108678 - llogiq:use-option-as-slice, r=Nilstrieb
Use `Option::as_slice` where applicable

After #105871 introduced `Option::as_slice`, this PR uses it within the compiler. I found it interesting that all cases where `as_slice` could be used were done with different code before; so it seems the new API also has the benefit of being "the obvious solution" where before there was a mix of options, none clearly better than the rest.
2023-03-03 20:45:02 +01:00
Matthias Krüger
188ed14ca3
Rollup merge of #108292 - compiler-errors:opaque-captures-where, r=oli-obk
Label opaque type for 'captures lifetime' error message

Providing more information may help make this somewhat opaque (lol) error message a bit clearer.
2023-03-03 20:45:00 +01:00
Matthias Krüger
01fc5a7653
Rollup merge of #108694 - est31:backticks_matchmaking_comments, r=Nilstrieb
Match unmatched backticks in compiler/ comments

r? ``@Nilstrieb`` as per [advice](https://github.com/rust-lang/rust/pull/108685#issuecomment-1453018499)
2023-03-03 20:06:30 +01:00
Matthias Krüger
846424d15f
Rollup merge of #108685 - est31:backticks_matchmaking, r=petrochenkov
Match unmatched backticks in compiler/

Found with GNU grep:
```
grep -rEn '^(([^`]*`){2})*[^`]*`[^`]*$' compiler/ | rg -v '\s*[//]?.{1,2}```'
```
2023-03-03 20:06:29 +01:00
Matthias Krüger
db4b3dd608
Rollup merge of #108667 - compiler-errors:issue-108664, r=estebank
Fix another ICE in `point_at_expr_source_of_inferred_type`

Types coming from method probes must only be investigated *structurally*, since they often contain escaping infer variables from generalization and autoderef. We already have a hack in this PR that erases variables from types, so just use that.

Fixes #108664

The note attached to this error is pretty bad:

```
here the type of `primes` is inferred to be `[_]`
```

But that's unrelated to the PR.

---

Side-note: This is a pretty easy to trigger beta regression, so I've nominated it. Alternatively, I'm slightly inclined to remove this code altogether until it can be reformulated to be more accurate and less ICEy.
2023-03-03 20:06:28 +01:00
Matthias Krüger
1fab0fc4a2
Rollup merge of #108599 - nikic:drop-init, r=cuviper
Remove legacy PM leftovers

This drops two leftovers of legacy PM usage:
 * We don't need to initialize passes anymore.
 * The pass listing was still using legacy PM passes. Replace it with the corresponding new PM listing.
2023-03-03 20:06:27 +01:00
Matthias Krüger
44e794f8ab
Rollup merge of #108553 - compiler-errors:non-lt-late-bound-in-anon-ct, r=petrochenkov
Deny capturing late-bound non-lifetime param in anon const

Introduce a new AnonConstBoundary so we can detect when we capture a late-bound non-lifetime param with `non_lifetime_binders` enabled.

In the future, we could technically do something like introduce an early-bound parameter on the anon const, and stick the late-bound param in its substs (kinda like how we turn late-bound lifetimes in opaques into early-bound ones). But for now, just deny it so we don't ICE.

Fixes #108191
2023-03-03 20:06:27 +01:00
Matthias Krüger
4f49352e92
Rollup merge of #107981 - lcnr:canonicalization-uwu, r=compiler-errors
new solver: implement canonicalization and region constraints

see the corresponding rustc-dev-guide chapter: https://rustc-dev-guide.rust-lang.org/solve/canonicalization.html

r? ``@compiler-errors``
2023-03-03 20:06:26 +01:00
Giacomo Pasini
9cf0ff26f8
use helper function for error reporting 2023-03-03 16:33:11 +01:00
Giacomo Pasini
b3a47d9b6b
Desugars drop and replace at MIR build
This commit desugars the drop and replace deriving from an
assignment at MIR build, avoiding the construction of the
DropAndReplace terminator (which will be removed in a followign PR)

In order to retain the same error messages for replaces a new
DesugaringKind::Replace variant is introduced.
2023-03-03 16:33:11 +01:00
Maybe Waffle
9ac0da8f39 Make unused_allocation lint warn against Box::new 2023-03-03 12:02:55 +00:00
lcnr
a15abea931 canonicalization 2023-03-03 12:45:03 +01:00
Ali MJ Al-Nasrawy
10da7710cd ignore bivariant regions in opaque types 2023-03-03 14:12:05 +03:00
Ali MJ Al-Nasrawy
9d74bff829 smarter algorithm for finding an equal region
Smarter and simpler!
2023-03-03 14:10:25 +03:00
Ali MJ Al-Nasrawy
09524bfd5a promote subject even if it has unnamed regions
Don't require a region to have an `external_name` in order to be
promoted.
2023-03-03 14:04:50 +03:00
est31
c54f061228 Don't put integers into backticks during formatting 2023-03-03 08:39:37 +01:00
est31
5a02105fff Rustdoc-ify LiteralKind note 2023-03-03 08:39:36 +01:00
est31
ef658907a5 Match end user facing unmatched backticks in compiler/ 2023-03-03 08:39:36 +01:00
est31
6df5ae4fb0 Match unmatched backticks in comments in compiler/ 2023-03-03 08:39:00 +01:00
est31
ff2c609d66 Match unmatched backticks in compiler/ that are part of rustdoc 2023-03-03 08:39:00 +01:00
Takayuki Maeda
871ee18086 check if snippet is ) 2023-03-03 14:34:11 +09:00
Nicholas Nethercote
6b9c4125a5 Don't call temporary_scope twice.
`mirror_expr_inner` calls `temporary_scope`. It then calls
`make_mirror_unadjusted` which makes an identical call to
`temporary_scope`.

This commit changes the `mirror_expr_inner` to get the `temp_lifetime`
out of the expression produced by `make_mirror_unadjusted`, similar to
how it currently gets the type.
2023-03-03 16:15:23 +11:00
Michael Goulet
bdacc8bdd9 Migrate diagnostic 2023-03-03 05:02:34 +00:00
Michael Goulet
4b23a224ab Label opaque type for 'captures lifetime' error message 2023-03-03 05:02:34 +00:00
Michael Goulet
a43b554259 Remove NormalizationError::ConstantKind 2023-03-03 02:25:31 +00:00
Nicholas Nethercote
3bcea5f979 Improve comments in needs_process_obligation.
And a couple of other places.
2023-03-03 09:59:33 +11:00
Caleb Zulawski
d3cbedd49e Stabilize movbe target feature 2023-03-02 17:14:47 -05:00
Matthias Krüger
e85df8d0fe
Rollup merge of #108672 - spastorino:new-rpitit-impl-side, r=compiler-errors
Feed queries on impl side for RPITITs when using lower_impl_trait_in_trait_to_assoc_ty

I've added a test for traits that were already working and what I think is probably the last bit of infrastructure work needed.
In following PRs I'm going to start adding things TDD style, tests and code that make it work.

r? `@compiler-errors`
2023-03-02 23:05:31 +01:00
Matthias Krüger
7c4e9dd63d
Rollup merge of #108624 - Nilstrieb:move-it-up, r=WaffleLapkin
Make `ExprKind` the first field in `thir::Expr`

This makes its `Debug` impl print it first which is useful, as it's the most important part when looking at an expr.
2023-03-02 23:05:30 +01:00
Matthias Krüger
13640e337a
Rollup merge of #108573 - kornelski:runtimeenvs, r=WaffleLapkin
Explain compile-time vs run-time difference in env!() error message

This PR is clarifying error message of `env!()` based on this user question: https://users.rust-lang.org/t/environment-variable-out-dir-is-undefined/90067

It makes it clear that `env!()` is for env variables defined at compile-time. There's special-case help text for common Cargo build script variables.

I've also rearranged the code to avoid allocating error message on the happy path when the env var is defined.
2023-03-02 23:05:29 +01:00
Matthias Krüger
564715a5b7
Rollup merge of #108557 - Nathan-Fenner:nathanf/adjust-error-span-fix-Some, r=WaffleLapkin
Point error span at Some constructor argument when trait resolution fails

This is a follow up to #108254 and #106477 which extends error span refinement to handle a case which I mistakenly believed was handled in #106477. The goal is to refine the error span depicted below:

```rs
trait Fancy {}
impl <T> Fancy for Option<T> where T: Iterator {}

fn want_fancy<F>(f: F) where F: Fancy {}

fn example() {
    want_fancy(Some(5));
//  (BEFORE)   ^^^^^^^ `{integer}` is not an iterator
//  (AFTER)         ^  `{integer}` is not an iterator
}
```

I had used a (slightly more complex) example as an illustrative example in #108254 , but hadn't actually turned it into a test, because I had (incorrectly) believed at the time it was covered by existing behavior. It turns out that `Some` is slightly "special" in that it resolves differently from the other `enum` constructors I had tried, and therefore this test was actually broken.

I've now updated the tests to include this example, and fixed the code to correctly resolve the `Some` constructor so that the span of the error is reduced.
2023-03-02 23:05:28 +01:00
Matthias Krüger
f75f440bbf
Rollup merge of #108022 - CraftSpider:align-bytes, r=oli-obk
Support allocations with non-Box<[u8]> bytes

This is prep work for allowing miri to support passing pointers to C code, which will require `Allocation`s to be correctly aligned. Currently, it just makes `Allocation` generic and plumbs the necessary changes through the right places.

The follow-up to this will be adding a type in the miri interpreter which correctly aligns the bytes, using that for the Miri engine, then allowing Miri to pass pointers into these allocations to C calls.

Based off of #100467, credit to ```@emarteca``` for the code
2023-03-02 23:05:27 +01:00
Andre Bogus
03334503b3 Use Option::as_slice where applicable 2023-03-02 22:36:37 +01:00
bwmf2
832b33e6b1 Force parentheses around match expression in binary expression 2023-03-02 21:58:49 +01:00
Santiago Pastorino
fa6bf2afdb
Feed queries on impl side for RPITITs when using lower_impl_trait_in_trait_to_assoc_ty 2023-03-02 16:48:49 -03:00
Vadim Petrochenkov
c83553da31 rustc_middle: Remove trait DefIdTree
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-02 23:46:44 +04:00
Nilstrieb
10a69de5fd Allow checking whether a type allows being uninitialized
This is useful for clippy and for the future `MaybeUninit::assume_init`
panics.
2023-03-02 18:33:48 +00:00
Michael Goulet
4b01a1a07a Fix another ICE in point_at_expr_source_of_inferred_type 2023-03-02 18:27:06 +00:00
Nilstrieb
e3d397a5f6 Make ExprKind the first field in thir::Expr
This makes its `Debug` impl print it first which is useful, as it's the
most important part when looking at an expr.
2023-03-02 18:21:44 +00:00
bors
13471d3b20 Auto merge of #108654 - LeSeulArtichaut:revert-99767, r=compiler-errors
Revert stabilization of `#![feature(target_feature_11)]`

This reverts #99767 due to the presence of bugs #108645 and #108646.

cc `@joshtriplett`
cc tracking issue #69098
r? `@ghost`
2023-03-02 17:38:31 +00:00
Léo Lanteri Thauvin
bfe5189904 Revert "Stabilize #![feature(target_feature_11)]"
This reverts commit b379d216ee.
2023-03-02 13:41:17 +01:00
Matthias Krüger
832987bb1e
Rollup merge of #108609 - clubby789:e0599-highlight, r=estebank
Highlight whole expression for E0599

Fixes #108603

This adds a secondary label to highlight the whole expression leading to the error. It also prevents empty labels being recognised as 'unexpected' by compiletest - otherwise, tests with NOTE annotations would pick up empty labels.

`@rustbot` label +A-diagnostics
2023-03-02 07:24:02 +01:00
Matthias Krüger
91dafebc91
Rollup merge of #108575 - compiler-errors:erase, r=estebank
Erase **all** regions when probing for associated types on ambiguity in astconv

Fixes #108562
2023-03-02 07:24:01 +01:00
Matthias Krüger
c9c9283c6a
Rollup merge of #108516 - clubby789:rustc-box-restrict, r=compiler-errors
Restrict `#[rustc_box]` to `Box::new` calls

Currently, `#[rustc_box]` can be applied to any call expression with a single argument. This PR only allows it to be applied to calls to `Box::new`
2023-03-02 07:24:00 +01:00
clubby789
d845769557 Restrict #[rustc_box] to Box::new calls 2023-03-02 02:42:19 +00:00
Rune Tynan
f26b0a2948
Format 2023-03-01 20:27:03 -05:00
bors
f77bfb7336 Auto merge of #108620 - Dylan-DPC:rollup-o5c4evy, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #108143 (rustdoc: search by macro when query ends with `!`)
 - #108394 (Make `x doc --open` work on every book)
 - #108427 (Recover from for-else and while-else)
 - #108462 (Fix `VecDeque::append` capacity overflow for ZSTs)
 - #108568 (Make associated_item_def_ids for traits use an unstable option to also return associated types for RPITITs)
 - #108604 (Add regression test for #107280)
 - #108605 (Add regression test for #105821)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-01 18:51:29 +00:00
Dylan DPC
9d132f77ae
Rollup merge of #108568 - spastorino:new-rpitit-flag, r=compiler-errors
Make associated_item_def_ids for traits use an unstable option to also return associated types for RPITITs

r? `@compiler-errors`
2023-03-01 23:40:21 +05:30
Santiago Pastorino
73e2fe0494
Properly implement should_encode_fn_impl_trait_in_trait using new unstable option 2023-03-01 14:13:41 -03:00
clubby789
6c2a952b56 Highlight whole expression for E0599 2023-03-01 16:57:11 +00:00
Santiago Pastorino
811a1cabda
Make associated_item_def_ids for traits use an unstable option to also return associated types for RPITITs 2023-03-01 12:56:39 -03:00
Santiago Pastorino
be72beca68
Fix typo in docs 2023-03-01 12:56:39 -03:00
Santiago Pastorino
e74f50ecc2
Add unstable option new_rpitit to be used for new RPITIT lowering system 2023-03-01 12:56:39 -03:00
Santiago Pastorino
5295de1694
Add opt_rpitit_info query 2023-03-01 12:56:38 -03:00
bors
609496eecf Auto merge of #108446 - Zoxc:named-allocs, r=oli-obk
Name LLVM anonymous constants by a hash of their contents

This makes the names stable between different versions of a crate unlike the `AllocId` naming, making LLVM IR comparisons with `llvm-diff` more practical.
2023-03-01 15:36:15 +00:00
y21
0758c05c97 recover from for-else and while-else 2023-03-01 13:26:59 +01:00
Michael Woerister
b79f0261f8 Do not implement HashStable for HashSet. 2023-03-01 10:20:45 +01:00
Michael Woerister
04e5fa3ce2 Remove last instances of HashSet in query result types. 2023-03-01 10:20:45 +01:00
Michael Woerister
422208ae52 Use UnordSet instead of FxHashSet for names_imported_by_glob_use query. 2023-03-01 10:20:43 +01:00
Michael Woerister
ee8bc5b0b2 Use FxIndexSet instead of FxHashSet for asm_target_features query. 2023-03-01 10:19:26 +01:00
Michael Woerister
b0202d9c2c Use LocalDefIdSet/Map instead of FxHashSet/Map for live_symbols_and_ignored_derived_traits query. 2023-03-01 10:19:26 +01:00
Michael Woerister
f0eadbafd4 Use LocalDefIdSet instead of FxHashSet for reachable_set query. 2023-03-01 10:19:25 +01:00
Michael Woerister
5ff00f96e6 Use DefIdMap instead of FxHashMap for impl_item_implementor_ids query. 2023-03-01 10:19:25 +01:00
Nikita Popov
655a810b66 Print NewPM passes
-C passes=list was printing passes for the legacy pass manager.
Use PassBuilder::printPassNames() to print NewPM passes instead.
2023-03-01 09:26:00 +01:00
Nikita Popov
45f694dbba Remove pass initialization code
This is no longer necessary with the new pass manager.
2023-03-01 09:24:13 +01:00
bors
bcb610da7f Auto merge of #108587 - matthiaskrgr:rollup-rw6po59, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #108376 (compiler/rustc_session: fix sysroot detection logic)
 - #108400 (add llvm cgu instructions stats to perf)
 - #108496 (fix #108495, postfix decrement and prefix decrement has no warning)
 - #108505 (Further unify validity intrinsics)
 - #108520 (Small cleanup to `one_bound_for_assoc_type`)
 - #108560 (Some `infer/mod.rs` cleanups)
 - #108563 (Make mailmap more correct)
 - #108564 (Fix `x clean` with specific paths)
 - #108571 (Add contains_key to SortedIndexMultiMap)
 - #108578 (Update Fuchsia platform team members)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-01 06:23:19 +00:00
Matthias Krüger
168589426c
Rollup merge of #108571 - Jesse-Bakker:sorted_index_multi_map_contains_key, r=Nilstrieb
Add contains_key to SortedIndexMultiMap
2023-03-01 01:21:59 +01:00
Matthias Krüger
3ff3011afb
Rollup merge of #108560 - Nilstrieb:infer-cleanup, r=compiler-errors
Some `infer/mod.rs` cleanups
2023-03-01 01:21:58 +01:00
Matthias Krüger
35ef8ea5e1
Rollup merge of #108520 - compiler-errors:one-bound-nit, r=jackh726
Small cleanup to `one_bound_for_assoc_type`

Use fewer closures :)
2023-03-01 01:21:57 +01:00
Matthias Krüger
5af16c1655
Rollup merge of #108505 - Nilstrieb:further-unify-validity-intrinsics, r=michaelwoerister
Further unify validity intrinsics

Also merges the inhabitedness check into the query to further unify the
code paths.

Depends on #108364
2023-03-01 01:21:57 +01:00
Matthias Krüger
1c3cc8bba5
Rollup merge of #108496 - nx2k3:issue-108495-dec, r=WaffleLapkin
fix #108495, postfix decrement and prefix decrement has no warning

Fixes #108495
2023-03-01 01:21:56 +01:00
Matthias Krüger
32d7024100
Rollup merge of #108400 - csmoe:cgu-instr-perf, r=bjorn3
add llvm cgu instructions stats to perf

r? ```@bjorn3```
2023-03-01 01:21:56 +01:00
Matthias Krüger
a51006b8d2
Rollup merge of #108555 - Zoxc:par-fix, r=cjgillot
Fix a race in the query system

This fixes an issue where in between the `job` removal and `complete` call the query neither has a job nor a result, allowing another thread to start executing it again.

r? ``@cjgillot``
2023-03-01 01:20:26 +01:00
Matthias Krüger
19604c2362
Rollup merge of #108554 - compiler-errors:late-bound-object-default, r=oli-obk
Only look for param in item's generics if it actually comes from generics

Record whether a `hir::GenericParam` comes from an item's generics, or from a `for<...>` binder. Then, only look for the param in `object_lifetime_default` if it actually comes from the item's generics.

Fixes #108177
2023-03-01 01:20:25 +01:00
Matthias Krüger
b2dc8c505c
Rollup merge of #108551 - compiler-errors:rpitit-bad-spec, r=oli-obk
Descriptive error when users try to combine RPITIT/AFIT with specialization

Previously we failed with some esoteric error like:

```
error[E0053]: method `foo` has an incompatible type for trait
  --> $DIR/dont-project-to-specializable-projection.rs:14:35
   |
LL |     default async fn foo(_: T) -> &'static str {
   |                                   ^^^^^^^^^^^^ expected associated type, found future
   |
note: type in trait
  --> $DIR/dont-project-to-specializable-projection.rs:10:27
   |
LL |     async fn foo(_: T) -> &'static str;
   |                           ^^^^^^^^^^^^
   = note: expected signature `fn(_) -> impl Future<Output = &'static str>`
              found signature `fn(_) -> impl Future<Output = &'static str>`
```

Now we error like:

```
error: async associated function in trait cannot be specialized
  --> $DIR/dont-project-to-specializable-projection.rs:14:5
   |
LL |     default async fn foo(_: T) -> &'static str {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: specialization behaves in inconsistent and surprising ways with `#![feature(async_fn_in_trait)]`, and for now is disallowed
```
2023-03-01 01:20:24 +01:00
Matthias Krüger
78f9bb11fe
Rollup merge of #108550 - clubby789:remove-disjoint, r=compiler-errors
Remove the `capture_disjoint_fields` feature

As best I can tell, this was stabilized for Edition 2021 in #88126 but the feature was never removed.
2023-03-01 01:20:24 +01:00
Matthias Krüger
371904bba6
Rollup merge of #108297 - chenyukang:yukang/delim-error-exit, r=petrochenkov
Exit when there are unmatched delims to avoid noisy diagnostics

From https://github.com/rust-lang/rust/pull/104012#issuecomment-1311764832
r? ``@petrochenkov``
2023-03-01 01:20:22 +01:00
Nathan Fenner
be15f174fa restore unaddressed FIXME 2023-02-28 14:59:32 -08:00
Nathan Fenner
f0212e6532 Fix error spans for arguments to tuple enum constructors 2023-02-28 14:58:14 -08:00
Michael Goulet
b7e0ca993d Shift vars for default RPITIT methods correctly 2023-02-28 21:34:59 +00:00
Rune Tynan
79f0021c16
Update header comment 2023-02-28 15:52:00 -05:00
Rune Tynan
3a87a18857
Make zeroed return an Option 2023-02-28 15:39:17 -05:00
Michael Goulet
cb9852b8e6 Erase **all** regions when probing for associated types in astconv 2023-02-28 17:29:46 +00:00
liushuyu
2186358e5a
compiler/rustc_session: fix sysroot detection logic ...
... on systems where /usr/lib contains a multi-arch structure
2023-02-28 10:02:38 -07:00
Kornel
2407b0c578 Explain compile-time vs run-time difference in env!() error message 2023-02-28 16:44:59 +00:00
Jesse Bakker
edf053036f Add contains_key to SortedIndexMultiMap 2023-02-28 17:15:00 +01:00