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

RenderPassDescriptor: make label lifetime match doc, and make names descriptive. #2654

Merged
merged 1 commit into from
May 13, 2022

Conversation

kpreid
Copy link
Contributor

@kpreid kpreid commented May 13, 2022

Description
Lifetime names like <'a, 'b> mean that the reader must look at how they are used to understand them. By changing them to 'tex (lifetime of borrows of the texture views the documentation describes) and 'desc (everything else), and mentioning them in the documentation, it's more obvious which role each one plays.

For consistency, I also changed begin_render_pass(), RenderPassColorAttachment, and RenderPassDepthStencilAttachment to use matching lifetime names.

Also, this made it clear that the Label had the wrong lifetime -- the docs say that the texture views have a different lifetime from “everything else”, but the Label in fact had the same lifetime as the texture views, so I changed it to the 'desc (formerly 'b) lifetime. (On review of change history, this mismatch was previously introduced in commit 632f828.) This change is definitely safe because I followed the data flow down to BasePass::new which promptly calls to_string() on the label, thus converting it to owned data.

Testing
As this only weakens lifetimes (which cannot change run-time behavior or stop a program from compiling) and renames them (which is not an API surface change) it should not have any effect other than allowing some programs with short-lived labels to compile when they would not have otherwise. That said, I ran cargo nextest run --no-fail-fast and all tests passed except for example/shadow which always fails on my machine.

…escriptive.

Lifetime names like `<'a, 'b>` mean that the reader must look at how
they are used to understand them. By changing them to `'tex` (lifetime
of borrows of the texture views the documentation describes) and `'desc`
(everything else), and mentioning them in the documentation, it's more
obvious which role each one plays.

For consistency, I also changed `begin_render_pass()`,
`RenderPassColorAttachment`, and `RenderPassDepthStencilAttachment` to
use matching lifetime names.

Also, this made it clear that the `Label` had the wrong lifetime --
the docs say that the texture views have a different lifetime from
“everything else”, but the `Label` in fact had the same lifetime as
the texture views, so I changed it to the `'desc` (formerly `'b`)
lifetime. (On review of change history, this mismatch was previously
introduced in commit 632f828.)
This change is definitely safe because I followed the data flow down
to `BasePass::new` which promptly calls `to_string()` on the label,
thus converting it to owned data.
@kvark kvark merged commit c1934dc into gfx-rs:master May 13, 2022
@kpreid kpreid deleted the passlifetime branch July 2, 2022 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants