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

Rustup #13639

Merged
merged 53 commits into from
Nov 7, 2024
Merged

Rustup #13639

merged 53 commits into from
Nov 7, 2024

Commits on Oct 8, 2024

  1. Stabilize isqrt feature

    ChaiTRex committed Oct 8, 2024
    Configuration menu
    Copy the full SHA
    b95aa31 View commit details
    Browse the repository at this point in the history

Commits on Oct 18, 2024

  1. Configuration menu
    Copy the full SHA
    fea5e77 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    91a458f View commit details
    Browse the repository at this point in the history

Commits on Oct 19, 2024

  1. Do not run lints that cannot emit

    Before this change, adding a lint was a difficult matter
    because it always had some overhead involved. This was
    because all lints would run, no matter their default level,
    or if the user had #![allow]ed them. This PR changes that
    blyxyas committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    6983631 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8f8aa46 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e427a4e View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e518d66 View commit details
    Browse the repository at this point in the history
  5. Fix tests

    compiler-errors committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    69b0886 View commit details
    Browse the repository at this point in the history

Commits on Oct 20, 2024

  1. Configuration menu
    Copy the full SHA
    aab0eee View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d8b2f93 View commit details
    Browse the repository at this point in the history

Commits on Oct 21, 2024

  1. Auto merge of #131988 - matthiaskrgr:rollup-tx173wn, r=matthiaskrgr

    Rollup of 4 pull requests
    
    Successful merges:
    
     - #126588 (Added more scenarios where comma to be removed in the function arg)
     - #131728 (bootstrap: extract builder cargo to its own module)
     - #131968 (Rip out old effects var handling code from traits)
     - #131981 (Remove the `BoundConstness::NotConst` variant)
    
    r? `@ghost`
    `@rustbot` modify labels: rollup
    bors committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    1d0dad5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3773534 View commit details
    Browse the repository at this point in the history

Commits on Oct 22, 2024

  1. Auto merge of #129935 - RalfJung:unsupported_calling_conventions, r=c…

    …ompiler-errors
    
    make unsupported_calling_conventions a hard error
    
    This has been a future-compat lint (not shown in dependencies) since Rust 1.55, released 3 years ago. Hopefully that was enough time so this can be made a hard error now. Given that long timeframe, I think it's justified to skip the "show in dependencies" stage. There were [not many crates hitting this](rust-lang/rust#86231 (comment)) even when the lint was originally added.
    
    This should get cratered, and I assume then it needs a t-compiler FCP. (t-compiler because this looks entirely like an implementation oversight -- for the vast majority of ABIs, we already have a hard error, but some were initially missed, and we are finally fixing that.)
    
    Fixes rust-lang/rust#87678
    bors committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    f03f7c6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2fd8222 View commit details
    Browse the repository at this point in the history
  3. Auto merge of #131321 - RalfJung:feature-activation, r=nnethercote

    terminology: #[feature] *enables* a feature (instead of "declaring" or "activating" it)
    
    Mostly, we currently call a feature that has a corresponding `#[feature(name)]` attribute in the current crate a "declared" feature. I think that is confusing as it does not align with what "declaring" usually means. Furthermore, we *also* refer to `#[stable]`/`#[unstable]` as *declaring* a feature (e.g. in [these diagnostics](https://github.com/rust-lang/rust/blob/f25e5abea229a6b6aa77b45e21cb784e785c6040/compiler/rustc_passes/messages.ftl#L297-L301)), which aligns better with what "declaring" usually means. To make things worse, the functions  `tcx.features().active(...)` and  `tcx.features().declared(...)` both exist and they are doing almost the same thing (testing whether a corresponding `#[feature(name)]`  exists) except that `active` would ICE if the feature is not an unstable lang feature. On top of this, the callback when a feature is activated/declared is called `set_enabled`, and many comments also talk about "enabling" a feature.
    
    So really, our terminology is just a mess.
    
    I would suggest we use "declaring a feature" for saying that something is/was guarded by a feature (e.g. `#[stable]`/`#[unstable]`), and "enabling a feature" for  `#[feature(name)]`. This PR implements that.
    bors committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    78fc7bb View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    088f07a View commit details
    Browse the repository at this point in the history

Commits on Oct 23, 2024

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

Commits on Oct 24, 2024

  1. Configuration menu
    Copy the full SHA
    eb6026a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5d681cf View commit details
    Browse the repository at this point in the history

Commits on Oct 25, 2024

  1. Rollup merge of #132106 - maxcabrajac:ident_ref, r=petrochenkov

    Pass Ident by reference in ast Visitor
    
    `MutVisitor`'s version of `visit_ident` passes around `&Ident`, but `Visitor` copies `Ident`. This PR changes that
    
    r? `@petrochenkov`
    
    related to #128974
    matthiaskrgr authored Oct 25, 2024
    Configuration menu
    Copy the full SHA
    a1ff955 View commit details
    Browse the repository at this point in the history
  2. tcx.is_const_fn doesn't work the way it is described, remove it

    Then we can rename the _raw functions to drop their suffix, and instead
    explicitly use is_stable_const_fn for the few cases where that is really what
    you want.
    RalfJung committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    cd21594 View commit details
    Browse the repository at this point in the history
  3. Auto merge of #131349 - RalfJung:const-stability-checks, r=compiler-e…

    …rrors
    
    Const stability checks v2
    
    The const stability system has served us well ever since `const fn` were first stabilized. It's main feature is that it enforces *recursive* validity -- a stable const fn cannot internally make use of unstable const features without an explicit marker in the form of `#[rustc_allow_const_fn_unstable]`. This is done to make sure that we don't accidentally expose unstable const features on stable in a way that would be hard to take back. As part of this, it is enforced that a `#[rustc_const_stable]` can only call `#[rustc_const_stable]` functions. However, some problems have been coming up with increased usage:
    - It is baffling that we have to mark private or even unstable functions as `#[rustc_const_stable]` when they are used as helpers in regular stable `const fn`, and often people will rather add `#[rustc_allow_const_fn_unstable]` instead which was not our intention.
    - The system has several gaping holes: a private `const fn` without stability attributes whose inherited stability (walking up parent modules) is `#[stable]` is allowed to call *arbitrary* unstable const operations, but can itself be called from stable `const fn`. Similarly, `#[allow_internal_unstable]` on a macro completely bypasses the recursive nature of the check.
    
    Fundamentally, the problem is that we have *three* disjoint categories of functions, and not enough attributes to distinguish them:
    1. const-stable functions
    2. private/unstable functions that are meant to be callable from const-stable functions
    3. functions that can make use of unstable const features
    
    Functions in the first two categories cannot use unstable const features and they can only call functions from the first two categories.
    
    This PR implements the following system:
    - `#[rustc_const_stable]` puts functions in the first category. It may only be applied to `#[stable]` functions.
    - `#[rustc_const_unstable]` by default puts functions in the third category. The new attribute `#[rustc_const_stable_indirect]` can be added to such a function to move it into the second category.
    - `const fn` without a const stability marker are in the second category if they are still unstable. They automatically inherit the feature gate for regular calls, it can now also be used for const-calls.
    
    Also, all the holes mentioned above have been closed. There's still one potential hole that is hard to avoid, which is when MIR building automatically inserts calls to a particular function in stable functions -- which happens in the panic machinery. Those need to be manually marked `#[rustc_const_stable_indirect]` to be sure they follow recursive const stability. But that's a fairly rare and special case so IMO it's fine.
    
    The net effect of this is that a `#[unstable]` or unmarked function can be constified simply by marking it as `const fn`, and it will then be const-callable from stable `const fn` and subject to recursive const stability requirements. If it is publicly reachable (which implies it cannot be unmarked), it will be const-unstable under the same feature gate. Only if the function ever becomes `#[stable]` does it need a `#[rustc_const_unstable]` or `#[rustc_const_stable]` marker to decide if this should also imply const-stability.
    
    Adding `#[rustc_const_unstable]` is only needed for (a) functions that need to use unstable const lang features (including intrinsics), or (b) `#[stable]` functions that are not yet intended to be const-stable. Adding `#[rustc_const_stable]` is only needed for functions that are actually meant to be directly callable from stable const code. `#[rustc_const_stable_indirect]` is used to mark intrinsics as const-callable and for `#[rustc_const_unstable]` functions that are actually called from other, exposed-on-stable `const fn`. No other attributes are required.
    
    Also see the updated dev-guide at rust-lang/rustc-dev-guide#2098.
    
    I think in the future we may want to tweak this further, so that in the hopefully common case where a public function's const-stability just exactly mirrors its regular stability, we never have to add any attribute. But right now, once the function is stable this requires `#[rustc_const_stable]`.
    
    ### Open question
    
    There is one point I could see we might want to do differently, and that is putting `#[rustc_const_unstable]`  functions (but not intrinsics) in category 2 by default, and requiring an extra attribute for `#[rustc_const_not_exposed_on_stable]` or so. This would require a bunch of extra annotations, but would have the advantage that turning a `#[rustc_const_unstable]` into `#[rustc_const_stable]`  will never change the way the function is const-checked. Currently, we often discover in the const stabilization PR that a function needs some other unstable const things, and then we rush to quickly deal with that. In this alternative universe, we'd work towards getting rid of the `rustc_const_not_exposed_on_stable` before stabilization, and once that is done stabilization becomes a trivial matter. `#[rustc_const_stable_indirect]` would then only be used for intrinsics.
    
    I think I like this idea, but might want to do it in a follow-up PR, as it will need a whole bunch of annotations in the standard library. Also, we probably want to convert all const intrinsics to the "new" form (`#[rustc_intrinsic]` instead of an `extern` block) before doing this to avoid having to deal with two different ways of declaring intrinsics.
    
    Cc `@rust-lang/wg-const-eval` `@rust-lang/libs-api`
    Part of rust-lang/rust#129815 (but not finished since this is not yet sufficient to safely let us expose `const fn` from hashbrown)
    Fixes rust-lang/rust#131073 by making it so that const-stable functions are always stable
    
    try-job: test-various
    bors committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    8b9376a View commit details
    Browse the repository at this point in the history

Commits on Oct 26, 2024

  1. Effects cleanup

    - removed extra bits from predicates queries that are no longer needed in the new system
    - removed the need for `non_erasable_generics` to take in tcx and DefId, removed unused arguments in callers
    fee1-dead committed Oct 26, 2024
    Configuration menu
    Copy the full SHA
    350d1c4 View commit details
    Browse the repository at this point in the history
  2. Rollup merge of #132168 - fee1-dead-contrib:fxclean, r=compiler-errors

    Effects cleanup
    
    - removed extra bits from predicates queries that are no longer needed in the new system
    - removed the need for `non_erasable_generics` to take in tcx and DefId, removed unused arguments in callers
    
    r? compiler-errors
    matthiaskrgr authored Oct 26, 2024
    Configuration menu
    Copy the full SHA
    b75d511 View commit details
    Browse the repository at this point in the history
  3. Auto merge of #125116 - blyxyas:ignore-allowed-lints-final, r=cjgillot

    (Big performance change) Do not run lints that cannot emit
    
    Before this change, adding a lint was a difficult matter because it always had some overhead involved. This was because all lints would run, no matter their default level, or if the user had `#![allow]`ed them. This PR changes that. This change would improve both the Rust lint infrastructure and Clippy, but Clippy will see the most benefit, as it has about 900 registered lints (and growing!)
    
    So yeah, with this little patch we filter all lints pre-linting, and remove any lint that is either:
    - Manually `#![allow]`ed in the whole crate,
    - Allowed in the command line, or
    - Not manually enabled with `#[warn]` or similar, and its default level is `Allow`
    
    As some lints **need** to run, this PR also adds **loadbearing lints**. On a lint declaration, you can use the ``@eval_always` = true` marker to label it as loadbearing. A loadbearing lint will never be filtered (it will always run)
    
    Fixes #106983
    bors committed Oct 26, 2024
    Configuration menu
    Copy the full SHA
    9e36f89 View commit details
    Browse the repository at this point in the history

Commits on Oct 28, 2024

  1. Rollup merge of #131391 - ChaiTRex:isqrt, r=scottmcm,tgross35

    Stabilize `isqrt` feature
    
    Stabilizes the `isqrt` feature. FCP is incomplete.
    
    Closes #116226
    matthiaskrgr authored Oct 28, 2024
    Configuration menu
    Copy the full SHA
    303ab51 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f286174 View commit details
    Browse the repository at this point in the history

Commits on Oct 29, 2024

  1. Auto merge of #128985 - GrigorenkoPV:instantly-dangling-pointer, r=Urgau

    Lint against getting pointers from immediately dropped temporaries
    
    Fixes #123613
    
    ## Changes:
    1. New lint: `dangling_pointers_from_temporaries`. Is a generalization of `temporary_cstring_as_ptr` for more types and more ways to get a temporary.
    2. `temporary_cstring_as_ptr` is removed and marked as renamed to `dangling_pointers_from_temporaries`.
    3. `clippy::temporary_cstring_as_ptr` is marked as renamed to `dangling_pointers_from_temporaries`.
    4. Fixed a false positive[^fp] for when the pointer is not actually dangling because of lifetime extension for function/method call arguments.
    5. `core::cell::Cell` is now `rustc_diagnostic_item = "Cell"`
    
    ## Questions:
    - [ ]  Instead of manually checking for a list of known methods and diagnostic items, maybe add some sort of annotation to those methods in library and check for the presence of that annotation? rust-lang/rust#128985 (comment)
    
    ## Known limitations:
    
    ### False negatives[^fn]:
    
    See the comments in `compiler/rustc_lint/src/dangling.rs`
    
    1. Method calls that are not checked for:
       - `temporary_unsafe_cell.get()`
       - `temporary_sync_unsafe_cell.get()`
    2. Ways to get a temporary that are not recognized:
       - `owning_temporary.field`
       - `owning_temporary[index]`
    3. No checks for ref-to-ptr conversions:
       - `&raw [mut] temporary`
       - `&temporary as *(const|mut) _`
        - `ptr::from_ref(&temporary)` and friends
    
    [^fn]: lint **should** be emitted, but **is not**
    
    [^fp]: lint **should not** be emitted, but **is**
    bors committed Oct 29, 2024
    Configuration menu
    Copy the full SHA
    149665a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    353868a View commit details
    Browse the repository at this point in the history
  3. update tools

    lcnr committed Oct 29, 2024
    Configuration menu
    Copy the full SHA
    8d190cc View commit details
    Browse the repository at this point in the history
  4. Remove Analysis::into_engine.

    This is a standard pattern:
    ```
    MyAnalysis.into_engine(tcx, body).iterate_to_fixpoint()
    ```
    `into_engine` and `iterate_to_fixpoint` are always called in pairs, but
    sometimes with a builder-style `pass_name` call between them. But a
    builder-style interface is overkill here. This has been bugging me a for
    a while.
    
    This commit:
    - Merges `Engine::new` and `Engine::iterate_to_fixpoint`. This removes
      the need for `Engine` to have fields, leaving it as a trivial type
      that the next commit will remove.
    - Renames `Analysis::into_engine` as `Analysis::iterate_to_fixpoint`,
      gives it an extra argument for the optional pass name, and makes it
      call `Engine::iterate_to_fixpoint` instead of `Engine::new`.
    
    This turns the pattern from above into this:
    ```
    MyAnalysis.iterate_to_fixpoint(tcx, body, None)
    ```
    which is shorter at every call site, and there's less plumbing required
    to support it.
    nnethercote committed Oct 29, 2024
    Configuration menu
    Copy the full SHA
    ae82c75 View commit details
    Browse the repository at this point in the history

Commits on Oct 30, 2024

  1. Rollup merge of #132338 - nnethercote:rm-Engine, r=nnethercote

    Remove `Engine`
    
    It's just unnecessary plumbing. Removing it results in less code, and simpler code.
    
    r? ``@cjgillot``
    matthiaskrgr authored Oct 30, 2024
    Configuration menu
    Copy the full SHA
    297f28c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d9a0fec View commit details
    Browse the repository at this point in the history

Commits on Oct 31, 2024

  1. Auto merge of #132301 - compiler-errors:adjust, r=lcnr

    Remove region from adjustments
    
    It's not necessary to store this region, because it's only used in THIR and MemCat/ExprUse, both of which already basically only deal with erased regions anyways.
    bors committed Oct 31, 2024
    Configuration menu
    Copy the full SHA
    9f89421 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d30a0b2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    bad3edd View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    d7850ec View commit details
    Browse the repository at this point in the history

Commits on Nov 1, 2024

  1. Rollup merge of #132403 - lcnr:typing-mode, r=compiler-errors

    continue `TypingMode` refactor
    
    There are still quite a few places which (indirectly) rely on the `Reveal` of a `ParamEnv`, but we're slowly getting there
    
    r? `@compiler-errors`
    workingjubilee authored Nov 1, 2024
    Configuration menu
    Copy the full SHA
    c2db7fa View commit details
    Browse the repository at this point in the history

Commits on Nov 3, 2024

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

Commits on Nov 4, 2024

  1. Configuration menu
    Copy the full SHA
    b14362f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    efeed55 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    63d0ba9 View commit details
    Browse the repository at this point in the history

Commits on Nov 5, 2024

  1. Auto merge of #132580 - compiler-errors:globs, r=Noratrieb

    Remove unnecessary pub enum glob-imports from `rustc_middle::ty`
    
    We used to have an idiom in the compiler where we'd prefix or suffix all the variants of an enum, for example `BoundRegionKind`, with something like `Br`, and then *glob-import* that enum variant directly.
    
    `@noratrieb` brought this up, and I think that it's easier to read when we just use the normal style `EnumName::Variant`.
    
    This PR is a bit large, but it's just naming.
    
    The only somewhat opinionated change that this PR does is rename `BorrowKind::Imm` to `BorrowKind::Immutable` and same for the other variants. I think these enums are used sparingly enough that the extra length is fine.
    
    r? `@noratrieb` or reassign
    bors committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    d8a3fcc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    626406f View commit details
    Browse the repository at this point in the history
  3. Rollup merge of #132637 - blyxyas:lint-less-passes, r=flip1995

    Do not filter empty lint passes & re-do CTFE pass
    
    Some structs implement `LintPass` without having a `Lint` associated with them #125116 broke that behaviour by filtering them out. This PR ensures that lintless passes are not filtered out.
    matthiaskrgr authored Nov 5, 2024
    Configuration menu
    Copy the full SHA
    4847c40 View commit details
    Browse the repository at this point in the history

Commits on Nov 7, 2024

  1. Configuration menu
    Copy the full SHA
    b816d4e View commit details
    Browse the repository at this point in the history
  2. Fix author lint and move it back to tests/ui

    The author lint is not an internal lint, and should also be enabled, when Clippy
    is distributed through rustup. This moves the author lint test cases back to
    tests/ui.
    flip1995 committed Nov 7, 2024
    Configuration menu
    Copy the full SHA
    03daf7c View commit details
    Browse the repository at this point in the history
  3. Clean up declare_clippy_lint

    The new @eval_always option should always follow after a comma for consistency
    with the declare_tool_lint macro.
    
    Rename $catergory->$level.
    flip1995 committed Nov 7, 2024
    Configuration menu
    Copy the full SHA
    4f12b98 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    c64f1e3 View commit details
    Browse the repository at this point in the history
  5. Fix cargo dev update_lints

    Now that lints can add @eval_always at the end of their definition, the lint
    declaration might not end right after the description. The `update_lints`
    command can skip everything that comes after that.
    flip1995 committed Nov 7, 2024
    Configuration menu
    Copy the full SHA
    b27570b View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    a5d6100 View commit details
    Browse the repository at this point in the history
  7. Remove ui/no_lints.rs test

    This test was only meant for debugging purposes
    flip1995 committed Nov 7, 2024
    Configuration menu
    Copy the full SHA
    d583df0 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    b116696 View commit details
    Browse the repository at this point in the history