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

std::ops::Slice is not in the prelude #17710

Closed
SimonSapin opened this issue Oct 2, 2014 · 6 comments · Fixed by #17715
Closed

std::ops::Slice is not in the prelude #17710

SimonSapin opened this issue Oct 2, 2014 · 6 comments · Fixed by #17715

Comments

@SimonSapin
Copy link
Contributor

The slice and related methods of &[T] apparently have moved to the std::ops::Slice trait, but that trait is not in the prelude. This leads to errors such as:

error: type `&[u8]` does not implement any method in scope named `slice`

This can be “fixed” by adding use std::ops::Slice everywhere, but that doesn’t seem like the intended behavior.

@pnkfelix
Copy link
Member

pnkfelix commented Oct 2, 2014

I believe this was injected by PR #17620

cc @nick29581

aturon added a commit to aturon/rust that referenced this issue Oct 2, 2014
The new overloaded slice operations have replaced the various `slice`
methods on slice types. However, the relevant traits were not included
in the prelude, meaning that you would have to manually import
`std::ops::Slice` to get these operations -- an unintended regression.

This commit adds the traits to the prelude, as is done with most other
operator traits.

Unfortunately, the trait `std::slice::Slice` (which defines an
`as_slice` method) was already included in the prelude. This trait is
renamed to `AsSlice`, which is a better name in any case.

In addition, because of both `AsSlice` and `Str` traits being included
in the prelude, both of which define `as_slice`, and both of which are
used for generic programming, this commit renames `ops::Slice::as_slice`
to `ops::Slice::as_slice_`. This is a stopgap solution; we'll need to
figure out a long-term story here later on.

Closes rust-lang#17710

Due to the renamings, this is a:

[breaking-change]
@nrc
Copy link
Member

nrc commented Oct 2, 2014

You should use the slicing notation instead of the slice methods.

@SimonSapin
Copy link
Contributor Author

Sure, eventually. But going straight to a build error without a deprecation period nor an error message that indicates what to do is unusual for Rust, even pre-1.0.

@pnkfelix
Copy link
Member

pnkfelix commented Oct 2, 2014

@nick29581 I thought the sugar was feature gated. Was the gate removed?

bors added a commit that referenced this issue Oct 2, 2014
This PR reverts #17620, which caused a significant regression for slices.

As discussed with @alexcrichton, all of the public-facing changes of the earlier PR need to be rolled back, and it's not clear that we should move the libraries over to this new notation yet anyway (especially given its feature-gated status).

Closes #17710
@nrc
Copy link
Member

nrc commented Oct 2, 2014

@pnkfelix I believe it was as part of @aturon's backout, but I didn't check and if it was, it was unintentional.

@SimonSapin hard to make an error message for this, since it is just a missing method, but I think we are going to try a smoother deprecation approach

@SimonSapin
Copy link
Contributor Author

@nick29581 My understanding is that so far, stuff we want people not to use should be marked as deprecated (to emit a warning) with a message indicating the alternative, and not removed from some time (possibly until 1.0).

bors added a commit that referenced this issue Oct 2, 2014
This PR reverts #17620, which caused a significant regression for slices.

As discussed with @alexcrichton, all of the public-facing changes of the earlier PR need to be rolled back, and it's not clear that we should move the libraries over to this new notation yet anyway (especially given its feature-gated status).

Closes #17710
lnicola pushed a commit to lnicola/rust that referenced this issue Jul 28, 2024
fix: early exit if unresolved field is an index

Fixes rust-lang#17710
RalfJung pushed a commit to RalfJung/rust that referenced this issue Aug 1, 2024
fix: early exit if unresolved field is an index

Fixes rust-lang#17710
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants