Skip to content

Peel all array dimensions in clang::Type::is_const - #3521

Merged
emilio merged 1 commit into
rust-lang:mainfrom
mhils:fix-multidim-const-array
Oct 14, 2026
Merged

emilio merged 1 commit into
rust-lang:mainfrom
mhils:fix-multidim-const-array

Conversation

@mhils

@mhils mhils commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Previously, ir/var.rs and ir/ty.rs only peeled a single array layer when checking whether a ConstantArray or IncompleteArray had const-qualified elements. As a result, multidimensional const arrays (e.g. extern const int baz[1][1]; or extern const int qux[][1];) were emitted as pub static mut, and 3D+ const array parameters were emitted as *mut.

Move the array-peeling loop into clang::Type::is_const so all callers handle arbitrary-dimensional constant and incomplete arrays consistently.

Previously, ir/var.rs and ir/ty.rs only peeled a single array layer when checking whether a ConstantArray or IncompleteArray had const-qualified elements. As a result, multidimensional const arrays (e.g. `extern const int baz[1][1];` or `extern const int qux[][1];`) were emitted as `pub static mut`, and 3D+ const array parameters were emitted as `*mut`.

Move the array-peeling loop into `clang::Type::is_const` so all callers handle arbitrary-dimensional constant and incomplete arrays consistently.
@mhils

mhils commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

r? @emilio

@emilio
emilio added this pull request to the merge queue Oct 14, 2026
Merged via the queue into rust-lang:main with commit 841f911 Oct 14, 2026
52 checks passed
@mhils

mhils commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the quick review, much appreciated! 🙏 😃 🍰

@mhils
mhils deleted the fix-multidim-const-array branch October 14, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants