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

Check that #[may_dangle] is properly applied #129235

Merged
merged 2 commits into from
Aug 19, 2024

Conversation

GoldsteinE
Copy link
Contributor

It's only valid when applied to a type or lifetime parameter in Drop trait implementation.

Tracking issue: #34761
cc #34761 (comment)

@rustbot
Copy link
Collaborator

rustbot commented Aug 18, 2024

r? @fee1-dead

rustbot has assigned @fee1-dead.
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 Aug 18, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

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.

Couple tiny tweaks, otherwise LGTM

compiler/rustc_passes/src/check_attr.rs Outdated Show resolved Hide resolved
Comment on lines +1386 to +1387
&& let hir::Node::Item(item) = self.tcx.hir_node(parent_hir_id)
&& let hir::ItemKind::Impl(impl_) = item.kind
&& let Some(trait_) = impl_.of_trait
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
&& let hir::Node::Item(item) = self.tcx.hir_node(parent_hir_id)
&& let hir::ItemKind::Impl(impl_) = item.kind
&& let Some(trait_) = impl_.of_trait
&& let hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(impl_), .. }) = self.tcx.hir_node(parent_hir_id)
&& let Some(trait_) = impl_.of_trait

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This leads to somewhat ugly formatting:

&& let hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(impl_), .. }) =
    self.tcx.hir_node(parent_hir_id)

I think the current version is nicer, but I don’t feel that strong about it, so I can make this change if you prefer it.

It's only valid when applied to a type or lifetime parameter
in `Drop` trait implementation.
@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 18, 2024

📌 Commit df6cb95 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 18, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 18, 2024
…piler-errors

Check that `#[may_dangle]` is properly applied

It's only valid when applied to a type or lifetime parameter in `Drop` trait implementation.

Tracking issue: rust-lang#34761
cc rust-lang#34761 (comment)
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 18, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#125854 (Move ZST ABI handling to `rustc_target`)
 - rust-lang#127623 (fix: fs::remove_dir_all: treat internal ENOENT as success)
 - rust-lang#128084 (Suggest adding Result return type for associated method in E0277.)
 - rust-lang#128902 (doc: std::env::var: Returns None for names with '=' or NUL byte)
 - rust-lang#129187 (bootstrap: fix clean's remove_dir_all implementation)
 - rust-lang#129235 (Check that `#[may_dangle]` is properly applied)
 - rust-lang#129245 (Typo)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 18, 2024
…piler-errors

Check that `#[may_dangle]` is properly applied

It's only valid when applied to a type or lifetime parameter in `Drop` trait implementation.

Tracking issue: rust-lang#34761
cc rust-lang#34761 (comment)
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 19, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#128084 (Suggest adding Result return type for associated method in E0277.)
 - rust-lang#128902 (doc: std::env::var: Returns None for names with '=' or NUL byte)
 - rust-lang#129187 (bootstrap: fix clean's remove_dir_all implementation)
 - rust-lang#129194 (Fix bootstrap test `detect_src_and_out` on Windows)
 - rust-lang#129231 (improve submodule updates)
 - rust-lang#129235 (Check that `#[may_dangle]` is properly applied)
 - rust-lang#129245 (Typo)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 19, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#129194 (Fix bootstrap test `detect_src_and_out` on Windows)
 - rust-lang#129217 (safe transmute: check lifetimes)
 - rust-lang#129223 ( Fix wrong argument for `get_fn_decl`)
 - rust-lang#129235 (Check that `#[may_dangle]` is properly applied)
 - rust-lang#129245 (Fix a typo in `rustc_hir` doc comment)
 - rust-lang#129271 (Prevent double panic in query system, improve diagnostics)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7b245e4 into rust-lang:master Aug 19, 2024
6 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Aug 19, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 19, 2024
Rollup merge of rust-lang#129235 - GoldsteinE:check-may-dangle, r=compiler-errors

Check that `#[may_dangle]` is properly applied

It's only valid when applied to a type or lifetime parameter in `Drop` trait implementation.

Tracking issue: rust-lang#34761
cc rust-lang#34761 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants