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

Treat safe target_feature functions as unsafe by default [less invasive variant] #134353

Merged
merged 7 commits into from
Jan 15, 2025

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Dec 15, 2024

This unblocks

As I stated in #134090 (comment) I think the previous impl was too easy to get wrong, as by default it treated safe target feature functions as safe and had to add additional checks for when they weren't. Now the logic is inverted. By default they are unsafe and you have to explicitly handle safe target feature functions.

This is the less (imo) invasive variant of #134317, as it doesn't require changing the Safety enum, so it only affects FnDefs and nothing else, as it should.

@rustbot
Copy link
Collaborator

rustbot commented Dec 15, 2024

r? @chenyukang

rustbot has assigned @chenyukang.
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 Dec 15, 2024
@rustbot
Copy link
Collaborator

rustbot commented Dec 15, 2024

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Dec 15, 2024
compiler/rustc_ast_lowering/src/delegation.rs Show resolved Hide resolved
compiler/rustc_hir_typeck/src/coercion.rs Outdated Show resolved Hide resolved
compiler/rustc_mir_build/src/check_unsafety.rs Outdated Show resolved Hide resolved
compiler/rustc_smir/src/rustc_smir/convert/mod.rs Outdated Show resolved Hide resolved
tests/ui/error-emitter/highlighting.svg Outdated Show resolved Hide resolved
tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.stderr Outdated Show resolved Hide resolved
tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr Outdated Show resolved Hide resolved
tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr Outdated Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk force-pushed the safe-target-feature-unsafe-by-default branch from 9bd90ce to 273c6c5 Compare December 15, 2024 21:20
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 16, 2024
…ler-errors

Handle fndef rendering together with signature rendering

Pulled out of rust-lang#134353

Changes some highlighting in type mismatch errors around fndefs
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 16, 2024
…ler-errors

Handle fndef rendering together with signature rendering

Pulled out of rust-lang#134353

Changes some highlighting in type mismatch errors around fndefs
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 16, 2024
…ler-errors

Handle fndef rendering together with signature rendering

Pulled out of rust-lang#134353

Changes some highlighting in type mismatch errors around fndefs
@oli-obk oli-obk force-pushed the safe-target-feature-unsafe-by-default branch from 273c6c5 to e14cb3b Compare December 16, 2024 15:51
@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk force-pushed the safe-target-feature-unsafe-by-default branch from e14cb3b to 97754d0 Compare December 16, 2024 16:02
@rustbot
Copy link
Collaborator

rustbot commented Dec 16, 2024

Some changes occurred in need_type_info.rs

cc @lcnr

@rust-log-analyzer

This comment has been minimized.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 16, 2024
…ostic-cleanups, r=compiler-errors

Some trait method vs impl method signature difference diagnostic cleanups

Just some things I noticed while debugging a weird diagnostic in rust-lang#134353

best reviewed commit by commit
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 16, 2024
…ostic-cleanups, r=compiler-errors

Some trait method vs impl method signature difference diagnostic cleanups

Just some things I noticed while debugging a weird diagnostic in rust-lang#134353

best reviewed commit by commit
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 16, 2024
…ostic-cleanups, r=compiler-errors

Some trait method vs impl method signature difference diagnostic cleanups

Just some things I noticed while debugging a weird diagnostic in rust-lang#134353

best reviewed commit by commit
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 16, 2024
…ostic-cleanups, r=compiler-errors

Some trait method vs impl method signature difference diagnostic cleanups

Just some things I noticed while debugging a weird diagnostic in rust-lang#134353

best reviewed commit by commit
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 16, 2024
Rollup merge of rust-lang#134386 - oli-obk:some-trait-impl-diff-diagnostic-cleanups, r=compiler-errors

Some trait method vs impl method signature difference diagnostic cleanups

Just some things I noticed while debugging a weird diagnostic in rust-lang#134353

best reviewed commit by commit
jhpratt added a commit to jhpratt/rust that referenced this pull request Dec 17, 2024
…ler-errors

Handle fndef rendering together with signature rendering

Pulled out of rust-lang#134353

Changes some highlighting in type mismatch errors around fndefs
jhpratt added a commit to jhpratt/rust that referenced this pull request Dec 17, 2024
…ler-errors

Handle fndef rendering together with signature rendering

Pulled out of rust-lang#134353

Changes some highlighting in type mismatch errors around fndefs
@oli-obk oli-obk force-pushed the safe-target-feature-unsafe-by-default branch from 97754d0 to 54901b6 Compare December 17, 2024 12:39
@rust-log-analyzer

This comment has been minimized.

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 17, 2024
Rollup merge of rust-lang#134354 - oli-obk:push-nlrxswvpqnuk, r=compiler-errors

Handle fndef rendering together with signature rendering

Pulled out of rust-lang#134353

Changes some highlighting in type mismatch errors around fndefs
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jan 14, 2025
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jan 14, 2025
…-by-default, r=wesleywiser

Treat safe target_feature functions as unsafe by default [less invasive variant]

This unblocks
* rust-lang#134090

As I stated in rust-lang#134090 (comment) I think the previous impl was too easy to get wrong, as by default it treated safe target feature functions as safe and had to add additional checks for when they weren't. Now the logic is inverted. By default they are unsafe and you have to explicitly handle safe target feature functions.

This is the less (imo) invasive variant of rust-lang#134317, as it doesn't require changing the Safety enum, so it only affects FnDefs and nothing else, as it should.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 14, 2025
…llaumeGomez

Rollup of 5 pull requests

Successful merges:

 - rust-lang#134216 (Enable "jump to def" feature on patterns)
 - rust-lang#134353 (Treat safe target_feature functions as unsafe by default [less invasive variant])
 - rust-lang#134880 (Made `Path::name` only have item name rather than full name)
 - rust-lang#135466 (Leak check in `impossible_predicates` to avoid monomorphizing impossible instances)
 - rust-lang#135476 (Remove remnant of asmjs)

r? `@ghost`
`@rustbot` modify labels: rollup
@matthiaskrgr
Copy link
Member

@bors r-
#135486 (comment)

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 14, 2025
@oli-obk oli-obk force-pushed the safe-target-feature-unsafe-by-default branch from b1deae5 to 767d4fe Compare January 15, 2025 08:58
@oli-obk
Copy link
Contributor Author

oli-obk commented Jan 15, 2025

@bors r+ rollup=iffy

@bors
Copy link
Contributor

bors commented Jan 15, 2025

📌 Commit 767d4fe has been approved by oli-obk

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 15, 2025
@oli-obk
Copy link
Contributor Author

oli-obk commented Jan 15, 2025

@bors r=wesleywiser

@bors
Copy link
Contributor

bors commented Jan 15, 2025

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Contributor

bors commented Jan 15, 2025

📌 Commit 767d4fe has been approved by wesleywiser

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jan 15, 2025

⌛ Testing commit 767d4fe with merge 341f603...

@bors
Copy link
Contributor

bors commented Jan 15, 2025

☀️ Test successful - checks-actions
Approved by: wesleywiser
Pushing 341f603 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 15, 2025
@bors bors merged commit 341f603 into rust-lang:master Jan 15, 2025
7 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Jan 15, 2025
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (341f603): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.0%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.0%] 1

Max RSS (memory usage)

Results (primary -3.1%, secondary 0.6%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.8% [2.2%, 3.3%] 2
Improvements ✅
(primary)
-3.1% [-3.1%, -3.1%] 1
Improvements ✅
(secondary)
-3.8% [-3.8%, -3.8%] 1
All ❌✅ (primary) -3.1% [-3.1%, -3.1%] 1

Cycles

Results (secondary 7.2%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
7.2% [7.2%, 7.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.0%, secondary 0.2%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.1%] 54
Regressions ❌
(secondary)
0.2% [0.0%, 0.4%] 21
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.1%] 54

Bootstrap: 764.012s -> 762.915s (-0.14%)
Artifact size: 326.03 MiB -> 326.09 MiB (0.02%)

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 16, 2025
…-ptr, r=oli-obk

Allow coercing safe-to-call target_feature functions to safe fn pointers

r? oli-obk

`@oli-obk:` this is based on your PR rust-lang#134353 :-)

See rust-lang#134090 (comment) for the motivation behind this change.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 17, 2025
Rollup merge of rust-lang#135504 - veluca93:target-feature-cast-to-fn-ptr, r=oli-obk

Allow coercing safe-to-call target_feature functions to safe fn pointers

r? oli-obk

`@oli-obk:` this is based on your PR rust-lang#134353 :-)

See rust-lang#134090 (comment) for the motivation behind this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants