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

pretty.rs: Update Closure and Generator print #22

Closed
wants to merge 1,128 commits into from
Closed

Conversation

arora-aman
Copy link
Member

@arora-aman arora-aman commented Sep 11, 2020

Proposal is here: rust-lang/project-rfc-2229#17


This change is Reviewable

Copy link

@ChrisPardy ChrisPardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. So are generators full or semi coroutines?

@arora-aman
Copy link
Member Author

arora-aman commented Sep 22, 2020

Looks good. So are generators full or semi coroutines?

I'm assuming when they get to being feature complete it will be full generators. Also not sure what semi-generators would be? Like no stack/basic state?

@ChrisPardy
Copy link

I'm assuming when they get to being feature complete it will be full generators. Also not sure what semi-generators would be? Like no stack/basic state?

Idk, my question was more of a cs 343 throwback than anything else lol. IIRC, semicoroutines couldn't be part of a resume cycle, or something like that

Copy link

@Azhng Azhng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 45 files reviewed, 2 unresolved discussions (waiting on @arora-aman, @Azhng, @jenniferwills, and @roxelo)


compiler/rustc_middle/src/ty/print/pretty.rs, line 692 at r1 (raw file):

                    if let Some(did) = did.as_local() {
                        let hir_id = self.tcx().hir().local_def_id_to_hir_id(did);
                        if self.tcx().sess.opts.debugging_opts.span_free_formats {

What is the span_free_formats ? 🤔🤔🤔


compiler/rustc_middle/src/ty/print/pretty.rs, line 725 at r1 (raw file):

                    }
                }
                p!(write("]"));

Intentional ?

Copy link

@Azhng Azhng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified OOB. LGTM

Reviewable status: 0 of 45 files reviewed, 2 unresolved discussions (waiting on @arora-aman, @jenniferwills, and @roxelo)

Copy link

@jenniferwills jenniferwills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@arora-aman
Copy link
Member Author

rust-lang#77069

Dylan-DPC and others added 14 commits September 23, 2020 14:54
Record `tcx.def_span` instead of `item.span` in crate metadata

This was missed in PR rust-lang#75465. As a result, a few places have been using
the full body span of functions, instead of just the header span.
emit errors during AbstractConst building

There changes are currently still untested, so I don't expect this to pass CI 😆

It seems to me like this is the direction we want to go in, though we didn't have too much of a discussion about this.

r? @oli-obk
…-from-mut, r=Amanieu

Add cfg(target_has_atomic_equal_alignment) and use it for Atomic::from_mut.

Fixes some platform-specific problems with rust-lang#74532 by using the actual alignment of the types instead of hardcoding a few `target_arch`s.

r? @RalfJung
Changing the alloc() to accept &self instead of &mut self

Fixes: [#55](rust-lang/wg-allocators#55)

This is the first cut. It only makes the change for `alloc` method.
fix small typo in docs and comments

Fixed `the the` to `the`, as far as I found.
…-iter, r=Dylan-DPC

Add missing examples on Vec iter types

r? @Dylan-DPC
Improve documentation for ToSocketAddrs

I little clarification
Miri: more informative deallocation error messages

Make sure we show the affected AllocId.

r? @oli-obk
…ulacrum

Add #[track_caller] to more panicking Cell functions

Continuation of rust-lang#74526

Adds the #[track_caller] attribute to almost all panicking Cell
functions. The ones that borrow two Cells in their function
body are spared, because the panic location helps pinpoint
which of the two borrows failed. You'd need to have
full debuginfo and backtraces enabled together with column
info in order to be able to discern the cases.
Column info in debuginfo is only available on non-Windows platforms.
…tions-cint, r=dtolnay

Revert "Function to convert OpenOptions to c_int"

Reverts rust-lang#76110. This broke Rust's stability guarantees.

Closes rust-lang#77089.

r? `@joshtriplett`
jyn514 and others added 27 commits September 27, 2020 00:10
This mis-highlighted the entire documentation as code.
…r=dtolnay

Remove std::io::lazy::Lazy in favour of SyncOnceCell

The (internal) std::io::lazy::Lazy was used to lazily initialize the stdout and stdin buffers (and mutexes). It uses atexit() to register a destructor to flush the streams on exit, and mark the streams as 'closed'. Using the stream afterwards would result in a panic.

Stdout uses a LineWriter which contains a BufWriter that will flush the buffer on drop. This one is important to be executed during shutdown, to make sure no buffered output is lost. It also forbids access to stdout afterwards, since the buffer is already flushed and gone.

Stdin uses a BufReader, which does not implement Drop. It simply forgets any previously read data that was not read from the buffer yet. This means that in the case of stdin, the atexit() function's only effect is making stdin inaccessible to the program, such that later accesses result in a panic. This is uncessary, as it'd have been safe to access stdin during shutdown of the program.

---

This change removes the entire io::lazy module in favour of SyncOnceCell. SyncOnceCell's fast path is much faster (a single atomic operation) than locking a sys_common::Mutex on every access like Lazy did.

However, SyncOnceCell does not use atexit() to drop the contained object during shutdown.

As noted above, this is not a problem for stdin. It simply means stdin is now usable during shutdown.

The atexit() call for stdout is moved to the stdio module. Unlike the now-removed Lazy struct, SyncOnceCell does not have a 'gone and unusable' state that panics. Instead of adding this again, this simply replaces the buffer with one with zero capacity. This effectively flushes the old buffer *and* makes any writes afterwards pass through directly without touching a buffer, making print!() available during shutdown without panicking.

---

In addition, because the contents of the SyncOnceCell are no longer dropped, we can now use `&'static` instead of `Arc` in `Stdout` and `Stdin`. This also saves two levels of indirection in `stdin()` and `stdout()`, since Lazy effectively stored a `Box<Arc<T>>`, and SyncOnceCell stores the `T` directly.
Refactor and fix intra-doc link diagnostics, and fix links to primitives

Closes rust-lang#76925, closes rust-lang#76693, closes rust-lang#76692.

Originally I only meant to fix rust-lang#76925. But the hack with `has_primitive` was so bad it was easier to fix the primitive issues than to try and work around it.

Note that this still has one bug: `std::primitive::i32::MAX` does not resolve. However, this fixes the ICE so I'm fine with fixing the link in a later PR.

This is part of a series of refactors to make rust-lang#76467 possible.

This is best reviewed commit-by-commit; it has detailed commit messages.

r? `@euclio`
…petrochenkov

might_permit_raw_init: also check aggregate fields

This is the next step for rust-lang#66151: when doing `mem::zeroed`/`mem::uninitialized`, also recursively check fields of aggregates (except for arrays) for whether they permit zero/uninit initialization.
…, r=varkor

 Stability annotations on generic parameters (take 2.5)

Rebase of rust-lang#72314 + more tests

Implements rust-lang/wg-allocators#2.
…separate lints

This is not ideal because it means `deny(broken_intra_doc_links)` will
no longer `deny(private_intra_doc_links)`. However, it can't be fixed
with a new lint group, because `broken` is already in the `rustdoc` lint
group; there would need to be a way to nest groups somehow.

This also removes the early `return` so that the link will be generated
even though it gives a warning.
update stdarch submodule

This commit update the src/stdarch submodule, we primarily want to include [https://github.com/rust-lang/stdarch/pull/918](url) which provides prefetch hints for aarch64. This PR could deliver ~20% performance gain on our aarch64 server in Filecoin. Wish this could be used as soon as possible.

Thanks.
Add asm! support for MIPS

For now, I only add support for mips32.
mips64 may come in future PRs if I could learn more about the target.
…-checks, r=oli-obk

Check for missing const-stability attributes in `rustc_passes`

Currently, this happens as a side effect of `is_min_const_fn`, which is non-obvious. Also adds a test for this case, since we didn't seem to have one before.
Separate `private_intra_doc_links` and `broken_intra_doc_links` into separate lints

This is not ideal because it means `deny(broken_intra_doc_links)` will
no longer `deny(private_intra_doc_links)`. However, it can't be fixed
with a new lint group, because `broken` is already in the `rustdoc` lint
group; there would need to be a way to nest groups somehow.

This also removes the early `return` so that the link will be generated
even though it gives a warning.

r? @Manishearth
cc @ecstatic-morse (rust-lang#77242 (comment))
…as-schievink

Rollup of 7 pull requests

Successful merges:

 - rust-lang#76839 (Add asm! support for MIPS)
 - rust-lang#77203 (Check for missing const-stability attributes in `rustc_passes`)
 - rust-lang#77249 (Separate `private_intra_doc_links` and `broken_intra_doc_links` into separate lints)
 - rust-lang#77252 (reduce overlong line)
 - rust-lang#77256 (Fix typo in ExpnData documentation)
 - rust-lang#77262 (Remove duplicate comment)
 - rust-lang#77263 (Clean up trivial if let)

Failed merges:

r? `@ghost`
Small improvements in liveness pass

* Remove redundant debug logging (`add_variable` already contains logging).
* Remove redundant fields for a number of live nodes and variables.
* Delay conversion from a symbol to a string until linting.
* Inline contents of specials struct.
* Remove unnecessary local variable exit_ln.
* Use newtype_index for Variable and LiveNode.
* Access live nodes directly through self.lnks[ln].

No functional changes intended (except those related to the logging).
The syscalls returning a new file descriptors generally use
lowest-numbered file descriptor not currently opened, without any
exceptions for those corresponding to the standard streams.

Previously when any of standard streams has been closed before starting
the application, operations on std::io::{stderr,stdin,stdout} objects
were likely to operate on other logically unrelated file resources
opened afterwards.

Avoid the issue by reopening the standard streams when they are closed.
…=jonas-schievink

Replace `discriminant_switch_effect` with more general version

rust-lang#68528 added a new edge-specific effect for `SwitchInt` terminators, `discriminant_switch_effect`, to the dataflow framework. While this accomplished the short-term goal of making drop elaboration more precise, it wasn't really useful in other contexts: It only supported `SwitchInt`s on the discriminant of an `enum` and did not allow effects to be applied along the "otherwise" branch. In const-propagation, for example, arbitrary edge-specific effects for the targets of a `SwitchInt` can be used to remember the value a `match` scrutinee must have in each arm.

This PR replaces `discriminant_switch_effect` with a more general `switch_int_edge_effects` method. The new method has a slightly different interface from the other edge-specific effect methods (e.g. `call_return_effect`). This divergence is explained in the new method's documentation, and reading the changes to the various dataflow impls as well as `direction.rs` should further clarify things. This PR should not change behavior.
Reopen standard file descriptors when they are missing on Unix

The syscalls returning a new file descriptors generally return lowest-numbered
file descriptor not currently opened, without any exceptions for those
corresponding to stdin, sdout, or stderr.

Previously when any of standard file descriptors has been closed before starting
the application, operations on std::io::{stderr,stdin,stdout} were likely to
either succeed while being performed on unrelated file descriptor, or fail with
EBADF which is silently ignored.

Avoid the issue by using /dev/null as a replacement when the standard file
descriptors are missing.

The implementation is based on the one found in musl. It was selected among a
few others on the basis of the lowest overhead in the case when all descriptors
are already present (measured on GNU/Linux).

Closes rust-lang#57728.
Closes rust-lang#46981.
Closes rust-lang#60447.

Benefits:
* Makes applications robust in the absence of standard file descriptors.
* Upholds IntoRawFd / FromRawFd safety contract (which was broken previously).

Drawbacks:
* Additional syscall during startup.
* The standard descriptors might have been closed intentionally.
* Requires /dev/null.

Alternatives:
* Check if stdin, stdout, stderr are opened and provide no-op substitutes in std::io::{stdin,stdout,stderr} without reopening them directly.
* Leave the status quo, expect robust applications to reopen them manually.
Co-authored-by: Dhruv Jauhar <dhruvjhr@gmail.com>
Co-authored-by: Logan Mosier <logmosier@gmail.com>
Co-authored-by: Dhruv Jauhar <dhruvjhr@gmail.com>
Co-authored-by: Logan Mosier <logmosier@gmail.com>
@arora-aman arora-aman closed this Sep 30, 2020
@arora-aman arora-aman deleted the closure_print_2 branch September 30, 2020 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.