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

Remove TypeAndMut from ty::RawPtr variant, make it take Ty and Mutability #122852

Merged
merged 6 commits into from
Mar 22, 2024

Conversation

compiler-errors
Copy link
Member

Pretty much mechanically converting ty::RawPtr(ty::TypeAndMut { ty, mutbl }) to ty::RawPtr(ty, mutbl) and its fallout.

r? lcnr

cc rust-lang/types-team#124

@rustbot rustbot added PG-exploit-mitigations Project group: Exploit mitigations 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Mar 21, 2024
@rustbot
Copy link
Collaborator

rustbot commented Mar 21, 2024

Some changes occurred in exhaustiveness checking

cc @Nadrieril

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred in compiler/rustc_symbol_mangling/src/typeid

cc @rust-lang/project-exploit-mitigations, @rcvalle

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

Type relation code was changed

cc @compiler-errors, @lcnr

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

The Miri subtree was changed

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

(&ty::RawPtr(mt_a), &ty::RawPtr(mt_b)) => {
check_mutbl(mt_a, mt_b, &|ty| Ty::new_imm_ptr(tcx, ty))
}
(&ty::Ref(_, ty_a, mutbl_a), &ty::RawPtr(ty_b, mutbl_b)) => check_mutbl(
Copy link
Contributor

Choose a reason for hiding this comment

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

are these the only remaining uses of TypeAndMut?

This could just be check_mutbl(mutbl_a, mutbl_b) and then use target and source for the error messagte instead.

ty::RawPtr(ref mt) => {
self.add_constraints_from_mt(current, mt, variance);
ty::RawPtr(ty, mutbl) => {
self.add_constraints_from_mt(current, &ty::TypeAndMut { ty, mutbl }, variance);
Copy link
Contributor

Choose a reason for hiding this comment

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

okay... not the only use of TypeAndMut 🤷 idk if it's useful to fully remove it then

Copy link
Member

Choose a reason for hiding this comment

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

Is there an issue tracking "entirely remove TypeAndMut"? That would be the logical next step IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not totally sure, some of the remaining uses here seem appropriate as an abstraction over both Ref and RawPtr. Personally don't care too much about keeping it around 🤷

@@ -984,13 +978,13 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {

let (is_ref, mt_a) = match *a.kind() {
ty::Ref(_, ty, mutbl) => (true, ty::TypeAndMut { ty, mutbl }),
ty::RawPtr(mt) => (false, mt),
ty::RawPtr(ty, mutbl) => (false, ty::TypeAndMut { ty, mutbl }),
Copy link
Contributor

Choose a reason for hiding this comment

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

this canreturn (is_ref, ty_a, mutbl_a) instead

Comment on lines +1592 to +1594
r: Region<'tcx>,
ty: Ty<'tcx>,
mutbl: ty::Mutability,
Copy link
Contributor

Choose a reason for hiding this comment

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

vibe: would have expected r, mutbl, ty to match the &'r mutbl ty syntax, same for new_ptr. Anyways, fine to merge as is

@lcnr
Copy link
Contributor

lcnr commented Mar 22, 2024

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Mar 22, 2024

📌 Commit 4f90688 has been approved by lcnr

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 Mar 22, 2024
@bors
Copy link
Contributor

bors commented Mar 22, 2024

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

@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 Mar 22, 2024
@rustbot
Copy link
Collaborator

rustbot commented Mar 22, 2024

HIR ty lowering was modified

cc @fmease

@compiler-errors
Copy link
Member Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Mar 22, 2024

📌 Commit 6a40dab has been approved by lcnr

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 Mar 22, 2024
@bors
Copy link
Contributor

bors commented Mar 22, 2024

⌛ Testing commit 6a40dab with merge 85e449a...

@bors
Copy link
Contributor

bors commented Mar 22, 2024

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing 85e449a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 22, 2024
@bors bors merged commit 85e449a into rust-lang:master Mar 22, 2024
12 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Mar 22, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (85e449a): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results

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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.0% [-7.0%, -5.5%] 3
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 669.004s -> 669.446s (0.07%)
Artifact size: 314.95 MiB -> 314.98 MiB (0.01%)

bjorn3 pushed a commit to bjorn3/rust that referenced this pull request Mar 28, 2024
Remove `TypeAndMut` from `ty::RawPtr` variant, make it take `Ty` and `Mutability`

Pretty much mechanically converting `ty::RawPtr(ty::TypeAndMut { ty, mutbl })` to `ty::RawPtr(ty, mutbl)` and its fallout.

r? lcnr

cc rust-lang/types-team#124
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. PG-exploit-mitigations Project group: Exploit mitigations 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants