Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #102230

Closed
wants to merge 24 commits into from
Closed

Conversation

Dylan-DPC
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

WaffleLapkin and others added 24 commits September 4, 2022 17:27
…ls/alloc.rs` nicer

- Use `.addr()` instead of `as`-cast
- Use `add` instead of `offset` and remove some `as isize` casts by doing that
- Remove some casts
…rminal

The UNIX and WASI implementations use `isatty`. The Windows
implementation uses the same logic the `atty` crate uses, including the
hack needed to detect msys terminals.

Implement this trait for `File` and for `Stdin`/`Stdout`/`Stderr` and
their locked counterparts on all platforms. On UNIX and WASI, implement
it for `BorrowedFd`/`OwnedFd`. On Windows, implement it for
`BorrowedHandle`/`OwnedHandle`.

Based on rust-lang#91121

Co-authored-by: Matt Wilkinson <mattwilki17@gmail.com>
If a process has no console, it'll have NULL in place of a console
handle, so return early with `false` in that case without making any OS
calls.
Rather than referencing a slice's pointer and then creating a new slice
with a longer length, offset from the base structure pointer instead.
This makes some choices of Rust semantics happier.
This rule became redundant in 07e3f99.
When `#source-sidebar` became nested below `.sidebar`, it went from being
`position: fixed` to `position: static`, and according to MDN's [z-index]
documentation, this means it has no effect.

[z-index]: https://developer.mozilla.org/en-US/docs/Web/CSS/z-index
This rule became redundant in 07e3f99.
When `#source-sidebar` became nested below `.sidebar`, it went from being
`position: fixed` to `position: static`, and according to MDN's [z-index]
documentation, this means it has no effect.

[z-index]: https://developer.mozilla.org/en-US/docs/Web/CSS/z-index
… r=thomcc

Add `IsTerminal` trait to determine if a descriptor or handle is a terminal

The UNIX implementation uses `isatty`. The Windows implementation uses
the same logic the `atty` crate uses, including the hack needed to
detect msys terminals.

Implement this trait for `Stdin`/`Stdout`/`Stderr`/`File` on all
platforms. On Unix, implement it for `BorrowedFd`/`OwnedFd`. On Windows,
implement it for `BorrowedHandle`/`OwnedHandle`.

Based on rust-lang#91121

Co-authored-by: Matt Wilkinson <mattwilki17@gmail.com>
Refactor some `std` code that works with pointer offstes

This PR replaces `pointer::offset` in standard library with `pointer::add` and `pointer::sub`, [re]moving some casts and using `.addr()` while we are at it.

This is a more complicated refactor than all other sibling PRs, so take a closer look when reviewing, please 😃  (though I've checked this multiple times and it looks fine).

r? ```@scottmcm```

_split off from rust-lang#100746, continuation of #100822_
…=fee1-dead

Add const_closure, Constify Try trait

Adds a struct for creating const `FnMut` closures (for now just copy pasted form my [const_closure](https://crates.io/crates/const_closure) crate).
I'm not sure if this way is how it should be done.
The `ConstFnClosure` and `ConstFnOnceClosure` structs can probably also be entirely removed.

This is then used to constify the try trait.

Not sure if i should add const_closure in its own pr and maybe make it public behind a perma-unstable feature gate.

cc ``@fee1-dead``  ``@rust-lang/wg-const-eval``
…, r=GuillaumeGomez

rustdoc: remove no-op CSS `#source-sidebar { z-index }`

This rule became redundant in 07e3f99. When `#source-sidebar` became nested below `.sidebar`, it went from being `position: fixed` to `position: static`, and according to MDN's [z-index] documentation, this means it has no effect.

[z-index]: https://developer.mozilla.org/en-US/docs/Web/CSS/z-index
…r=cjgillot

diagnostics: avoid syntactically invalid suggestion in if conditionals

Fixes rust-lang#101065
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Sep 24, 2022
@Dylan-DPC
Copy link
Member Author

@bors r+ rollup=never p=5

@bors
Copy link
Contributor

bors commented Sep 24, 2022

📌 Commit 7414529 has been approved by Dylan-DPC

It is now in the queue for this repository.

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Sep 24, 2022
@bors
Copy link
Contributor

bors commented Sep 24, 2022

⌛ Testing commit 7414529 with merge 969ffad567dcced557176863d52cf9748629707f...

@bors
Copy link
Contributor

bors commented Sep 24, 2022

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 24, 2022
@rust-log-analyzer
Copy link
Collaborator

The job dist-various-2 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] gimli test:false 4.515
[RUSTC-TIMING] object test:false 5.293
warning: dropping unsupported crate type `dylib` for target `wasm32-wasi`

error[E0277]: the trait bound `io::stdio::Stdin: owned::AsFd` is not satisfied
     |
1034 | / macro_rules! impl_is_terminal {
1034 | / macro_rules! impl_is_terminal {
1035 | |     ($($t:ty),*$(,)?) => {$(
1036 | |         #[unstable(feature = "sealed", issue = "none")]
1037 | |         impl crate::sealed::Sealed for $t {}
1043 | |                 crate::sys::io::is_terminal(self)
1043 | |                 crate::sys::io::is_terminal(self)
     | |                 --------------------------- ^^^^ the trait `owned::AsFd` is not implemented for `io::stdio::Stdin`
     | |                 required by a bound introduced by this call
...    |
1046 | |     )*}
1047 | | }
1047 | | }
     | |_- in this expansion of `impl_is_terminal!`
1048 |
1049 |   impl_is_terminal!(File, Stdin, StdinLock<'_>, Stdout, StdoutLock<'_>, Stderr, StderrLock<'_>);
     |
     |
     = help: the following other types implement trait `owned::AsFd`:
               &T
               Arc<T>
               Box<T>
               Socket
               WasiFd
               WasiFd
               fs::File
               owned::BorrowedFd<'_>
note: required by a bound in `is_terminal`
    --> library/std/src/sys/wasi/io.rs:77:30
     |
     |
77   | pub fn is_terminal(fd: &impl AsFd) -> bool {
     |                              ^^^^ required by this bound in `is_terminal`

error[E0277]: the trait bound `StdinLock<'_>: owned::AsFd` is not satisfied
     |
1034 | / macro_rules! impl_is_terminal {
1034 | / macro_rules! impl_is_terminal {
1035 | |     ($($t:ty),*$(,)?) => {$(
1036 | |         #[unstable(feature = "sealed", issue = "none")]
1037 | |         impl crate::sealed::Sealed for $t {}
1043 | |                 crate::sys::io::is_terminal(self)
1043 | |                 crate::sys::io::is_terminal(self)
     | |                 --------------------------- ^^^^ the trait `owned::AsFd` is not implemented for `StdinLock<'_>`
     | |                 required by a bound introduced by this call
...    |
1046 | |     )*}
1047 | | }
1047 | | }
     | |_- in this expansion of `impl_is_terminal!`
1048 |
1049 |   impl_is_terminal!(File, Stdin, StdinLock<'_>, Stdout, StdoutLock<'_>, Stderr, StderrLock<'_>);
     |
     |
     = help: the following other types implement trait `owned::AsFd`:
               &T
               Arc<T>
               Box<T>
               Socket
               WasiFd
               WasiFd
               fs::File
               owned::BorrowedFd<'_>
note: required by a bound in `is_terminal`
    --> library/std/src/sys/wasi/io.rs:77:30
     |
     |
77   | pub fn is_terminal(fd: &impl AsFd) -> bool {
     |                              ^^^^ required by this bound in `is_terminal`

error[E0277]: the trait bound `io::stdio::Stdout: owned::AsFd` is not satisfied
     |
1034 | / macro_rules! impl_is_terminal {
1034 | / macro_rules! impl_is_terminal {
1035 | |     ($($t:ty),*$(,)?) => {$(
1036 | |         #[unstable(feature = "sealed", issue = "none")]
1037 | |         impl crate::sealed::Sealed for $t {}
1043 | |                 crate::sys::io::is_terminal(self)
1043 | |                 crate::sys::io::is_terminal(self)
     | |                 --------------------------- ^^^^ the trait `owned::AsFd` is not implemented for `io::stdio::Stdout`
     | |                 required by a bound introduced by this call
...    |
1046 | |     )*}
1047 | | }
1047 | | }
     | |_- in this expansion of `impl_is_terminal!`
1048 |
1049 |   impl_is_terminal!(File, Stdin, StdinLock<'_>, Stdout, StdoutLock<'_>, Stderr, StderrLock<'_>);
     |
     |
     = help: the following other types implement trait `owned::AsFd`:
               &T
               Arc<T>
               Box<T>
               Socket
               WasiFd
               WasiFd
               fs::File
               owned::BorrowedFd<'_>
note: required by a bound in `is_terminal`
    --> library/std/src/sys/wasi/io.rs:77:30
     |
     |
77   | pub fn is_terminal(fd: &impl AsFd) -> bool {
     |                              ^^^^ required by this bound in `is_terminal`

error[E0277]: the trait bound `StdoutLock<'_>: owned::AsFd` is not satisfied
     |
1034 | / macro_rules! impl_is_terminal {
1034 | / macro_rules! impl_is_terminal {
1035 | |     ($($t:ty),*$(,)?) => {$(
1036 | |         #[unstable(feature = "sealed", issue = "none")]
1037 | |         impl crate::sealed::Sealed for $t {}
1043 | |                 crate::sys::io::is_terminal(self)
1043 | |                 crate::sys::io::is_terminal(self)
     | |                 --------------------------- ^^^^ the trait `owned::AsFd` is not implemented for `StdoutLock<'_>`
     | |                 required by a bound introduced by this call
...    |
1046 | |     )*}
1047 | | }
1047 | | }
     | |_- in this expansion of `impl_is_terminal!`
1048 |
1049 |   impl_is_terminal!(File, Stdin, StdinLock<'_>, Stdout, StdoutLock<'_>, Stderr, StderrLock<'_>);
     |
     |
     = help: the following other types implement trait `owned::AsFd`:
               &T
               Arc<T>
               Box<T>
               Socket
               WasiFd
               WasiFd
               fs::File
               owned::BorrowedFd<'_>
note: required by a bound in `is_terminal`
    --> library/std/src/sys/wasi/io.rs:77:30
     |
     |
77   | pub fn is_terminal(fd: &impl AsFd) -> bool {
     |                              ^^^^ required by this bound in `is_terminal`

error[E0277]: the trait bound `io::stdio::Stderr: owned::AsFd` is not satisfied
     |
1034 | / macro_rules! impl_is_terminal {
1034 | / macro_rules! impl_is_terminal {
1035 | |     ($($t:ty),*$(,)?) => {$(
1036 | |         #[unstable(feature = "sealed", issue = "none")]
1037 | |         impl crate::sealed::Sealed for $t {}
1043 | |                 crate::sys::io::is_terminal(self)
1043 | |                 crate::sys::io::is_terminal(self)
     | |                 --------------------------- ^^^^ the trait `owned::AsFd` is not implemented for `io::stdio::Stderr`
     | |                 required by a bound introduced by this call
...    |
1046 | |     )*}
1047 | | }
1047 | | }
     | |_- in this expansion of `impl_is_terminal!`
1048 |
1049 |   impl_is_terminal!(File, Stdin, StdinLock<'_>, Stdout, StdoutLock<'_>, Stderr, StderrLock<'_>);
     |
     |
     = help: the following other types implement trait `owned::AsFd`:
               &T
               Arc<T>
               Box<T>
               Socket
               WasiFd
               WasiFd
               fs::File
               owned::BorrowedFd<'_>
note: required by a bound in `is_terminal`
    --> library/std/src/sys/wasi/io.rs:77:30
     |
     |
77   | pub fn is_terminal(fd: &impl AsFd) -> bool {
     |                              ^^^^ required by this bound in `is_terminal`

error[E0277]: the trait bound `StderrLock<'_>: owned::AsFd` is not satisfied
     |
1034 | / macro_rules! impl_is_terminal {
1034 | / macro_rules! impl_is_terminal {
1035 | |     ($($t:ty),*$(,)?) => {$(
1036 | |         #[unstable(feature = "sealed", issue = "none")]
1037 | |         impl crate::sealed::Sealed for $t {}
1043 | |                 crate::sys::io::is_terminal(self)
1043 | |                 crate::sys::io::is_terminal(self)
     | |                 --------------------------- ^^^^ the trait `owned::AsFd` is not implemented for `StderrLock<'_>`
     | |                 required by a bound introduced by this call
...    |
1046 | |     )*}
1047 | | }
1047 | | }
     | |_- in this expansion of `impl_is_terminal!`
1048 |
1049 |   impl_is_terminal!(File, Stdin, StdinLock<'_>, Stdout, StdoutLock<'_>, Stderr, StderrLock<'_>);
     |
     |
     = help: the following other types implement trait `owned::AsFd`:
               &T
               Arc<T>
               Box<T>
               Socket
               WasiFd
               WasiFd
               fs::File
               owned::BorrowedFd<'_>
note: required by a bound in `is_terminal`
    --> library/std/src/sys/wasi/io.rs:77:30
     |
     |
77   | pub fn is_terminal(fd: &impl AsFd) -> bool {
     |                              ^^^^ required by this bound in `is_terminal`
For more information about this error, try `rustc --explain E0277`.
[RUSTC-TIMING] std test:false 2.345
warning: `std` (lib) generated 1 warning
error: could not compile `std` due to 6 previous errors; 1 warning emitted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants