Skip to content

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

Merged
bors merged 7 commits into
rust-lang:masterfrom
oli-obk:safe-target-feature-unsafe-by-default
Jan 15, 2025
Merged

Treat safe target_feature functions as unsafe by default [less invasive variant]#134353
bors merged 7 commits into
rust-lang:masterfrom
oli-obk:safe-target-feature-unsafe-by-default

Conversation

@oli-obk

@oli-obkoli-obk commented Dec 15, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Collaborator

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

@rustbotrustbot 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
Copy Markdown
Collaborator

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

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

This comment has been minimized.

@oli-obk
oli-obkforce-pushed the safe-target-feature-unsafe-by-default branch from 9bd90ce to 273c6c5CompareDecember 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-obkforce-pushed the safe-target-feature-unsafe-by-default branch from 273c6c5 to e14cb3bCompareDecember 16, 2024 15:51
@rust-log-analyzer

This comment has been minimized.

@oli-obk
oli-obkforce-pushed the safe-target-feature-unsafe-by-default branch from e14cb3b to 97754d0CompareDecember 16, 2024 16:02
@rustbot

Copy link
Copy Markdown
Collaborator

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-obkforce-pushed the safe-target-feature-unsafe-by-default branch from 97754d0 to 54901b6CompareDecember 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 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
Copy Markdown
Member

@bors r-
#135486 (comment)

@borsbors 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-obkforce-pushed the safe-target-feature-unsafe-by-default branch from b1deae5 to 767d4feCompareJanuary 15, 2025 08:58
@oli-obk

Copy link
Copy Markdown
ContributorAuthor

@bors r+ rollup=iffy

@bors

bors commented Jan 15, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 767d4fe has been approved by oli-obk

It is now in the queue for this repository.

@borsbors 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
Copy Markdown
ContributorAuthor

@bors r=wesleywiser

@bors

bors commented Jan 15, 2025

Copy link
Copy Markdown
Collaborator

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

@bors

bors commented Jan 15, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 767d4fe has been approved by wesleywiser

It is now in the queue for this repository.

@bors

bors commented Jan 15, 2025

Copy link
Copy Markdown
Collaborator

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

@bors

bors commented Jan 15, 2025

Copy link
Copy Markdown
Collaborator

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

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Jan 15, 2025
@bors
bors merged commit 341f603 into rust-lang:masterJan 15, 2025
@rustbotrustbot added this to the 1.86.0 milestone Jan 15, 2025
@rust-timer

Copy link
Copy Markdown
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.

meanrangecount
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.

meanrangecount
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.

meanrangecount
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.

meanrangecount
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.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 28, 2025
…y-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.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-borsThis PR was explicitly merged by bors.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant 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

@oli-obk@rustbot@rust-log-analyzer@bors@wesleywiser@matthiaskrgr@rust-timer@chenyukang