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 unused Index(Mut) impls on AST types #11903

Merged
merged 2 commits into from Feb 21, 2024

Conversation

sholderbach
Copy link
Member

Description

Both Block and Pipeline had Index/IndexMut implementations to access their elements, that are currently unused.
Explicit helpers or iteration would generally be preferred anyways but in the current state the inner containers are pub and are liberally used. (Sometimes with potentially panicking indexing or also iteration)

As it is potentially unclear what the meaning of the element from a block or pipeline queried by a usize is, let's remove it entirely until we come up with a better API.

User-Facing Changes

None

Plugin authors shouldn't dig into AST internals

Both `Block` and `Pipeline` had `Index`/`IndexMut` implementations to
access their elements, that are currently unused.
Explicit helpers or iteration would generally be preferred anyways but
in the current state the inner containers are `pub` and are liberally
used. (Sometimes with potentially panicking indexing or also iteration)

As it is potentially unclear what the meaning of the element from a
block or pipeline queried by a usize is, let's remove it entirely until
we come up with a better API.
@fdncred
Copy link
Collaborator

fdncred commented Feb 19, 2024

I wonder if these were added by consumers of nushell crates like couchbase-shell? 🤔

Nope - doesn't look like it #4482

@sholderbach
Copy link
Member Author

Alas I was mislead by rust-analyzer, should have checked with --tests as well.

At least for Blocks in my opinion it is not totally obvious what the indexed unit is.

I forgot to check if there are references in the tests.

This certainly makes it more verbose.
Copy link
Collaborator

@WindSoilder WindSoilder left a comment

Choose a reason for hiding this comment

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

Sure! Let's go and remove it

@WindSoilder WindSoilder merged commit 6e590fe into nushell:main Feb 21, 2024
19 checks passed
@sholderbach sholderbach deleted the ineffective-index branch February 21, 2024 11:59
@hustcer hustcer added this to the v0.91.0 milestone Feb 22, 2024
kik4444 pushed a commit to kik4444/nushell-fork that referenced this pull request Feb 28, 2024
# Description
Both `Block` and `Pipeline` had `Index`/`IndexMut` implementations to
access their elements, that are currently unused.
Explicit helpers or iteration would generally be preferred anyways but
in the current state the inner containers are `pub` and are liberally
used. (Sometimes with potentially panicking indexing or also iteration)

As it is potentially unclear what the meaning of the element from a
block or pipeline queried by a usize is, let's remove it entirely until
we come up with a better API.

# User-Facing Changes
None

Plugin authors shouldn't dig into AST internals
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.

None yet

4 participants