about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-03-01Auto merge of #105871 - llogiq:option-as-slice, r=scottmcmbors-0/+28
Add `Option::as_`(`mut_`)`slice` This adds the following functions: * `Option<T>::as_slice(&self) -> &[T]` * `Option<T>::as_mut_slice(&mut self) -> &[T]` The `as_slice` and `as_mut_slice_mut` functions benefit from an optimization that makes them completely branch-free. ~~Unfortunately, this optimization is not available on by-value Options, therefore the `into_slice` implementations use the plain `match` + `slice::from_ref` approach.~~ Note that the optimization's soundness hinges on the fact that either the niche optimization makes the offset of the `Some(_)` contents zero or the mempory layout of `Option<T>` is equal to that of `Option<MaybeUninit<T>>`. The idea has been discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Option.3A.3Aas_slice). Notably the idea for the `as_slice_mut` and `into_slice´ methods came from `@cuviper` and `@Sp00ph` hardened the optimization against niche-optimized Options. The [rust playground](https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=74f8e4239a19f454c183aaf7b4a969e0) shows that the generated assembly of the optimized method is basically only a copy while the naive method generates code containing a `test dx, dx` on x86_64. --- EDIT from reviewer: ACP is https://github.com/rust-lang/libs-team/issues/150
2023-03-01Auto merge of #108587 - matthiaskrgr:rollup-rw6po59, r=matthiaskrgrbors-0/+108
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-01Rollup merge of #108496 - nx2k3:issue-108495-dec, r=WaffleLapkinMatthias Krüger-0/+108
fix #108495, postfix decrement and prefix decrement has no warning Fixes #108495
2023-03-01Rollup merge of #108554 - compiler-errors:late-bound-object-default, r=oli-obkMatthias Krüger-0/+18
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-01Rollup merge of #108551 - compiler-errors:rpitit-bad-spec, r=oli-obkMatthias Krüger-12/+14
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-01Rollup merge of #108550 - clubby789:remove-disjoint, r=compiler-errorsMatthias Krüger-12/+4
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-01Rollup merge of #108297 - chenyukang:yukang/delim-error-exit, r=petrochenkovMatthias Krüger-1510/+254
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-01Add `Option::as_slice`(`_mut`)Andre Bogus-0/+28
This adds the following functions: * `Option<T>::as_slice(&self) -> &[T]` * `Option<T>::as_slice_mut(&mut self) -> &[T]` The `as_slice` and `as_slice_mut` functions benefit from an optimization that makes them completely branch-free. Note that the optimization's soundness hinges on the fact that either the niche optimization makes the offset of the `Some(_)` contents zero or the mempory layout of `Option<T>` is equal to that of `Option<MaybeUninit<T>>`.
2023-02-28micro fmt changesMaybe Waffle-12/+10
2023-02-28remove duplicated diagnostic for unclosed delimiteryukang-305/+73
2023-02-28Exit when there are unmatched delims to avoid noisy diagnosticsyukang-1263/+239
2023-02-28Only look for param in generics if it actually comes from genericsMichael Goulet-0/+18
2023-02-28Descriptive error when users try to combine RPITIT/AFIT with specializationMichael Goulet-12/+14
2023-02-28Remove the `capture_disjoint_fields` featureclubby789-12/+4
2023-02-28Auto merge of #99767 - LeSeulArtichaut:stable-target-feature-11, r=estebankbors-119/+58
Stabilize `#![feature(target_feature_11)]` ## Stabilization report ### Summary Allows for safe functions to be marked with `#[target_feature]` attributes. Functions marked with `#[target_feature]` are generally considered as unsafe functions: they are unsafe to call, cannot be assigned to safe function pointers, and don't implement the `Fn*` traits. However, calling them from other `#[target_feature]` functions with a superset of features is safe. ```rust // Demonstration function #[target_feature(enable = "avx2")] fn avx2() {} fn foo() { // Calling `avx2` here is unsafe, as we must ensure // that AVX is available first. unsafe { avx2(); } } #[target_feature(enable = "avx2")] fn bar() { // Calling `avx2` here is safe. avx2(); } ``` ### Test cases Tests for this feature can be found in [`src/test/ui/rfcs/rfc-2396-target_feature-11/`](https://github.com/rust-lang/rust/tree/b67ba9ba208ac918228a18321fc3a11a99b1c62b/src/test/ui/rfcs/rfc-2396-target_feature-11/). ### Edge cases - https://github.com/rust-lang/rust/issues/73631 Closures defined inside functions marked with `#[target_feature]` inherit the target features of their parent function. They can still be assigned to safe function pointers and implement the appropriate `Fn*` traits. ```rust #[target_feature(enable = "avx2")] fn qux() { let my_closure = || avx2(); // this call to `avx2` is safe let f: fn() = my_closure; } ``` This means that in order to call a function with `#[target_feature]`, you must show that the target-feature is available while the function executes *and* for as long as whatever may escape from that function lives. ### Documentation - Reference: https://github.com/rust-lang/reference/pull/1181 --- cc tracking issue #69098 r? `@ghost`
2023-02-27Auto merge of #108487 - cjgillot:no-typeck-mir, r=oli-obkbors-0/+3
Avoid invoking typeck from borrowck This PR attempts to reduce direct dependencies between typeck and MIR-related queries. The goal is to have all the information transit either through THIR or through dedicated queries that avoid depending on the whole `TypeckResults`. In a first commit, we store the type information that MIR building requires into THIR. This avoids edges between mir_built and typeck. In the second and third commit, we wrap informations around closures (upvars, kind origin and user-provided signature) to avoid borrowck depending on typeck information. There should be a single remaining borrowck -> typeck edge in the good path, due to inline consts.
2023-02-27Rollup merge of #108533 - notriddle:notriddle/resolver-def-descr, ↵Matthias Krüger-0/+17
r=compiler-errors diagnostics: avoid querying `associated_item` in the resolver Fixes #108529 CC #108324
2023-02-27Rollup merge of #108522 - compiler-errors:new-solver-more-tests, r=jackh726Matthias Krüger-0/+66
Commit some new solver tests Lazy norm is hard. `<?0 as Trait>::Assoc = ?0` ... probably should emit an alias-eq goal, but currently we don't do that. Right now it fails with a cyclical ty error. Also committed a check-pass test that broken when I attempted to fix this (unsuccessfully). r? types
2023-02-27Rollup merge of #108363 - cjgillot:unused-crate, r=WaffleLapkinMatthias Krüger-3/+39
Move the unused extern crate check back to the resolver. It doesn't have anything to do in `rustc_hir_typeck`.
2023-02-27Rollup merge of #104265 - faern:move-ipaddr-to-core, r=joshtriplettMatthias Krüger-1/+1
Move IpAddr, SocketAddr and V4+V6 related types to `core` Implements RFC https://github.com/rust-lang/rfcs/pull/2832. The RFC has completed FCP with disposition merge, but is not yet merged. Moves IP types to `core` as specified in the RFC. The full list of moved types is: `IpAddr`, `Ipv4Addr`, `Ipv6Addr`, `SocketAddr`, `SocketAddrV4`, `SocketAddrV6`, `Ipv6MulticastScope` and `AddrParseError`. Doing this move was one of the main driving arguments behind #78802.
2023-02-27handle only postfix decrementnx2k3-48/+0
2023-02-27diagnostics: avoid querying `associated_item` in the resolverMichael Howell-0/+17
Fixes #108529
2023-02-27check double negationnx2k3-81/+80
2023-02-27Auto merge of #108175 - cjgillot:validate-storage, r=tmiaskobors-0/+43
MIR-Validate StorageLive. `StorageLive` statements on a local which already has storage is banned by miri. This check is easy enough, and can detect bugs in MIR opts.
2023-02-27Commit some new solver testsMichael Goulet-0/+66
2023-02-27Rollup merge of #108502 - lenko-d:cannot_relate_region, r=compiler-errorsMatthias Krüger-0/+40
Don't trigger error for ReError when other region is empty. Fixes [#107988](https://github.com/rust-lang/rust/issues/107988)
2023-02-27Rollup merge of #108486 - cjgillot:owner-ditem, r=NilstriebMatthias Krüger-2/+4
Merge diagnostic_items duplicate diagnostics To deduplicate how we diagnose duplication.
2023-02-27Rollup merge of #108477 - y21:replace-semi-with-comma-sugg, r=compiler-errorsMatthias Krüger-3/+7
Make `match` arm comma suggestion more clear Fixes #108472
2023-02-27Rollup merge of #108319 - ↵Matthias Krüger-0/+97
compiler-errors:dont-project-to-specializable-rpitits, r=lcnr Don't project specializable RPITIT projection This effective rejects specialization + RPITIT/AFIT (usages of `impl Trait` in traits) because the implementation is significantly complicated over making regular "default" trait method bodies work. I have another PR that experimentally fixes all this, but the code may not be worth investing in.
2023-02-26Don't trigger ICE for ReError when the other region is empty.Lenko Donchev-0/+40
2023-02-26fix #108495, postfix decrement and prefix decrement has no warningnx2k3-0/+159
2023-02-26Adapt issue-77982.stderr to new rustc errorLinus Färnstrand-1/+1
2023-02-26Rollup merge of #108337 - tshepang:translatable-hir-analysis, r=cjgillotMatthias Krüger-1/+1
hir-analysis: make a helpful note
2023-02-26Rollup merge of #107941 - compiler-errors:str-has-u8-slice-for-auto, r=lcnrMatthias Krüger-0/+29
Treat `str` as containing `[u8]` for auto trait purposes Wanted to gauge ``@rust-lang/lang`` and ``@rust-lang/types`` teams' thoughts on treating `str` as "containing" a `[u8]` slice for auto-trait purposes. ``@dtolnay`` brought this up in https://github.com/rust-lang/rust/issues/13231#issuecomment-1399386472 as a blocker for future `str` type librarification, and I think it's both a valid concern and very easy to fix. I'm interested in actually doing that `str` type librarification (#107939), but this probably should be considered in the mean time regardless of that PR. r? types for the impl, though this definitely needs an FCP.
2023-02-26generalize help messagey21-3/+7
2023-02-26Store the body type in THIR.Camille GILLOT-0/+3
2023-02-26Merge the two diagnostics.Camille GILLOT-2/+4
2023-02-26Auto merge of #108473 - matthiaskrgr:rollup-qjyae58, r=matthiaskrgrbors-12/+204
Rollup of 8 pull requests Successful merges: - #107062 (Do some cleanup of doc/index.md) - #107890 (Lint against `Iterator::map` receiving a callable that returns `()`) - #108431 (Add regression test for #107918) - #108432 (test: drop unused deps) - #108436 (make "proc macro panicked" translatable) - #108444 (docs/test: add UI test and docs for `E0476`) - #108449 (Do not lint ineffective unstable trait impl for unresolved trait) - #108456 (Complete migrating `ast_passes` to derive diagnostics) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-26Rollup merge of #108456 - clubby789:ast-passes-diag-migrate, r=compiler-errorsMatthias Krüger-12/+12
Complete migrating `ast_passes` to derive diagnostics cc #100717 ```@rustbot``` label +A-translation
2023-02-26Rollup merge of #108449 - fee1-dead-contrib:do_not_lint_unresolved, ↵Matthias Krüger-0/+17
r=compiler-errors Do not lint ineffective unstable trait impl for unresolved trait
2023-02-26Rollup merge of #108444 - Ezrashaw:add-test+docs-for-e0476, r=GuillaumeGomezMatthias Krüger-0/+44
docs/test: add UI test and docs for `E0476` Final undocumented error code. Not entirely sure about wording in the docs. Part of https://github.com/rust-lang/rust/issues/61137. r? ```@compiler-errors``` cc ```@compiler-errors```
2023-02-26Rollup merge of #108431 - GuillaumeGomez:regression-test-for-107918, r=notriddleMatthias Krüger-0/+21
Add regression test for #107918 Fixes https://github.com/rust-lang/rust/issues/107918. r? ```@notriddle```
2023-02-26Rollup merge of #107890 - obeis:mapping-to-unit, r=cjgillotMatthias Krüger-0/+110
Lint against `Iterator::map` receiving a callable that returns `()` Close #106991
2023-02-26hir-analysis: make a helpful noteTshepang Mbambo-1/+1
2023-02-25Special note for str in auto traitsMichael Goulet-1/+1
2023-02-25Treat `str` as containing `[u8]` for auto trait purposesMichael Goulet-0/+29
2023-02-25Rollup merge of #108333 - compiler-errors:new-solver-object-sound, r=lcnrMichael Goulet-0/+102
Make object bound candidates sound in the new trait solver r? `@lcnr`
2023-02-25Rollup merge of #107911 - blyxyas:issue-107231-fix, r=compiler-errorsMichael Goulet-0/+42
Add check for invalid #[macro_export] arguments Resolves #107231 Sorry if I made something wrong, this is my first contribution to the repo.
2023-02-25Rollup merge of #107675 - jsgf:link-directives, r=davidtwcoMichael Goulet-0/+11
Implement -Zlink-directives=yes/no `-Zlink-directives=no` will ignored `#[link]` directives while compiling a crate, so nothing is emitted into the crate's metadata. The assumption is that the build system already knows about the crate's native dependencies and can provide them at link time without these directives. This is another way to address issue # #70093, which is currently addressed by `-Zlink-native-libraries` (implemented in #70095). The latter is implemented at link time, which has the effect of ignoring `#[link]` in *every* crate. This makes it a very large hammer as it requires all native dependencies to be known to the build system to be at all usable, including those in sysroot libraries. I think this means its effectively unused, and definitely under-used. Being able to control this on a crate-by-crate basis should make it much easier to apply when needed. I'm not sure if we need both mechanisms, but we can decide that later. cc `@pcwalton` `@cramertj`
2023-02-25Rollup merge of #107291 - oli-obk:rustdoc_breaking_change, r=estebankMichael Goulet-0/+20
[breaking change] Remove a rustdoc back compat warning This warning was introduced in https://github.com/rust-lang/rust/pull/62855 for users who use `rustdoc` directly on proc macro crates (instead of using `cargo doc`) without passing `--crate-type proc-macro` (which `cargo doc` passed automatically).