Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Unnecessary references lint #138230

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

Open
obeis wants to merge 3 commits into rust-lang:master
base: master
Choose a base branch
Loading
from obeis:lint-unnecessary-reference

Conversation

Copy link
Contributor

@obeis obeis commented Mar 8, 2025

Close #127724

Copy link
Collaborator

rustbot commented Mar 8, 2025

r? @Noratrieb

rustbot has assigned @Noratrieb.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 8, 2025
Copy link
Collaborator

rustbot commented Mar 8, 2025

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

This comment has been minimized.

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lint seems really specific to a single kind of expression, and there are plenty of other cases where unnecessary references are created when the user is trying to create a raw pointer. Unless this can be greatly generalized, it doesn't really seem worth adding this.

Copy link
Member

r? RalfJung

@rustbot rustbot assigned RalfJung and unassigned Noratrieb Mar 8, 2025
Copy link
Contributor Author

obeis commented Mar 8, 2025

I agree, and my intention is to generalize this lint to cover all unnecessarily created references. Could you please list other cases that you think should be included? I can update this PR to cover them or create an issue to track these cases and mention that they should be added to the unnecessary_refs lint.

Copy link
Member

RalfJung commented Mar 9, 2025 via email

Sorry, I am swamped. Happy to discuss which cases the lint shoild fire on, but I can't review the implementation. r? compiler

@rustbot rustbot assigned SparrowLii and unassigned RalfJung Mar 9, 2025
@traviscross traviscross added T-lang Relevant to the language team needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. labels Mar 9, 2025
Copy link
Member

@SparrowLii SparrowLii left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know little about lints' impls so r? compiler

Copy link
Member

Do we have some people who are our "linting experts"?

Copy link
Member

This lint seems really specific to a single kind of expression, and there are plenty of other cases where unnecessary references are created when the user is trying to create a raw pointer. Unless this can be greatly generalized, it doesn't really seem worth adding this.

Which examples did you have in mind?

A starting point might be to uplift https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr from cliippy to rustc, as you mention. It is not clear to me what the difference is between that lint and this one.

Copy link
Contributor

Do we have some people who are our "linting experts"?

cc @Urgau

Copy link
Member

Urgau commented Mar 10, 2025

Happy to take over the review. If @Nadrieril doesn't want to review it of course.

As for the lint it-self, I join @RalfJung that this is lint is currently clippy::borrow_as_ptr, which will need to be dropped from clippy. Look at 1fee1a4 for the changes needed.

As a drive-by, rustc_hir_pretty should not be necessary, a multi-part suggestion should be used instead, with some span manipulation to get the correct spans.

Copy link
Member

Much appreciated :) r? @Urgau

@rustbot rustbot assigned Urgau and unassigned Nadrieril Mar 11, 2025
@Urgau Urgau added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 12, 2025
@obeis obeis force-pushed the lint-unnecessary-reference branch from 1e686f1 to e113827 Compare March 18, 2025 18:26
@obeis obeis requested a review from Urgau March 18, 2025 18:27
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 18, 2025
@obeis obeis force-pushed the lint-unnecessary-reference branch from e113827 to faf0620 Compare March 18, 2025 18:49

This comment has been minimized.

@Urgau Urgau added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 18, 2025
@obeis obeis force-pushed the lint-unnecessary-reference branch from faf0620 to 976c0a8 Compare March 24, 2025 20:10
Copy link
Collaborator

rustbot commented Mar 24, 2025

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@obeis obeis force-pushed the lint-unnecessary-reference branch from 976c0a8 to 64132e5 Compare March 24, 2025 20:19
@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) O-windows Operating system: Windows labels Mar 24, 2025

This comment has been minimized.

Copy link
Contributor Author

obeis commented Mar 24, 2025

I ran x test on my machine, and everything passed. Why is it failing here, and how can I reproduce those errors locally?

Copy link
Member

RalfJung commented Mar 24, 2025 via email

Maybe try rebasing over the latest master, CI will test your code merged with that and there might be semantic conflicts.
obeis reacted with thumbs up emoji

@obeis obeis force-pushed the lint-unnecessary-reference branch from 64132e5 to b0d836f Compare March 24, 2025 22:35

This comment has been minimized.

@obeis obeis force-pushed the lint-unnecessary-reference branch from b0d836f to 4acb822 Compare March 26, 2025 14:02
@obeis obeis force-pushed the lint-unnecessary-reference branch from 4acb822 to d6d72c8 Compare March 26, 2025 14:04
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] build_script_build test:false 0.334
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
88 | simd_ty!(u8x2[u8;2]: x0, x1);
 | ---------------------------- in this macro invocation
 |
 = note: `-D unnecessary-refs` implied by `-D warnings`
 = help: to override `-D warnings` add `#[allow(unnecessary_refs)]`
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
89 | simd_ty!(i8x2[i8;2]: x0, x1);
 | ---------------------------- in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
93 | simd_ty!(u8x4[u8;4]: x0, x1, x2, x3);
 | ------------------------------------ in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
94 | simd_ty!(u16x2[u16;2]: x0, x1);
 | ------------------------------ in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
96 | simd_ty!(i8x4[i8;4]: x0, x1, x2, x3);
 | ------------------------------------ in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
97 | simd_ty!(i16x2[i16;2]: x0, x1);
 | ------------------------------ in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
101 | / simd_ty!(
102 | | u8x8[u8;8]:
103 | | x0,
104 | | x1,
... |
110 | | x7
111 | | );
 | |_- in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
112 | simd_ty!(u16x4[u16;4]: x0, x1, x2, x3);
 | -------------------------------------- in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
113 | simd_ty!(u32x2[u32;2]: x0, x1);
 | ------------------------------ in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
114 | simd_ty!(u64x1[u64;1]: x1);
 | -------------------------- in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
116 | / simd_ty!(
117 | | i8x8[i8;8]:
118 | | x0,
119 | | x1,
... |
125 | | x7
126 | | );
 | |_- in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
127 | simd_ty!(i16x4[i16;4]: x0, x1, x2, x3);
 | -------------------------------------- in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
128 | simd_ty!(i32x2[i32;2]: x0, x1);
 | ------------------------------ in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
129 | simd_ty!(i64x1[i64;1]: x1);
 | -------------------------- in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
131 | simd_ty!(f32x2[f32;2]: x0, x1);
 | ------------------------------ in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
132 | simd_ty!(f64x1[f64;1]: x1);
 | -------------------------- in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
136 | / simd_ty!(
137 | | u8x16[u8;16]:
138 | | x0,
139 | | x1,
... |
153 | | x15
154 | | );
 | |_- in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
155 | / simd_ty!(
156 | | u16x8[u16;8]:
157 | | x0,
158 | | x1,
... |
164 | | x7
165 | | );
 | |_- in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
166 | simd_ty!(u32x4[u32;4]: x0, x1, x2, x3);
 | -------------------------------------- in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`
...
167 | simd_ty!(u64x2[u64;2]: x0, x1);
 | ------------------------------ in this macro invocation
 |
help: consider using `&raw const` for a safer and more explicit raw pointer
 |
44 - let self_ptr = &self as *const Self as *const $elem_type;
44 + let self_ptr = &raw const self as *const $elem_type;
 |
error: creating a intermediate reference implies aliasing requirements even when immediately casting to raw pointers
 --> library/core/src/../../stdarch/crates/core_arch/src/simd.rs:44:32
 |
5 | / macro_rules! simd_ty {
6 | | ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => {
7 | | #[repr(simd)]
8 | | #[derive(Copy, Clone, Debug, PartialEq)]
... |
44 | | let self_ptr = &self as *const Self as *const $elem_type;
 | | ^^^^^^^^^^^^^^^^^^^^
... |
51 | | }
 | |_- in this expansion of `simd_ty!`

Copy link
Collaborator

bors commented Mar 27, 2025

☔ The latest upstream changes (presumably #139012) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor Author

obeis commented Apr 14, 2025

My PR is currently blocked because the stdarch bump is waiting on a bootstrap bump, see this.

@Dylan-DPC Dylan-DPC added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@Urgau Urgau Urgau left review comments

@SparrowLii SparrowLii SparrowLii left review comments

@compiler-errors compiler-errors compiler-errors requested changes

Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. O-windows Operating system: Windows S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Lint against expressions that unnecessarily create references

AltStyle によって変換されたページ (->オリジナル) /