Repository navigation
remove MutTy - #163327
remove MutTy#163327
MutTy#163327Conversation
|
The parser was modified, potentially altering the grammar of (stable) Rust cc @fmease Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt
cc @rust-lang/clippy
cc @rust-lang/rustfmt Some changes occurred in compiler/rustc_builtin_macros/src/autodiff.rs cc @ZuseZ4 HIR ty lowering was modified cc @fmease Some changes occurred in compiler/rustc_ast/src/expand/autodiff_attrs.rs cc @ZuseZ4 |
|
r? @mejrs rustbot has assigned @mejrs. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
8bd1981 to
d1818bc
Compare
|
Huh I thought we had this before and changed at some point to bundle the pointer with its mutability. Or was that only in TyKind? Either way, we should keep all three in sync, so also do the change for TyKind::Ref and Ptr, or keep all three in the MutTy system. |
|
It was removed from |
There was a problem hiding this comment.
Overall the change looks good to me.
I have two thoughts about this (and please disagree if you disagree)
There are many changes like
- let TyKind::Ptr(_) = ret_ty.kind
+ let TyKind::Ptr(..) = ret_ty.kindThe downside of this is that it'll continue to compile if we add or remove fields in the future. It is more robust to do:
- let TyKind::Ptr(_) = ret_ty.kind
+ let TyKind::Ptr(_, _) = ret_ty.kind(same for the Ref types)
Second, there a couple of cases where this happens:
let ty =...;
let Ptr(ty, _) = ty.kind
// ty is used laterIt is rather error prone to alias variables of a same type in this manner. Usually, but not always, the code here chooses a different name to get around this. Can you choose one convention and apply it everywhere? Can be something like pointee_ty, ref_ty, inner_ty, etc, I don't really care about which one.
|
Regarding 1., I don't see this as much of a downside. It would make refactorings like this one easier and I would expect that if a new field was to be added or removed, these places would mostly not care and ignore the field as well. (And there are already several preexisting cases of Regarding 2., I'll change this tomorrow. |
| TyKind::Ptr(MutTy { ty, .. }) => (Pat::Str("*"), ast_ty_search_pat(ty).1), | ||
| TyKind::Ref(_, MutTy { ty, .. }) | TyKind::PinnedRef(_, MutTy { ty, .. }) => { | ||
| TyKind::Ptr( ty, .. ) => (Pat::Str("*"), ast_ty_search_pat(ty).1), | ||
| TyKind::Ref(_, ty, ..) | TyKind::PinnedRef(_, ty, .. ) => { |
There was a problem hiding this comment.
why was this extra whitespace neither detected by x fmt nor in CI?
There was a problem hiding this comment.
X doesn't format clippy, you have to navigate to the clippy folder and use cargo dev fmt
d1818bc to
ac6f00d
Compare
|
I've changed all the potentially ambiguous |
remove `MutTy` This PR removes `ast::MutTy` and `hir::MutTy` and inlines their two fields directly into their corresponding `TypeKind` variants. These types probably made sense in pre-1.0 versions where it still had a syntax-level representation with things like `[mut T]`. Nowadays, it is just a type that is used in some, but not all places to group a type and a mutability together (for example, `rustc_type_ir` does not include such a wrapper). It also has no methods and just makes some match statements more verbose. Removing it makes them more readable.
…uwer Rollup of 7 pull requests Successful merges: - #163327 (remove `MutTy`) - #162910 (Deterministic encoding of `DefPathHashMap`) - #163009 (dont store arbitrary parsed attributes in thir) - #162683 (Use attribute parser for `#[inline()]` attribute check) - #163429 (lint on `Ident::from_str_and_span` taking a string literal) - #163431 (Allow `#[repr(simd)]` with `f16b`) - #163433 (Support also `try-jobs:` to specify custom try jobs)
Rollup merge of #163327 - cyrgani:mut-ty, r=mejrs remove `MutTy` This PR removes `ast::MutTy` and `hir::MutTy` and inlines their two fields directly into their corresponding `TypeKind` variants. These types probably made sense in pre-1.0 versions where it still had a syntax-level representation with things like `[mut T]`. Nowadays, it is just a type that is used in some, but not all places to group a type and a mutability together (for example, `rustc_type_ir` does not include such a wrapper). It also has no methods and just makes some match statements more verbose. Removing it makes them more readable.
…uwer Rollup of 7 pull requests Successful merges: - rust-lang/rust#163327 (remove `MutTy`) - rust-lang/rust#162910 (Deterministic encoding of `DefPathHashMap`) - rust-lang/rust#163009 (dont store arbitrary parsed attributes in thir) - rust-lang/rust#162683 (Use attribute parser for `#[inline()]` attribute check) - rust-lang/rust#163429 (lint on `Ident::from_str_and_span` taking a string literal) - rust-lang/rust#163431 (Allow `#[repr(simd)]` with `f16b`) - rust-lang/rust#163433 (Support also `try-jobs:` to specify custom try jobs)
…nathanBrouwer Rollup of 7 pull requests Successful merges: - rust-lang#163327 (remove `MutTy`) - rust-lang#162910 (Deterministic encoding of `DefPathHashMap`) - rust-lang#163009 (dont store arbitrary parsed attributes in thir) - rust-lang#162683 (Use attribute parser for `#[inline()]` attribute check) - rust-lang#163429 (lint on `Ident::from_str_and_span` taking a string literal) - rust-lang#163431 (Allow `#[repr(simd)]` with `f16b`) - rust-lang#163433 (Support also `try-jobs:` to specify custom try jobs)
…uwer Rollup of 7 pull requests Successful merges: - rust-lang/rust#163327 (remove `MutTy`) - rust-lang/rust#162910 (Deterministic encoding of `DefPathHashMap`) - rust-lang/rust#163009 (dont store arbitrary parsed attributes in thir) - rust-lang/rust#162683 (Use attribute parser for `#[inline()]` attribute check) - rust-lang/rust#163429 (lint on `Ident::from_str_and_span` taking a string literal) - rust-lang/rust#163431 (Allow `#[repr(simd)]` with `f16b`) - rust-lang/rust#163433 (Support also `try-jobs:` to specify custom try jobs)
This PR removes
ast::MutTyandhir::MutTyand inlines their two fields directly into their correspondingTypeKindvariants. These types probably made sense in pre-1.0 versions where it still had a syntax-level representation with things like[mut T]. Nowadays, it is just a type that is used in some, but not all places to group a type and a mutability together (for example,rustc_type_irdoes not include such a wrapper). It also has no methods and just makes some match statements more verbose. Removing it makes them more readable.