Commit Graph

23529 Commits

Author SHA1 Message Date
Nilstrieb
968be98756 Allow clippy::from_mut_ref
This pattern is fine for arena allocators.
2023-04-09 22:29:56 +02:00
Nilstrieb
f00366d191 Box large enum variants 2023-04-09 21:59:28 +02:00
Nilstrieb
54e1309c65 Use HashMap entry APIs more 2023-04-09 21:59:28 +02:00
Nilstrieb
f058d05fc2 Some simple clippy::perf fixes 2023-04-09 21:59:28 +02:00
bors
7201301df6 Auto merge of #109500 - petrochenkov:modchainld, r=oli-obk
resolve: Preserve reexport chains in `ModChild`ren

This may be potentially useful for
- avoiding uses of `hir::ItemKind::Use` (which usually lead to correctness issues)
- preserving documentation comments on all reexports, including those from other crates
- preserving and checking stability/deprecation info on reexports
- all kinds of diagnostics

The second commit then migrates some hacky logic from rustdoc to `module_reexports` to make it simpler and more correct.
Ideally rustdoc should use `module_reexports` immediately at the top level, so `hir::ItemKind::Use`s are never used.
The second commit also fixes issues with https://github.com/rust-lang/rust/pull/109330 and therefore
Fixes https://github.com/rust-lang/rust/issues/109631
Fixes https://github.com/rust-lang/rust/issues/109614
Fixes https://github.com/rust-lang/rust/issues/109424
2023-04-09 13:05:56 +00:00
bors
56e0626836 Auto merge of #110041 - fmease:diag-sugg-adding-const-param, r=compiler-errors
Suggest defining const parameter when appropriate

Helps a bit with #91119.
Following #105523's lead, I use placeholder `/* Type */` instead of `_` in the suggestion.
It should be easier for newcomers to parse.

`@rustbot` label A-diagnostics
r? diagnostics
2023-04-09 10:54:04 +00:00
bors
709a97fffe Auto merge of #109173 - flba-eb:add-i586-qnx70-target, r=compiler-errors
Add tier 3 no_std x86 support for QNX Neutrino RTOS, version 7.0

This PR adds the target `i586-pc-nto-qnx700`, which targets QNX Neutrino RTOS version 7.0 on x86 32-bit targets.

cc: `@flba-eb` `@gh-tr`

This target falls under the umbrella of Tier 3 QNX Neutrino RTOS support documented in `nto-qnx.md` and previously started with #102701.
2023-04-09 07:36:53 +00:00
bors
7cd6f55323 Auto merge of #110101 - JohnTitor:rollup-ol20aw7, r=JohnTitor
Rollup of 6 pull requests

Successful merges:

 - #110058 (Remove `box_syntax` usage)
 - #110059 (ignore_git → omit_git_hash)
 - #110060 (Document that `&T` and `&mut T` are `Sync` if `T` is)
 - #110074 (Make the "codegen" profile of `config.toml` download and build llvm from source.)
 - #110086 (Add `max_line_length` to `.editorconfig`, matching rustfmt)
 - #110096 (Tweak tuple indexing suggestion)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-09 05:00:24 +00:00
Yuki Okushi
eed27ac7f4
Rollup merge of #110096 - compiler-errors:tweak-tuple-idx-msg, r=Nilstrieb
Tweak tuple indexing suggestion

Fixes #110091
2023-04-09 12:35:56 +09:00
bors
0030465bcc Auto merge of #109413 - compiler-errors:pointer-like-abi, r=cjgillot
Enforce that `PointerLike` requires a pointer-like ABI

At least temporarily, let's ban coercing things that are pointer-sized and pointer-aligned but *not* `Abi::Scalar(..)` into `dyn*`. See: https://github.com/rust-lang/rust/pull/104694#discussion_r1142522073

This can be lifted in the future if we decie that we *want* to be able to coerce something `repr(C)` into a `dyn*`, but we'll have to figure out what to do with Miri and codegen...

r? compiler
2023-04-09 02:41:58 +00:00
bors
f8ed97ecc1 Auto merge of #110031 - compiler-errors:generic-elaboration, r=b-naber
Make elaboration generic over input

Combines all the `elaborate_*` family of functions into just one, which is an iterator over the same type that you pass in (e.g. elaborating `Predicate` gives `Predicate`s, elaborating `Obligation`s gives `Obligation`s, etc.)
2023-04-09 00:18:10 +00:00
Michael Goulet
fbc3457d35 Tweak tuple indexing suggestion 2023-04-08 21:32:55 +00:00
Michael Goulet
920c51c526 Enforce that PointerLike requires a pointer-like ABI 2023-04-08 21:11:16 +00:00
bors
af06dce64b Auto merge of #106281 - JulianKnodt:transmute_const_generics, r=b-naber
Add ability to transmute (somewhat) with generic consts in arrays

Previously if the expression contained generic consts and did not have a directly equivalent type, transmuting the type in this way was forbidden, despite the two sizes being identical. Instead, we should be able to lazily tell if the two consts are identical, and if so allow them to be transmuted.

This is done by normalizing the forms of expressions into sorted order of multiplied terms, which is not generic over all expressions, but should handle most cases.

This allows for some _basic_ transmutations between types that are equivalent in size without requiring additional stack space at runtime.

I only see one other location at which `SizeSkeleton` is being used, and it checks for equality so this shouldn't affect anywhere else that I can tell.

See [this Stackoverflow post](https://stackoverflow.com/questions/73085012/transmute-nested-const-generic-array-rust) for what was previously necessary to convert between types. This PR makes converting nested `T -> [T; 1]` transmutes possible, and `[uB*2; N] -> [uB; N * 2]` possible as well.

I'm not sure whether this is something that would be wanted, and if it is it definitely should not be insta-stable, so I'd add a feature gate.
2023-04-08 19:47:22 +00:00
bors
dd2b19539e Auto merge of #109862 - klensy:llvm-dd, r=nikic
llvm: replace some deprecated functions, add fixmes

Replace some deprecated llvm functions, add FIXME's (for simpler future work), replace some rust custom functions with llvm ones.
2023-04-08 15:57:59 +00:00
bors
66f8dd1255 Auto merge of #110069 - ndrewxie:issue-104212-fix, r=cjgillot
Switched provisional evaluation cache map to FxIndexMap, and replaced map.drain_filter with map.retain

Switching ProvisionalEvaluationCache's map field from FxHashMap to FxIndexMap was previously blocked because doing so caused performance regressions that could be mitigated by the stabilization of drain_filter for FxIndexMap (#104212). However, the only use of drain_filter can be replaced with a retain, so I made the modification and put in a PR to see if this causes a performance regression as well.

This PR is part of a broader effort (#84447) of removing iteration through FxHashMaps, as the iteration order is unstable and can cause issues in incremental compilation.
2023-04-08 11:20:58 +00:00
Vadim Petrochenkov
9da9373bf0 rustc_middle: Remove Option from module_reexports query 2023-04-08 13:29:16 +03:00
Vadim Petrochenkov
d11b9165ee resolve: Preserve reexport chains in ModChildren
This may be potentially useful for
- avoiding uses of `hir::ItemKind::Use`
- preserving documentation comments on all reexports
- preserving and checking stability/deprecation info on reexports
- all kinds of diagnostics
2023-04-08 13:29:15 +03:00
klensy
fdfca765a7 fixup: use Bool instead of bool 2023-04-08 12:15:26 +03:00
bors
131211acd2 Auto merge of #110043 - ickk:fix_infer_message, r=eholk
Fix help message for `infer_source_kind_subdiag_let`

I discovered there's a double "the" in the help message for E0282.
2023-04-08 03:26:54 +00:00
bors
0f0dc29264 Auto merge of #109971 - WaffleLapkin:yeet_ownership, r=Nilstrieb
Yeet `owning_ref`

Based on the discussions from https://github.com/rust-lang/rust/pull/109948

This replaces `owning_ref` with a far simpler & safer abstraction.

Fixes #109974
2023-04-08 01:08:26 +00:00
Andrew Xie
9920baba5f Switched provisional evaluation cache map to FxIndexMap, and replaced map.drain_filter with map.retain 2023-04-07 19:41:08 -04:00
bors
23ee2af2f7 Auto merge of #109788 - compiler-errors:trait-item-from-non-trait, r=petrochenkov
More descriptive error when qself path doesnt have a trait on the RHS of `as`

`<Ty as Enum>::Assoc` should report that `Enum` is a trait. Main question is whether to eagerly report the error, or raise it with `return Err(..)` -- i'll note that in an inline comment though.

cc `@GuillaumeGomez` who said this came up at a Paris Rust meetup.

r? `@petrochenkov`
2023-04-07 20:40:05 +00:00
kadmin
b76dd8c807 Add feature gate 2023-04-07 11:18:07 -07:00
bors
94524020ea Auto merge of #110036 - jackh726:placeholder_boundvar, r=nnethercote
Remove u32 on BrAnon and BoundTyKind::Anon in favor of BoundVar on Placeholder types

r? `@nnethercote`

Better alternative to #110025
2023-04-07 14:26:24 +00:00
Nicholas Nethercote
f08f15481a Add a size assertion for RegionKind. 2023-04-07 09:15:38 -04:00
bors
da14081468 Auto merge of #102906 - nbdd0121:mir, r=wesleywiser,tmiasko
Refactor unwind in MIR

This makes unwinding from current `Option<BasicBlock>` into
```rust
enum UnwindAction {
	Continue,
	Cleanup(BasicBlock),
	Unreachable,
	Terminate,
}
```

cc `@JakobDegen` `@RalfJung` `@Amanieu`
2023-04-07 10:31:14 +00:00
Maybe Waffle
fbe0591c68 Mark OwnedSlice::{deref, borrow} as #[inline] 2023-04-07 10:14:50 +00:00
bors
b6f6104a1f Auto merge of #110019 - jplatte:jplatte/stabilize-is-some-and, r=Amanieu
Stabilize is_some_and

This stabilizes the following public API:

```rust
impl<T> Option<T> {
    pub fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool;
}

impl<T, E> Result<T, E> {
    pub fn is_ok_and(self, f: impl FnOnce(T) -> bool) -> bool;
    pub fn is_err_and(self, f: impl FnOnce(E) -> bool) -> bool;
}
```

Closes #93050 (tracking issue).

`@rustbot` label +T-libs-api -T-libs
2023-04-07 08:09:20 +00:00
ickk
726598ed9a fix infer_source_kind_subdiag_let help message - remove double "the" 2023-04-07 17:42:17 +10:00
León Orell Valerian Liehr
f2acafe9e2 suggest adding const param 2023-04-07 09:11:53 +02:00
Michael Goulet
d5b1ef1c3f Use smart-resolve when checking for trait in RHS of UFCS 2023-04-07 05:33:52 +00:00
bors
32ea4bb9e3 Auto merge of #109663 - fee1-dead-contrib:rustc_macros-syn-2.0, r=Nilstrieb
migrate rustc_macros to syn 2.0

WIP at this point since I need to work on migrating the code that heavily uses `NestedMeta` for parsing. Perhaps a full refactor would be nice..
2023-04-07 03:37:21 +00:00
Jack Huey
b15195a304 Remove u32 on BoundTyKind::Anon 2023-04-06 23:08:04 -04:00
Jack Huey
f0edcc8a6f Remove index from BrAnon 2023-04-06 23:01:40 -04:00
Jack Huey
e4edf00f12 Don't use BrAnon index in diagnostics 2023-04-06 23:01:38 -04:00
Jack Huey
167b70692b Remove expect_anon and expect_anon_placeholder in favor of var 2023-04-06 23:01:38 -04:00
Jack Huey
4646b3df6a Use BoundTy and BoundRegion instead of kind of PlaceholderTy and PlaceholderRegion 2023-04-06 23:01:35 -04:00
Michael Goulet
2cd0729d63 Get rid of elaborate_trait_ref{s} too 2023-04-06 23:30:22 +00:00
Michael Goulet
758bedc104 Make elaborator generic 2023-04-06 23:30:22 +00:00
Matthias Krüger
903b439cac
Rollup merge of #110022 - Ezrashaw:fix-parser-ident-regression, r=compiler-errors
fix: fix regression in #109203

Fixes #110014

r? `@compiler-errors`
2023-04-07 00:00:26 +02:00
Matthias Krüger
e70818983b
Rollup merge of #110013 - compiler-errors:non-exhaustive-privacy-reason, r=WaffleLapkin
Label `non_exhaustive` attribute on privacy errors from non-local items

Label when an ADT is `non_exhaustive` and we get a privacy error, help with confusion in a case like this:

```rust
#[non_exhaustive]
pub struct Foo;

// other crate
let x = Foo;
//~^ ERROR unit struct `Foo` is private
```
2023-04-07 00:00:25 +02:00
Matthias Krüger
e63586f386
Rollup merge of #109957 - fmease:fix-109905, r=petrochenkov
diagnostics: account for self type when looking for source of unsolved type variable

Fixes #109905.

When searching for the source of an unsolved infer var inside of a list of generic args, we look through the `tcx.generics_of(…).own_substs(…)` which *skips* the self type if present. However, the computed `argument_index` is later[^1] used to index into `tcx.generics_of(…).params` which may still contain the self type. In such case, we are off by one when indexing into the parameters.

From now on, we account for this immediately after calling `own_substs` which keeps things local.

This also fixes the wrong output in the preexisting UI test `inference/need_type_info/concrete-impl.rs` which was overlooked. It used to claim that the *type of type parameter `Self`* couldn't be inferred in `<Struct as Ambiguous<_>>::method()` which of course isn't true: `Self` equals `Struct` here, `A` couldn't be inferred.

`@rustbot` label A-diagnostics

[^1]: f98a271814/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs (L471)
2023-04-07 00:00:24 +02:00
Gary Guo
1499a6faad UnwindAction::Terminate edge is also critical edge 2023-04-06 22:24:47 +01:00
Jonas Platte
443928f7e3
Stabilize is_some_and 2023-04-06 23:14:23 +02:00
Ezra Shaw
9dbf20ef27
fix: fix regression in #109203 2023-04-07 08:54:13 +12:00
bors
de74dab880 Auto merge of #110012 - matthiaskrgr:rollup-sgmm5xv, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #109395 (Fix issue when there are multiple candidates for edit_distance_with_substrings)
 - #109755 (Implement support for `GeneratorWitnessMIR` in new solver)
 - #109782 (Don't leave a comma at the start of argument list when removing arguments)
 - #109977 (rustdoc: avoid including line numbers in Google SERP snippets)
 - #109980 (Derive String's PartialEq implementation)
 - #109984 (Remove f32 & f64 from MemDecoder/MemEncoder)
 - #110004 (add `dont_check_failure_status` option in the compiler test)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-06 18:48:42 +00:00
Maybe Waffle
2733c29bb1 Support multithreaded mode in OwnedSlice tests 2023-04-06 18:13:07 +00:00
Maybe Waffle
e0e39caf84 Add basic tests for OwnedSlice 2023-04-06 17:33:55 +00:00
Maybe Waffle
b6970d0e26 Use FnOnce for slice_owned instead of Fn 2023-04-06 17:03:42 +00:00