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

Closed
wants to merge 16 commits into from
Closed

Rollup of 6 pull requests #125755

wants to merge 16 commits into from

Commits on May 20, 2024

  1. Configuration menu
    Copy the full SHA
    20fd725 View commit details
    Browse the repository at this point in the history

Commits on May 29, 2024

  1. Configuration menu
    Copy the full SHA
    ceb45d5 View commit details
    Browse the repository at this point in the history
  2. Make body_owned_by return the body directly.

    Almost all callers want this anyway, and now we can use it to also return fed bodies
    oli-obk committed May 29, 2024
    Configuration menu
    Copy the full SHA
    a34c26e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d5bd4e2 View commit details
    Browse the repository at this point in the history
  4. Make std::env::{set_var, remove_var} unsafe in edition 2024

    Allow calling these functions without `unsafe` blocks in editions up
    until 2021, but don't trigger the `unused_unsafe` lint for `unsafe`
    blocks containing these functions.
    
    Fixes rust-lang#27970.
    Fixes rust-lang#90308.
    CC rust-lang#124866.
    tbu- committed May 29, 2024
    Configuration menu
    Copy the full SHA
    5d8f9b4 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    8cf4980 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    d7680e3 View commit details
    Browse the repository at this point in the history
  7. Add deprecated_safe lint

    It warns about usages of `std::env::{set_var, remove_var}` with an
    automatic fix wrapping the call in an `unsafe` block.
    tbu- committed May 29, 2024
    Configuration menu
    Copy the full SHA
    bbeccea View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    2f35cfd View commit details
    Browse the repository at this point in the history

Commits on May 30, 2024

  1. Configuration menu
    Copy the full SHA
    3104365 View commit details
    Browse the repository at this point in the history
  2. Rollup merge of rust-lang#124636 - tbu-:pr_env_unsafe, r=petrochenkov

    Make `std::env::{set_var, remove_var}` unsafe in edition 2024
    
    Allow calling these functions without `unsafe` blocks in editions up until 2021, but don't trigger the `unused_unsafe` lint for `unsafe` blocks containing these functions.
    
    Fixes rust-lang#27970.
    Fixes rust-lang#90308.
    CC rust-lang#124866.
    fmease authored May 30, 2024
    Configuration menu
    Copy the full SHA
    a736755 View commit details
    Browse the repository at this point in the history
  3. Rollup merge of rust-lang#125342 - tbu-:pr_doc_write, r=ChrisDenton

    Document platform-specifics for `Read` and `Write` of `File`
    fmease authored May 30, 2024
    Configuration menu
    Copy the full SHA
    8398ab8 View commit details
    Browse the repository at this point in the history
  4. Rollup merge of rust-lang#125671 - BoxyUwU:remove_const_ty_eq, r=comp…

    …iler-errors
    
    Do not equate `Const`'s ty in `super_combine_const`
    
    Fixes rust-lang#114456
    
    In rust-lang#125451 we started relating the `Const`'s tys outside of a probe so it was no longer simply an assertion to catch bugs.
    
    This was done so that when we _do_ provide a wrongly typed const argument to an item if we wind up relating it with some other instantiation we'll have a `TypeError` we can bubble up and taint the resulting mir allowing const eval to skip evaluation.
    
    In this PR I instead change `ConstArgHasType` to correctly handle checking the types of const inference variables. Previously if we had something like `impl<const N: u32> Trait for [(); N]`, when using the impl we would instantiate it with infer vars and then check that `?x: u32` is of type `u32` and succeed. Then later we would infer `?x` to some `Const` of type `usize`.
    
    We now stall on `?x` in `ConstArgHasType` until it has a concrete value that we can determine the type of. This allows us to fail using the erroneous implementation of `Trait` which allows us to taint the mir.
    
    Long term we intend to remove the `ty` field on `Const` so we would have no way of accessing the `ty` of a const inference variable anyway and would have to do this. I did not fully update `ConstArgHasType` to avoid using the `ty` field as it's not entirely possible right now- we would need to lookup `ConstArgHasType` candidates in the env.
    
    ---
    
    As for _why_ I think we should do this, relating the types of const's is not necessary for soundness of the type system. Originally this check started off as a plain `==` in `super_relate_consts` and gradually has been growing in complexity as we support more complicated types. It was never actually required to ensure that const arguments are correctly typed for their parameters however.
    
    The way we currently check that a const argument has the correct type is a little convoluted and confusing (and will hopefully be less weird as time goes on). Every const argument has an anon const with its return type set to type of the const parameter it is an argument to. When type checking the anon const regular type checking rules require that the expression is the same type as the return type. This effectively ensure that no matter what every const argument _always_ has the correct type.
    
    An extra bit of complexity is that during `hir_ty_lowering` we do not represent everything as a `ConstKind::Unevaluated` corresponding to the anon const. For generic parameters i.e. `[(); N]` we simply represent them as `ConstKind::Param` as we do not want `ConstKind::Unevaluated` with generic substs on stable under min const generics. The anon const still gets type checked resulting in errors about type mismatches.
    
    Eventually we intend to not create anon consts for all const arguments (for example for `ConstKind::Param`) and instead check that the argument type is correct via `ConstArgHasType` obligations (these effectively also act as a check that the anon consts have the correctly set return type).
    
    What this all means is that the the only time we should ever have mismatched types when relating two `Const`s is if we have messed up our logic for ensuring that const arguments are of the correct type. Having this not be an assert is:
    - Confusing as it may incorrectly lead people to believe this is an important check that is actually required
    - Opens the possibility for bugs or behaviour reliant on this (unnecessary) check existing
    
    ---
    
    This PR makes two tests go from pass->ICE (`generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.rs` and `tests/crashes/121858.rs`). This is caused by the fact that we evaluate anon consts even if their where clauses do not hold and is a pre-existing issue and only affects `generic_const_exprs`. I am comfortable exposing the brokenness of `generic_const_exprs` more with this PR
    
    This PR makes a test go from ICE->pass (`const-generics/issues/issue-105821.rs`). I have no idea why this PR affects that but I believe that ICE is an unrelated issue to do with the fact that under `generic_const_exprs`/`adt_const_params` we do not handle lifetimes in const parameter types correctly. This PR is likely just masking this bug.
    
    Note: this PR doesn't re-introduce the assertion that the two consts' tys are equal. I'm not really sure how I feel about this but tbh it has caused more ICEs than its found lately so 🤷‍♀️
    
    r? `@oli-obk` `@compiler-errors`
    fmease authored May 30, 2024
    Configuration menu
    Copy the full SHA
    948faa2 View commit details
    Browse the repository at this point in the history
  5. Rollup merge of rust-lang#125711 - oli-obk:const_block_ice2, r=Nadrieril

    Make `body_owned_by` return the `Body` instead of just the `BodyId`
    
    fixes rust-lang#125677
    
    Almost all `body_owned_by` callers immediately called `body`, too, so just return `Body` directly.
    
    This makes the inline-const query feeding more robust, as all calls to `body_owned_by` will now yield a body for inline consts, too.
    
    I have not yet figured out a good way to make `tcx.hir().body()` return an inline-const body, but that can be done as a follow-up
    fmease authored May 30, 2024
    Configuration menu
    Copy the full SHA
    b5f88f3 View commit details
    Browse the repository at this point in the history
  6. Rollup merge of rust-lang#125745 - tgross35:bump-stage0, r=Mark-Simul…

    …acrum
    
    Bump the stage0 compiler to beta.7 (2024-05-26)
    
    As mentioned at rust-lang#125016 (comment)
    fmease authored May 30, 2024
    Configuration menu
    Copy the full SHA
    3469e42 View commit details
    Browse the repository at this point in the history
  7. Rollup merge of rust-lang#125753 - Zalathar:procres, r=jieyouxu

    compiletest: Unify `cmd2procres` with `run_command_to_procres`
    
    Historical context: I originally added `run_command_to_procres` in rust-lang#112300 and rust-lang#114843, because I didn't like the overly-specific failure message in `cmd2procres`, but at the time I didn't feel confident enough to change the existing code, so I just added my own similar code.
    
    Now I'm going back to remove this redundancy by eliminating `cmd2procress`, and adjusting all callers to use a slightly-tweaked `run_command_to_procres` instead.
    fmease authored May 30, 2024
    Configuration menu
    Copy the full SHA
    cf66e64 View commit details
    Browse the repository at this point in the history