Skip to content

Scope deprecations#5798

Merged
laurmaedje merged 2 commits intomainfrom
deprecations
Feb 4, 2025
Merged

Scope deprecations#5798
laurmaedje merged 2 commits intomainfrom
deprecations

Conversation

@laurmaedje
Copy link
Member

This PR adds support for deprecating arbitrary definition in a Scope. It is an alternative to #5582 that builds on the refactorings done in #5797.

Compared to #5582, the main differences are:

  • There's no accumulation of define_* variants because with Refactor Scope #5797 the existing define variants return an &mut Binding on which we can chain .deprecated(..).

  • Used a sink argument like proposed in Make it possible to deprecate constants #5582 (comment). It's true that it's not less viral than a MaybeDeprecated, but it's still more lightweight because ignoring means just passing (). Also, we can skip the whole wrapper type with all its conversion methods. Probably it's also a bit more efficient, but that's more of a guess.

  • I kept binding.read() (without deprecation check) and binding.read_checked(..) (with deprecation check) separate for now. That means one could accidentally use read where read_checked would be more apprioriate, but I wanted to keep the virality down for now. We can reconsider this in the future.

  • Instead of Arc<EcoString> (which is double reference-counted), I used &'static str as we only have static messages for now. I also considered &'static &'static str to bring it from two down to one machine words, but I figured that might be annoying to integrate with codex. Since the message is only stored in a Binding and not in a MaybeDeprecated, having the absolute minimum memory size is also not as crucial as in the other PR.

  • Added support for #[deprecated = ".."] in #[scope].

@laurmaedje laurmaedje changed the title Scope deprecation Scope deprecations Feb 3, 2025
Copy link
Contributor

@PgBiel PgBiel left a comment

Choose a reason for hiding this comment

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

Looks like a nice and clean solution. 👍

Copy link
Contributor

@PgBiel PgBiel left a comment

Choose a reason for hiding this comment

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

My only potential restraint is that the empty sink argument might not be too obvious when it's used. I wonder if passing something like a IgnoreDeprecation zero-sized struct would be clearer (unless I misunderstood the purpose of it).

@laurmaedje
Copy link
Member Author

You understood correctly. I just wanted to keep it as unnoisy as possible for the ignoring case for now.

@PgBiel
Copy link
Contributor

PgBiel commented Feb 3, 2025

Okay. Given the description, I assume these functions will receive further changes in the future anyway.

@MDLC01
Copy link
Collaborator

MDLC01 commented Feb 3, 2025

I agree that having a IgnoreDeprecation type would be clearer, but if this is gonna change in the future anyway it probably does not matter. This solution is indeed more lightweight than mine. I closed #5582 in favor of this.

Also, why not renaming read_checked to just read, and the current read to read_unchecked? That way, the most obvious way to access the value is through the function that requires thinking about warnings.

@laurmaedje
Copy link
Member Author

laurmaedje commented Feb 3, 2025

I definitely understand your argument and normally I would be with you, trying to make the first method one reaches for the one where one has to think and consider the options. (Like with the new Scope::bind.)

Here I precisely made the opposite choice because I don't want to force thinking. I don't want the deprecation infrastructure to force any design decisions, extra thinking, or concern in other subsystems. It should be okay to just reach for read(). This is essentially what I mean with keeping the virality down for now, not just code-wise, also mentally. A missing deprecation warning in an edge case (i.e. not variable or field access) is not a big deal.

Once we're more sure that this is how things should work, we can always reconsider this, it's just how I feel for the moment.

I also think that the naming read_unchecked would perhaps invoke too strong a resistance in Rust users due to the unsafety connotation, but that's besides my primary point.

@laurmaedje laurmaedje added this pull request to the merge queue Feb 4, 2025
Merged via the queue into main with commit 50ccd7d Feb 4, 2025
12 checks passed
@laurmaedje laurmaedje deleted the deprecations branch February 4, 2025 10:05
hongjr03 pushed a commit to hongjr03/typst that referenced this pull request Apr 16, 2025
stelzo pushed a commit to stelzo/typst that referenced this pull request Nov 21, 2025
git download method

fixed warinings

documentation

cli updater adaptation and clippy fixes

enhanced documentation

add git downloader default impl

migrating from git2 to gitoxide crate for git downloads

Add support for `c2sc` OpenType feature in `smallcaps` (typst#5655)

Just add MathText SyntaxKind

Basic SymbolElem addition

Use SymbolElem in more places and add `char` cast for content

Add SymbolElem to realization

Update math TextElem layout to separate out SymbolElem

Handle boxes and blocks a bit better in HTML export (typst#5744)

Co-authored-by: Martin Haug <[email protected]>

Tweak HTML pretty printing (typst#5745)

Semantic paragraphs (typst#5746)

Fix space collapsing for explicit paragraphs (typst#5749)

Support first-line-indent for every paragraph (typst#5768)

Fixed typo in the new outline docs (typst#5772)

Resolve bound name of bare import statically (typst#5773)

Fix typo in scripting.md (typst#5783)

Modular, multi-threaded, transitioning plugins (typst#5779)

Include images from raw pixmaps and more (typst#5632)

Co-authored-by: PgBiel <[email protected]>
Co-authored-by: Laurenz <[email protected]>

Change type repr to short name (typst#5788)

Disable cjk_latin_spacing in raw by default (typst#5753)

Change the default math class of U+22A5 ⊥ UP TACK to Normal (typst#5714)

Revert adding `flatten-text` to `image` (typst#5789)

Refactor `Scope` (typst#5797)

Enable HTML feature in docs generator (typst#5800)

Scope deprecations (typst#5798)

Fix typo in page documentation (typst#5804)

Bump openssl from 0.10.66 to 0.10.70 (typst#5802)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump codex to 0.1.0 (typst#5805)

Bump dependencies (typst#5808)

Fix small copy-paste oversight (typst#5811)

Bump more dependencies (typst#5813)

Export target docs (typst#5812)

Co-authored-by: Martin Haug <[email protected]>

0.13 changelog (typst#5801)

Release Candidate 1

Autocomplete content methods (typst#5822)

Documentation fixes and improvements (typst#5816)

Fix docs outline for nested definitions (typst#5823)

Document removals in changelog (typst#5827)

Fix unnecessary import rename warning (typst#5828)

Don't crash on image with zero DPI (typst#5835)

Add warning for `pdf.embed` elem used with HTML (typst#5829)

Add smart quotes for Bulgarian (typst#5807)

Respect `par` constructor arguments (typst#5842)

Bump `typst-assets`

Fix autocomplete and jumps in math (typst#5849)

Update documentation for `float.{to-bits, from-bits}` (typst#5836)

`Gradient::repeat`: Fix floating-point error in stop calculation (typst#5837)

Lazy parsing of the package index (typst#5851)

Remove Linux Libertine warning (typst#5876)

Bring back type/str compatibility for 0.13, with warnings and hints (typst#5877)

More robust SVG auto-detection (typst#5878)

HTML export: Use `<code>` for inline `RawElem` (typst#5884)

--make-deps fixes (typst#5873)

Update changelog (typst#5894)

Version bump

Fix HTML export of table with gutter (typst#5920)

Fix comparison of `Func` and `NativeFuncData` (typst#5943)

HTML export: fix elem counting on classify_output (typst#5910)

Co-authored-by: Laurenz <[email protected]>

Fix introspection of HTML root sibling metadata (typst#5953)

Fix high CPU usage due to inotify watch triggering itself (typst#5905)

Co-authored-by: Laurenz <[email protected]>

Fix false positive for type/str comparison warning (typst#5957)

Fix paper name in page setup guide (typst#5956)

Fix curve with multiple non-closed components. (typst#5963)

Fix docs example with type/string comparison (typst#5987)

Correct typo (typst#5971)

Make `array.chunks` example more readable (typst#5975)

Hotfix for labels on symbols (typst#6015)

Replace `par` function call in tutorial (typst#6023)

Mention that `sym.ohm` was removed in the 0.13.0 changelog (typst#6017)

Co-authored-by: Laurenz <[email protected]>

Mark breaking symbol changes as breaking in 0.13.0 changelog (typst#6024)

0.13.1 changelog (typst#6025)

Version bump

dep min 1.81

use 1.81 in ci
stelzo pushed a commit to stelzo/typst that referenced this pull request Nov 21, 2025
git download method

fixed warinings

documentation

cli updater adaptation and clippy fixes

enhanced documentation

add git downloader default impl

migrating from git2 to gitoxide crate for git downloads

Add support for `c2sc` OpenType feature in `smallcaps` (typst#5655)

Just add MathText SyntaxKind

Basic SymbolElem addition

Use SymbolElem in more places and add `char` cast for content

Add SymbolElem to realization

Update math TextElem layout to separate out SymbolElem

Handle boxes and blocks a bit better in HTML export (typst#5744)

Co-authored-by: Martin Haug <[email protected]>

Tweak HTML pretty printing (typst#5745)

Semantic paragraphs (typst#5746)

Fix space collapsing for explicit paragraphs (typst#5749)

Support first-line-indent for every paragraph (typst#5768)

Fixed typo in the new outline docs (typst#5772)

Resolve bound name of bare import statically (typst#5773)

Fix typo in scripting.md (typst#5783)

Modular, multi-threaded, transitioning plugins (typst#5779)

Include images from raw pixmaps and more (typst#5632)

Co-authored-by: PgBiel <[email protected]>
Co-authored-by: Laurenz <[email protected]>

Change type repr to short name (typst#5788)

Disable cjk_latin_spacing in raw by default (typst#5753)

Change the default math class of U+22A5 ⊥ UP TACK to Normal (typst#5714)

Revert adding `flatten-text` to `image` (typst#5789)

Refactor `Scope` (typst#5797)

Enable HTML feature in docs generator (typst#5800)

Scope deprecations (typst#5798)

Fix typo in page documentation (typst#5804)

Bump openssl from 0.10.66 to 0.10.70 (typst#5802)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump codex to 0.1.0 (typst#5805)

Bump dependencies (typst#5808)

Fix small copy-paste oversight (typst#5811)

Bump more dependencies (typst#5813)

Export target docs (typst#5812)

Co-authored-by: Martin Haug <[email protected]>

0.13 changelog (typst#5801)

Release Candidate 1

Autocomplete content methods (typst#5822)

Documentation fixes and improvements (typst#5816)

Fix docs outline for nested definitions (typst#5823)

Document removals in changelog (typst#5827)

Fix unnecessary import rename warning (typst#5828)

Don't crash on image with zero DPI (typst#5835)

Add warning for `pdf.embed` elem used with HTML (typst#5829)

Add smart quotes for Bulgarian (typst#5807)

Respect `par` constructor arguments (typst#5842)

Bump `typst-assets`

Fix autocomplete and jumps in math (typst#5849)

Update documentation for `float.{to-bits, from-bits}` (typst#5836)

`Gradient::repeat`: Fix floating-point error in stop calculation (typst#5837)

Lazy parsing of the package index (typst#5851)

Remove Linux Libertine warning (typst#5876)

Bring back type/str compatibility for 0.13, with warnings and hints (typst#5877)

More robust SVG auto-detection (typst#5878)

HTML export: Use `<code>` for inline `RawElem` (typst#5884)

--make-deps fixes (typst#5873)

Update changelog (typst#5894)

Version bump

Fix HTML export of table with gutter (typst#5920)

Fix comparison of `Func` and `NativeFuncData` (typst#5943)

HTML export: fix elem counting on classify_output (typst#5910)

Co-authored-by: Laurenz <[email protected]>

Fix introspection of HTML root sibling metadata (typst#5953)

Fix high CPU usage due to inotify watch triggering itself (typst#5905)

Co-authored-by: Laurenz <[email protected]>

Fix false positive for type/str comparison warning (typst#5957)

Fix paper name in page setup guide (typst#5956)

Fix curve with multiple non-closed components. (typst#5963)

Fix docs example with type/string comparison (typst#5987)

Correct typo (typst#5971)

Make `array.chunks` example more readable (typst#5975)

Hotfix for labels on symbols (typst#6015)

Replace `par` function call in tutorial (typst#6023)

Mention that `sym.ohm` was removed in the 0.13.0 changelog (typst#6017)

Co-authored-by: Laurenz <[email protected]>

Mark breaking symbol changes as breaking in 0.13.0 changelog (typst#6024)

0.13.1 changelog (typst#6025)

Version bump

dep min 1.81

use 1.81 in ci
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.

3 participants