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 #69182

Merged
merged 12 commits into from
Feb 15, 2020
Merged

Rollup of 6 pull requests #69182

merged 12 commits into from
Feb 15, 2020

Commits on Feb 4, 2020

  1. Added From<Vec<NonZeroU8>> for CString

    Updated tracking issue number
    
    Added safeguards for transmute_vec potentially being factored out elsewhere
    
    Clarified comment about avoiding mem::forget
    
    Removed unneeded unstable guard
    
    Added back a stability annotation for CI
    
    Minor documentation improvements
    
    Thanks to @Centril's code review
    
    Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
    
    Improved layout checks, type annotations and removed unaccurate comment
    
    Removed unnecessary check on array layout
    
    Adapt the stability annotation to the new 1.41 milestone
    
    Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
    
    Simplify the implementation.
    
    Use `Vec::into_raw_parts` instead of a manual implementation of
    `Vec::transmute`.
    
    If `Vec::into_raw_parts` uses `NonNull` instead, then the code here
    will need to be adjusted to take it into account (issue rust-lang#65816)
    
    Reduce the whitespace of safety comments
    danielhenrymantilla committed Feb 4, 2020
    Configuration menu
    Copy the full SHA
    60274a9 View commit details
    Browse the repository at this point in the history

Commits on Feb 12, 2020

  1. Fix std::fs::copy on WASI target

    Previously `std::fs::copy` on wasm32-wasi would reuse code from the `sys_common` module and would successfully copy contents of the file just to fail right before closing it.
    
    This was happening because `sys_common::copy` tries to copy permissions of the file, but permissions are not a thing in WASI (at least yet) and `set_permissions` is implemented as an unconditional runtime error.
    
    This change instead adds a custom working implementation of `std::fs::copy` (like Rust already has on some other targets) that doesn't try to call `set_permissions` and is essentially a thin wrapper around `std::io::copy`.
    
    Fixes rust-lang#68560.
    RReverser committed Feb 12, 2020
    Configuration menu
    Copy the full SHA
    8fb8bb4 View commit details
    Browse the repository at this point in the history

Commits on Feb 14, 2020

  1. Configuration menu
    Copy the full SHA
    be92200 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    47aa2b5 View commit details
    Browse the repository at this point in the history

Commits on Feb 15, 2020

  1. Configuration menu
    Copy the full SHA
    a8fe47d View commit details
    Browse the repository at this point in the history
  2. Suggest a comma if a struct initializer field fails to parse

    Currently, we emit a "try adding a comma" suggestion if a comma is
    missing in a struct definition. However, we emit no such suggestion if a
    comma is missing in a struct initializer.
    
    This commit adds a "try adding a comma" suggestion when we don't find a
    comma during the parsing of a struct initializer field.
    
    The change to `src/test/ui/parser/removed-syntax-with-1.stderr` isn't
    great, but I don't see a good way of avoiding it.
    Aaron1011 committed Feb 15, 2020
    Configuration menu
    Copy the full SHA
    98757f1 View commit details
    Browse the repository at this point in the history
  3. Rollup merge of rust-lang#64069 - danielhenrymantilla:feature/cstring…

    …_from_vec_of_nonzerou8, r=KodrAus
    
    Added From<Vec<NonZeroU8>> for CString
    
    Added a `From<Vec<NonZeroU8>>` `impl` for `CString`
    
    # Rationale
    
      - `CString::from_vec_unchecked` is a subtle function, that makes `unsafe` code harder to audit when the generated `Vec`'s creation is non-trivial. This `impl` allows to write safer `unsafe` code thanks to the very explicit semantics of the `Vec<NonZeroU8>` type.
    
      - One such situation is when trying to `.read()` a `CString`, see issue rust-lang#59229.
    
          - this lead to a PR: rust-lang#59314, that was closed for being too specific / narrow (it only targetted being able to `.read()` a `CString`, when this pattern could have been generalized).
    
         - the issue suggested another route, based on `From<Vec<NonZeroU8>>`, which is indeed a less general and more concise code pattern.
    
      - quoting @Shnatsel:
    
          - >  For me the main thing about making this safe is simplifying auditing - people have spent like an hour looking at just this one unsafe block in libflate because it's not clear what exactly is unchecked, so you have to look it up when auditing anyway. This has distracted us from much more serious memory safety issues the library had.
    Having this trivial impl in stdlib would turn this into safe code with compiler more or less guaranteeing that it's fine, and save anyone auditing the code a whole lot of time.
    Dylan-DPC authored Feb 15, 2020
    Configuration menu
    Copy the full SHA
    d28b358 View commit details
    Browse the repository at this point in the history
  4. Rollup merge of rust-lang#66721 - maxbla:exp-format-integers, r=KodrAus

    implement LowerExp and UpperExp for integers
    
    Addresses rust-lang#39479
    
    This implementation is heavily based on the preexisting `macro_rules! impl_Display` in the same file. I don't like the liberal use of unsafe in that macro and would like to modify it so `unsafe` is only present where necessary. What is Rust's policy on doing such modifications?
    
    Also, I couldn't figure out where to put tests, can I have some help with that?
    Dylan-DPC authored Feb 15, 2020
    Configuration menu
    Copy the full SHA
    afea30d View commit details
    Browse the repository at this point in the history
  5. Rollup merge of rust-lang#69106 - RReverser:wasi-fs-copy, r=KodrAus

    Fix std::fs::copy on WASI target
    
    Previously `std::fs::copy` on wasm32-wasi would reuse code from the `sys_common` module and would successfully copy contents of the file just to fail right before closing it.
    
    This was happening because `sys_common::copy` tries to copy permissions of the file, but permissions are not a thing in WASI (at least yet) and `set_permissions` is implemented as an unconditional runtime error.
    
    This change instead adds a custom working implementation of `std::fs::copy` (like Rust already has on some other targets) that doesn't try to call `set_permissions` and is essentially a thin wrapper around `std::io::copy`.
    
    Fixes rust-lang#68560.
    Dylan-DPC authored Feb 15, 2020
    Configuration menu
    Copy the full SHA
    728be34 View commit details
    Browse the repository at this point in the history
  6. Rollup merge of rust-lang#69154 - JohnTitor:fix-macro-ices, r=petroch…

    …enkov
    
    Avoid calling `fn_sig` on closures
    
    Fixes rust-lang#68060
    
    r? @petrochenkov
    Dylan-DPC authored Feb 15, 2020
    Configuration menu
    Copy the full SHA
    c115ad9 View commit details
    Browse the repository at this point in the history
  7. Rollup merge of rust-lang#69166 - JohnTitor:ice-const-enum, r=matthew…

    …jasper
    
    Check `has_typeck_tables` before calling `typeck_tables_of`
    
    Fixes rust-lang#68684
    
    r? @matthewjasper
    Dylan-DPC authored Feb 15, 2020
    Configuration menu
    Copy the full SHA
    09d6a65 View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#69180 - Aaron1011:feature/comma-struct-init…

    …, r=petrochenkov
    
    Suggest a comma if a struct initializer field fails to parse
    
    Currently, we emit a "try adding a comma" suggestion if a comma is
    missing in a struct definition. However, we emit no such suggestion if a
    comma is missing in a struct initializer.
    
    This commit adds a "try adding a comma" suggestion when we don't find a
    comma during the parsing of a struct initializer field.
    
    The change to `src/test/ui/parser/removed-syntax-with-1.stderr` isn't
    great, but I don't see a good way of avoiding it.
    Dylan-DPC authored Feb 15, 2020
    Configuration menu
    Copy the full SHA
    e9db061 View commit details
    Browse the repository at this point in the history