-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Remove hir::ArrayLen
#133589
Remove hir::ArrayLen
#133589
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I think this is because I now normalize all |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool :3 thanks for doing this
@@ -2,7 +2,7 @@ | |||
|
|||
| User Type Annotations | |||
| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [&*b"AAAA"], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:13:16: 13:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} | |||
| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[d56d]::main::{constant#1}), args: [] }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} | |||
| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [&*b"AAAA"], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change would be why we dont want to normalize at the end of lower_const_arg
. User type annotations exist to remember the "unnormalized as written by the user" types/generic arguments in MIR so that any lifetime constraints introduced by them can be known to the borrow checker instead of being ignored :3
This specific example isn't wrong per se but in the general case it would be with const arguments that use lifetime parameters, e.g.:
#![feature(min_generic_const_args)]
trait Trait<'a> {
const ASSOC: usize;
}
impl Trait<'static> for u8 {
const ASSOC: usize = 10;
}
struct Bar<const N: usize>;
fn foo<'a>() {
let _: Bar<<u8 as Trait<'a>>::ASSOC>;
}
<u8 as Trait<'a>>::ASSOC
being well formed requires 'a: 'static
which doesn't hold so we should error in borrow checking. This is accomplished by having a user type annotation of <u8 as Trait<'a>>::ASSOC
so that borrow checking knows 'a: 'static
must hold. With this change we'd have a user type annotation of 10
which doesn't tell borrow checking anything about 'a: 'static
having to hold :3
Though this example won't actually do anything right now since min_generic_const_args
hasn't been implemented :3
HIR ty lowering was modified cc @fmease Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you squash these commits then r=me
Remove Node::ArrayLenInfer
fb8dfb2
to
d38f013
Compare
@bors r=boxyuwu |
Rollup of 4 pull requests Successful merges: - rust-lang#133589 (Remove `hir::ArrayLen`) - rust-lang#133672 (Remove a bunch of unnecessary const stability noise) - rust-lang#133678 (Stabilize `ptr::fn_addr_eq`) - rust-lang#133727 (Update mailmap) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 4 pull requests Successful merges: - rust-lang#133589 (Remove `hir::ArrayLen`) - rust-lang#133672 (Remove a bunch of unnecessary const stability noise) - rust-lang#133678 (Stabilize `ptr::fn_addr_eq`) - rust-lang#133727 (Update mailmap) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#133589 - voidc:remove-array-len, r=boxyuwu Remove `hir::ArrayLen` This refactoring removes `hir::ArrayLen`, replacing it with `hir::ConstArg`. To represent inferred array lengths (previously `hir::ArrayLen::Infer`), a new variant `ConstArgKind::Infer` is added. r? `@BoxyUwU`
…id, r=compiler-errors Use correct `hir_id` for array const arg infers Fixes rust-lang#133771 `self.next_id()` results in the `DefId` for the const argument, created from the hack introduced by rust-lang#133468, having no `HirId` associated with it. This then results in an ICE in metadata encoding. Fixing this then results in *another* ICE where `encode_defs` was not skipping encoding `type_of` and other queries for `DefId`s when they correspond to a `ConstArgKind::Infer` node. This only reproduces with a library crate as metadata is not encoded for binaries, and apparently we had 0 tests for `generic_arg_infer` for array lengths in a library crate so this was not caught :< cc rust-lang#133589 `@voidc` r? `@compiler-errors` `@lcnr`
…id, r=compiler-errors Use correct `hir_id` for array const arg infers Fixes rust-lang#133771 `self.next_id()` results in the `DefId` for the const argument, created from the hack introduced by rust-lang#133468, having no `HirId` associated with it. This then results in an ICE in metadata encoding. Fixing this then results in *another* ICE where `encode_defs` was not skipping encoding `type_of` and other queries for `DefId`s when they correspond to a `ConstArgKind::Infer` node. This only reproduces with a library crate as metadata is not encoded for binaries, and apparently we had 0 tests for `generic_arg_infer` for array lengths in a library crate so this was not caught :< cc rust-lang#133589 ``@voidc`` r? ``@compiler-errors`` ``@lcnr``
…id, r=compiler-errors Use correct `hir_id` for array const arg infers Fixes rust-lang#133771 `self.next_id()` results in the `DefId` for the const argument, created from the hack introduced by rust-lang#133468, having no `HirId` associated with it. This then results in an ICE in metadata encoding. Fixing this then results in *another* ICE where `encode_defs` was not skipping encoding `type_of` and other queries for `DefId`s when they correspond to a `ConstArgKind::Infer` node. This only reproduces with a library crate as metadata is not encoded for binaries, and apparently we had 0 tests for `generic_arg_infer` for array lengths in a library crate so this was not caught :< cc rust-lang#133589 ```@voidc``` r? ```@compiler-errors``` ```@lcnr```
…id, r=compiler-errors Use correct `hir_id` for array const arg infers Fixes rust-lang#133771 `self.next_id()` results in the `DefId` for the const argument, created from the hack introduced by rust-lang#133468, having no `HirId` associated with it. This then results in an ICE in metadata encoding. Fixing this then results in *another* ICE where `encode_defs` was not skipping encoding `type_of` and other queries for `DefId`s when they correspond to a `ConstArgKind::Infer` node. This only reproduces with a library crate as metadata is not encoded for binaries, and apparently we had 0 tests for `generic_arg_infer` for array lengths in a library crate so this was not caught :< cc rust-lang#133589 `@voidc` r? `@compiler-errors` `@lcnr`
Rollup merge of rust-lang#133779 - BoxyUwU:array_const_arg_infer_hir_id, r=compiler-errors Use correct `hir_id` for array const arg infers Fixes rust-lang#133771 `self.next_id()` results in the `DefId` for the const argument, created from the hack introduced by rust-lang#133468, having no `HirId` associated with it. This then results in an ICE in metadata encoding. Fixing this then results in *another* ICE where `encode_defs` was not skipping encoding `type_of` and other queries for `DefId`s when they correspond to a `ConstArgKind::Infer` node. This only reproduces with a library crate as metadata is not encoded for binaries, and apparently we had 0 tests for `generic_arg_infer` for array lengths in a library crate so this was not caught :< cc rust-lang#133589 `@voidc` r? `@compiler-errors` `@lcnr`
Remove `hir::ArrayLen` This refactoring removes `hir::ArrayLen`, replacing it with `hir::ConstArg`. To represent inferred array lengths (previously `hir::ArrayLen::Infer`), a new variant `ConstArgKind::Infer` is added. r? `@BoxyUwU`
This refactoring removes
hir::ArrayLen
, replacing it withhir::ConstArg
. To represent inferred array lengths (previouslyhir::ArrayLen::Infer
), a new variantConstArgKind::Infer
is added.r? @BoxyUwU