about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2022-10-25Add more tests for `impl Fn() -> impl Trait`Maybe Waffle-0/+106
2022-10-25Allow `impl Fn() -> impl Trait` in return positionMaybe Waffle-67/+73
This allows writing the following function signatures: ```rust fn f0() -> impl Fn() -> impl Trait; fn f3() -> &'static dyn Fn() -> impl Trait; ``` These signatures were already allowed for common traits and associated types, there is no reason why `Fn*` traits should be special in this regard.
2022-10-24Auto merge of #103471 - JohnTitor:rollup-tfmy6ab, r=JohnTitorbors-731/+1199
Rollup of 7 pull requests Successful merges: - #99578 (Remove redundant lifetime bound from `impl Borrow for Cow`) - #99939 (Sort tests at compile time, not at startup) - #102271 (Stabilize `duration_checked_float`) - #102766 (Don't link to `libresolv` in libstd on Darwin) - #103277 (Update libstd's libc to 0.2.135 (to make `libstd` no longer pull in `libiconv.dylib` on Darwin)) - #103437 (Sync rustc_codegen_cranelift) - #103466 (Fix grammar in docs for std::io::Read) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-10-24Rollup merge of #103466 - jruderman:patch-2, r=Dylan-DPCYuki Okushi-2/+2
Fix grammar in docs for std::io::Read Two independent clauses were incorrectly joined by a bare comma. The simplest fix would be to switch to a semicolon, but I think it's slightly better to keep the comma and use the coordinating conjunction "so".
2022-10-24Rollup merge of #103437 - bjorn3:sync_cg_clif-2022-10-23, r=bjorn3Yuki Okushi-638/+1043
Sync rustc_codegen_cranelift r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2022-10-24Rollup merge of #103277 - thomcc:bump-libc-135, r=Mark-SimulacrumYuki Okushi-3/+3
Update libstd's libc to 0.2.135 (to make `libstd` no longer pull in `libiconv.dylib` on Darwin) This is to pull in https://github.com/rust-lang/libc/pull/2944. It's related to https://github.com/rust-lang/rust/pull/102766, in that they both remove unused dylibs from libstd on Darwin platforms. As a result, I'm marking this as relnotes since everybody agreed it was good to add it to the other as well. (The note should be about no longer linking against libiconv -- the libc update is irrelevant). Might as well have the same reviewer too. r? `@Mark-Simulacrum`
2022-10-24Rollup merge of #102766 - thomcc:remove-resolv, r=Mark-SimulacrumYuki Okushi-4/+0
Don't link to `libresolv` in libstd on Darwin Currently we link `libresolv` into every Rust program on apple targets despite never using it (as of https://github.com/rust-lang/rust/pull/44965). I had thought we needed this for `getaddrinfo` or something, but we do not / cannot safely use it. I'd like to fix this for `libiconv` too (the other library we pull in. that's harder since it's coming in through `libc`, which is https://github.com/rust-lang/libc/pull/2944)). --- This may warrant release notes. I'm not sure but I've added the flag regardless -- It's a change to the list of dylibs every Rust program pulls in, so it's worth mentioning. It's pretty unlikely anybody was relying on this being pulled in, and `std` does not guarantee that it will link (and thus transitively provide access to) any particular system library -- anybody relying on that behavior would already be broken when dynamically linking std. That is, there's an outside chance something will fail to link on macOS and iOS because it was accidentally relying on our unnecessary dependency. (If that *does* happen, that project could be easily fixed by linking libresolv explicitly on those platforms, probably via `#[link(name = "resolv")] extern {}`,` -Crustc-link-lib=resolv`, `println!("cargo:rustc-link-lib=resolv")`, or one of several places in `.config/cargo.toml`) --- I'm also going to preemptively add the nomination for discussing this in the libs meeting. Basically: Do we care about programs that assume we will bring libraries in that we do not use. `libresolv` and `libiconv` on macOS/iOS are in this camp (`libresolv` because we used to use it, and `libiconv` because the `libc` crate was unintentionally(?) pulling it in to every Rust program). I'd like to remove them both, but this may cause link issues programs that are relying on `std` to depend on them transitively. (Relying on std for this does not work in all build configurations, so this seems very fragile, and like a use case we should not support). More generally, IMO we should not guarantee the specific set of system-provided libraries we use (beyond what is implied by an OS version requirement), which means we'd be free to remove this cruft.
2022-10-24Rollup merge of #102271 - ↵Yuki Okushi-26/+21
lopopolo:lopopolo/stabilize-duration-try-from-secs-float, r=dtolnay Stabilize `duration_checked_float` ## Stabilization Report This stabilization report is for a stabilization of `duration_checked_float`, tracking issue: https://github.com/rust-lang/rust/issues/83400. ### Implementation History - https://github.com/rust-lang/rust/pull/82179 - https://github.com/rust-lang/rust/pull/90247 - https://github.com/rust-lang/rust/pull/96051 - Changed error type to `FromFloatSecsError` in https://github.com/rust-lang/rust/pull/90247 - https://github.com/rust-lang/rust/pull/96051 changes the rounding mode to round-to-nearest instead of truncate. ## API Summary This stabilization report proposes the following API to be stabilized in `core`, along with their re-exports in `std`: ```rust // core::time impl Duration { pub const fn try_from_secs_f32(secs: f32) -> Result<Duration, TryFromFloatSecsError>; pub const fn try_from_secs_f64(secs: f64) -> Result<Duration, TryFromFloatSecsError>; } #[derive(Debug, Clone, PartialEq, Eq)] pub struct TryFromFloatSecsError { ... } impl core::fmt::Display for TryFromFloatSecsError { ... } impl core::error::Error for TryFromFloatSecsError { ... } ``` These functions are made const unstable under `duration_consts_float`, tracking issue #72440. There is an open question in the tracking issue around what the error type should be called which I was hoping to resolve in the context of an FCP. In this stabilization PR, I have altered the name of the error type to `TryFromFloatSecsError`. In my opinion, the error type shares the name of the method (adjusted to accommodate both types of floats), which is consistent with other error types in `core`, `alloc` and `std` like `TryReserveError` and `TryFromIntError`. ## Experience Report Code such as this is ready to be converted to a checked API to ensure it is panic free: ```rust impl Time { pub fn checked_add_f64(&self, seconds: f64) -> Result<Self, TimeError> { // Fail safely during `f64` conversion to duration if seconds.is_nan() || seconds.is_infinite() { return Err(TzOutOfRangeError::new().into()); } if seconds.is_sign_positive() { self.checked_add(Duration::from_secs_f64(seconds)) } else { self.checked_sub(Duration::from_secs_f64(-seconds)) } } } ``` See: https://github.com/artichoke/artichoke/issues/2194. `@rustbot` label +T-libs-api -T-libs cc `@mbartlett21`
2022-10-24Rollup merge of #99939 - saethlin:pre-sort-tests, r=thomcc,jackh726Yuki Okushi-57/+130
Sort tests at compile time, not at startup Recently, another Miri user was trying to run `cargo miri test` on the crate `iced-x86` with `--features=code_asm,mvex`. This configuration has a startup time of ~18 minutes. That's ~18 minutes before any tests even start to run. The fact that this crate has over 26,000 tests and Miri is slow makes a lot of code which is otherwise a bit sloppy but fine into a huge runtime issue. Sorting the tests when the test harness is created instead of at startup time knocks just under 4 minutes out of those ~18 minutes. I have ways to remove most of the rest of the startup time, but this change requires coordinating changes of both the compiler and libtest, so I'm sending it separately. (except for doctests, because there is no compile-time harness)
2022-10-24Rollup merge of #99578 - steffahn:remove_redundant_bound, r=thomccYuki Okushi-1/+0
Remove redundant lifetime bound from `impl Borrow for Cow` The lifetime bound `B::Owned: 'a` is redundant and doesn't make a difference, because `Cow<'a, B>` comes with an implicit `B: 'a`, and associated types will outlive lifetimes outlived by the `Self` type (and all the trait's generic parameters, of which there are none in this case), so the implicit `B: 'a` implies `B::Owned: 'a` anyway. The explicit lifetime bound here does however [end up in documentation](https://doc.rust-lang.org/std/borrow/enum.Cow.html#impl-Borrow%3CB%3E), and that's confusing in my opinion, so let's remove it ^^ _(Documentation right now, compare to `AsRef`, too:)_ ![Screenshot_20220722_014055](https://user-images.githubusercontent.com/3986214/180332665-424d0c05-afb3-40d8-a330-a57a2c9a494b.png)
2022-10-24Fix grammar in docs for std::io::ReadJesse Ruderman-2/+2
2022-10-24Auto merge of #102536 - scottmcm:lookup_line-tweak, r=jackh726bors-4/+1
Shorten the `lookup_line` code slightly The `match` looks like it's exactly the same as `checked_sub(1)`, so we might as well see if perf says we can just do that to save a couple lines.
2022-10-24Auto merge of #100848 - xfix:use-metadata-for-slice-len, r=thomccbors-17/+9
Use ptr::metadata in <[T]>::len implementation This avoids duplication of ptr::metadata code. I believe this is acceptable as the previous approach essentially duplicated `ptr::metadata` because back then `rustc_allow_const_fn_unstable` annotation did not exist. I would like somebody to ping `@rust-lang/wg-const-eval` as the documentation says: > Always ping `@rust-lang/wg-const-eval` if you are adding more rustc_allow_const_fn_unstable attributes to any const fn.
2022-10-24Auto merge of #103452 - notriddle:rollup-peewevm, r=notriddlebors-145/+305
Rollup of 11 pull requests Successful merges: - #100462 (Clarify `array::from_fn` documentation) - #101644 (Document surprising and dangerous fs::Permissions behaviour on Unix) - #103005 (kmc-solid: Handle errors returned by `SOLID_FS_ReadDir`) - #103140 (Add diagnostic for calling a function with the same name with unresolved Macro) - #103254 (rustdoc: do not filter out cross-crate `Self: Sized` bounds) - #103347 (bootstrap: also create rustc-src component in sysroot) - #103402 (Fix wrapped valid-range handling in ty_find_init_error) - #103414 (Pretty print lifetimes captured by RPIT) - #103424 (rustdoc: remove no-op CSS `.code-header { border-bottom: none }`) - #103434 (Use functions for jump-to-def-background rustdoc GUI test) - #103447 (`MaybeUninit`: use `assume_init_drop()` in the partially initialized array example) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-10-23Rollup merge of #103447 - ajtribick:maybe_uninit_doc_update, r=scottmcmMichael Howell-2/+1
`MaybeUninit`: use `assume_init_drop()` in the partially initialized array example The `assume_init_drop()` method does the same thing as the pointer conversion, and makes the example more straightforward.
2022-10-23Rollup merge of #103434 - ↵Michael Howell-38/+17
GuillaumeGomez:gui-test-jump-to-def-background-cleanup, r=notriddle Use functions for jump-to-def-background rustdoc GUI test r? `@notriddle`
2022-10-23Rollup merge of #103424 - ↵Michael Howell-1/+0
notriddle:notriddle/code-header-border-bottom-none, r=GuillaumeGomez rustdoc: remove no-op CSS `.code-header { border-bottom: none }` The code headers are always h3 or h4, which don't have border-bottom by default anyway.
2022-10-23Rollup merge of #103414 - compiler-errors:rpit-print-lt, r=cjgillotMichael Howell-21/+31
Pretty print lifetimes captured by RPIT This specifically makes the output in #103409 change from: ```diff error: `impl` item signature doesn't match `trait` item signature --> $DIR/signature-mismatch.rs:15:5 | LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>; | ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>` ... LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2` | = note: expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>` - found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>` + found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2` = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output error: aborting due to previous error ``` Along with the UI tests in this PR, which I think are all improvements! r? `@oli-obk` though feel free to re-roll
2022-10-23Rollup merge of #103402 - joshtriplett:niche-wrap-fix, r=oli-obkMichael Howell-52/+73
Fix wrapped valid-range handling in ty_find_init_error Rust's niche handling allows for wrapping valid ranges with end < start; for instance, a valid range with start=43 and end=41 means a niche of 42. Most places in the compiler handle this correctly, but `ty_find_init_error` assumed that `lo > 0` means the type cannot contain a zero. Fix it to handle wrapping ranges.
2022-10-23Rollup merge of #103347 - RalfJung:rustc-src, r=Mark-SimulacrumMichael Howell-0/+14
bootstrap: also create rustc-src component in sysroot Fixes https://github.com/rust-lang/rust-analyzer/issues/12926
2022-10-23Rollup merge of #103254 - fmease:fix-24183, r=GuillaumeGomezMichael Howell-18/+56
rustdoc: do not filter out cross-crate `Self: Sized` bounds All type parameters **except `Self`** are implicitly `Sized` ([via](https://doc.rust-lang.org/nightly/std/marker/trait.Sized.html)). Previously, we disregarded the exception of `Self` and omitted cross-crate `Sized` bounds of *any* type parameter *including* `Self` when rendering. From now on, we *do* render cross-crate `Self: Sized` bounds. Most notably, in `std` we now finally properly render the `Sized` bound of the `Clone` trait as well as the `Self: Sized` bound on `Iterator::map`. Fixes #24183. ``@rustbot`` label T-rustdoc A-cross-crate-reexports r? rustdoc
2022-10-23Rollup merge of #103140 - chenyukang:yukang/fix-103112, r=estebankMichael Howell-2/+33
Add diagnostic for calling a function with the same name with unresolved Macro Fixes #103112
2022-10-23Rollup merge of #103005 - solid-rs:patch/kmc-solid/readdir-terminator, r=m-ou-seMichael Howell-8/+12
kmc-solid: Handle errors returned by `SOLID_FS_ReadDir` Fixes the issue where the `std::fs::ReadDir` implementaton of the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets silently suppressed errors returned by the underlying `SOLID_FS_ReadDir` system function. The new implementation correctly handles all cases: - `SOLID_ERR_NOTFOUND` indicates the end of directory stream. - `SOLID_ERR_OK` + non-empty `d_name` indicates success. - Some old filesystem drivers may return `SOLID_ERR_OK` + empty `d_name` to indicate the end of directory stream. - Any other negative values (per ITRON convention) represent an error.
2022-10-23Rollup merge of #101644 - Timmmm:file_permissions_docs, r=thomccMichael Howell-3/+64
Document surprising and dangerous fs::Permissions behaviour on Unix This documents the very surprising behaviour that `set_readonly(false)` will make a file *world writable* on Unix. I would go so far as to say that this function should be deprecated on Unix, or maybe even entirely. But documenting the bad behaviour is a good first step. Fixes #74895
2022-10-23Rollup merge of #100462 - zohnannor:master, r=thomccMichael Howell-0/+4
Clarify `array::from_fn` documentation I've seen quite a few of people on social media confused of where the length of array is coming from in the newly stabilized `array::from_fn` example. This PR tries to clarify the documentation on this.
2022-10-23Auto merge of #103062 - cuviper:dist-mips, r=Mark-Simulacrumbors-88/+3345
Upgrade dist-mips*-linux to ubuntu:22.04 + crosstool-ng These have no change in compatibility, still Linux 4.4 and glibc 2.23. The main motivation for upgrading is that LLVM 16 will require at least GCC 7.1. Using crosstool-ng lets us choose our own toolchain versions, and then the Ubuntu version doesn't matter so much, just for the host compilation while we cross-compile.
2022-10-23Auto merge of #103137 - dtolnay:readdir, r=Mark-Simulacrumbors-20/+65
Eliminate 280-byte memset from ReadDir iterator This guy: https://github.com/rust-lang/rust/blob/1536ab1b383f21b38f8d49230a2aecc51daffa3d/library/std/src/sys/unix/fs.rs#L589 It turns out `libc::dirent64` is quite big&mdash;https://docs.rs/libc/0.2.135/libc/struct.dirent64.html. In #103135 this memset accounted for 0.9% of the runtime of iterating a big directory. Almost none of the big zeroed value is ever used. We memcpy a tiny prefix (19 bytes) into it, and then read just 9 bytes (`d_ino` and `d_type`) back out. We can read exactly those 9 bytes we need directly from the original entry_ptr instead. ## History This code got added in #93459 and tweaked in #94272 and #94750. Prior to #93459, there was no memset but a full 280 bytes were being copied from the entry_ptr. <table><tr><td>copy 280 bytes</td></tr></table> This was not legal because not all of those bytes might be initialized, or even allocated, depending on the length of the directory entry's name, leading to a segfault. That PR fixed the segfault by creating a new zeroed dirent64 and copying just the guaranteed initialized prefix into it. <table><tr><td>memset 280 bytes</td><td>copy 19 bytes</td></tr></table> However this was still buggy because it used `addr_of!((*entry_ptr).d_name)`, which is considered UB by Miri in the case that the full extent of entry_ptr is not in bounds of the same allocation. (Arguably this shouldn't be a requirement, but here we are.) The UB got fixed by #94272 by replacing `addr_of` with some pointer manipulation based on `offset_from`, but still fundamentally the same operation. <table><tr><td>memset 280 bytes</td><td>copy 19 bytes</td></tr></table> Then #94750 noticed that only 9 of those 19 bytes were even being used, so we could pick out only those 9 to put in the ReadDir value. <table><tr><td>memset 280 bytes</td><td>copy 19 bytes</td><td>copy 9 bytes</td></tr></table> After my PR we just grab the 9 needed bytes directly from entry_ptr. <table><tr><td>copy 9 bytes</td></tr></table> The resulting code is more complex but I believe still worthwhile to land for the following reason. This is an extremely straightforward thing to accomplish in C and clearly libc assumes that; literally just `entry_ptr->d_name`. The extra work in comparison to accomplish it in Rust is not an example of any actual safety being provided by Rust. I believe it's useful to have uncovered that and think about what could be done in the standard library or language to support this obvious operation better. ## References - https://man7.org/linux/man-pages/man3/readdir.3.html
2022-10-23Annotate static lifetimes tooMichael Goulet-28/+22
2022-10-23MaybeUninit: use assume_init_drop() in the partially initialized array exampleAndrew Tribick-2/+1
2022-10-23Auto merge of #101403 - bjorn3:dylib_lto, r=Mark-Simulacrumbors-27/+135
Enable LTO for rustc_driver.so Alternative to https://github.com/rust-lang/rust/pull/97154 This enables LTO'ing dylibs behind a feature flag and uses this feature for compiling rustc_driver.so.
2022-10-23Rustfmt cg_clif's build systembjorn3-6/+2
2022-10-23Update list of allowed cranelift dependenciesbjorn3-0/+2
2022-10-23Merge commit '266e96785ab71834b917bf474f130a6d8fdecd4b' into ↵bjorn3-638/+1045
sync_cg_clif-2022-10-23
2022-10-23Revert "Update to Cranelift 0.89.0"bjorn3-154/+30
It added a lot of extra dependencies. I opened bytecodealliance/wasmtime#5101 to remove those dependencies again. This reverts commit da770abea31e25514af65387ea93a755242610b7.
2022-10-23Revert "Stop using a depracated function"bjorn3-3/+3
This reverts commit b1791eef6add9563c1b750e88ec02e681a9a4ad7.
2022-10-23Use functions for jump-to-def-background rustodoc GUI testGuillaume Gomez-38/+17
2022-10-23Fix drop for dyn*bjorn3-2/+45
2022-10-23Allow dyn* upcastingbjorn3-6/+28
2022-10-23Update rustc test suite failure listbjorn3-2/+0
2022-10-23Rustup to rustc 1.66.0-nightly (6e95b6da8 2022-10-22)bjorn3-1/+1
2022-10-23Update LLVM submodulebjorn3-0/+0
2022-10-23Introduce dedicated `-Zdylib-lto` flag for enabling LTO on `dylib`sJakub Beránek-13/+66
2022-10-23Sync from rust e64f1110c062f61746f222059439529a43ccf6dcbjorn3-2/+2
2022-10-23Add `rust.lto` config optionJakub Beránek-2/+39
2022-10-23Allow LTO for dylibsbjorn3-24/+33
2022-10-23Add missing export for the oom strategy symbolbjorn3-1/+10
2022-10-23Auto merge of #103431 - Dylan-DPC:rollup-oozfo89, r=Dylan-DPCbors-264/+541
Rollup of 6 pull requests Successful merges: - #101293 (Recover when unclosed char literal is parsed as a lifetime in some positions) - #101908 (Suggest let for assignment, and some code refactor) - #103192 (rustdoc: Eliminate uses of `EarlyDocLinkResolver::all_traits`) - #103226 (Check `needs_infer` before `needs_drop` during HIR generator analysis) - #103249 (resolve: Revert "Set effective visibilities for imports more precisely") - #103305 (Move some tests to more reasonable places) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-10-23Rollup merge of #103305 - c410-f3r:moar-errors, r=petrochenkovDylan DPC-1/+1
Move some tests to more reasonable places r? `@petrochenkov`
2022-10-23Rollup merge of #103249 - petrochenkov:revaddids, r=oli-obkDylan DPC-36/+26
resolve: Revert "Set effective visibilities for imports more precisely" In theory the change was correct, but in practice the use of import items in HIR is limited and hacky, and it expects that (effective) visibilities for all (up to) 3 IDs of the import are set to the value reflecting (effective) visibility of the whole syntactic `use` item rather than its individual components. Fixes https://github.com/rust-lang/rust/issues/102352 r? `@oli-obk`
2022-10-23Rollup merge of #103226 - compiler-errors:delay-if-need-infer, r=lcnrDylan DPC-18/+23
Check `needs_infer` before `needs_drop` during HIR generator analysis This is kinda a revival of #103036, but with the understanding that after fallback, a generator-interior type will only have `needs_infer` true if there's an error that prevented int or float variable fallback to occur (modulo region variables, which are erased). Therefore the best choice here is to delay a bug and skip the `needs_drop` call altogether. r? `@lcnr` feel free to reassign though