-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tuple indexing regression #59553
Comments
cc @estebank |
@petrochenkov what do you think, should we accept i32 there? It feels like a bad idea and I feel the right fix is in quote, but for expidiency we could continue accepting this suffix in particular for a couple of releases. CC @rust-lang/compiler @rust-lang/lang @dtolnay |
I don't think there's any language design that needs this so I'm happy with a C-future-compatibility warning here for a few releases. I agree the right fix is in quote or in dependent crates. |
I believe quote is behaving correctly so I won't be making any code change associated with this in quote. |
@dtolnay Perhaps a change in documentation pointing out the right way to achieve what the user wants? |
Sure, that could be good. I filed dtolnay/quote#101 to follow up. Thanks! |
After an in person conversations with other members of the team, I feel that the right course if action is to wait until the beta crater run and depending on the extent of the in the wild breakage, backporting a beta only change that makes this a warning instead of a hard error for one release. Although it is bad that it was allowed for a while in stable, the new behavior is indeed the right behavior. If crater doesn't catch too many crates with problems we should go ahead and leave this as is |
triage: Marking P-high for now, but maybe team will convince me it is P-medium. |
there was somewhat heated discussion in the T-compiler meeting today about this. @nikomatsakis agreed to "try to lead it to resolution" assigning to them. |
(in the short term, we may want to revert #59421 and backport the revert to beta.) |
I will agree to reverting if and only if it is agreed that it will eventually become a hard error. I'm not OK with adding garbage into the grammar and I cannot say for certain that it won't conflict with future language design. Moreover, I don't want to set this as a precedent for adding other types of garbage the next time rustc has a bug and diverges from the grammar. (And this is a reminder why wg-grammar work is important... rustc should not be the spec, only an implementation among others). |
Could we make this into a warning on beta instead of reverting completely on master? It should be a very simple fix for users and it seems very undesirable to have this bug existing for a long period of time. |
I'm onboard with @varkor's view, possibly silencing the case of To clarify, I believe we should:
|
We can record whether the literal was created by a proc macro, through e.g. |
I agree with @estebank's proposal to start with a warning. I am not sure what I think the final steps are, though I think moving to a hard error eventually is probably acceptable (possibly over an edition, possibly not). |
I don't think this warrants edition differences; those should be used for intentional shifts that are actually breaking changes... Not for fixing bugs. If you use edition differences then it is still part of the grammar spec of older editions forever. |
quote generates a TokenStream with a suffix for integers (e.g. 0usize). Suffixes are not allowed for indexing tuples. See rust-lang/rust#59553
@Centril I understand your opinion, I just don't know if I fully agree or not. I'd prefer to discuss that in more depth elsewhere -- when it comes to this specific issue, though, it seems that we agree that we should begin with a warning. (Which is our standard bug fix procedure.) EDIT: Just to elaborate a bit -- this issue happens to come at a time when I'm thinking a lot about what our positioning on forwards compatibility ought to be. As the use of Rust grows, I think it behooves us to be increasingly careful about the way that we impact users. My hunch is that indeed transitioning to error makes sense here, but I think there might be cases where we have unexpected -- but long standing -- behavior that we should simply "deprecate" and not "remove". |
@nikomatsakis So to clarify, my agreement to using the standard bug fix procedure and to land #60186 is conditional on that we agree that it is a bug and commit to making it a hard error (on all editions). I don't want to find out later that due to unclear communication or whatnot that we don't make it into a hard error. An initial crater run has already been done #60138, and it suggests that the number of regressions are small and not systemic. |
Sure; I'm thinking about it as well but I take the opposite view. I think we already have a really strict policy around breakage and if we make it more strict then I fear we will drown under the baggage of things that come with it. While this specific issue has no soundness implications, I think we must value soundness more than we value stability. I also think the same of adding garbage to the grammar but less strongly. As Rust becomes standardized, it does not seem fair that the maintainers of |
Perhaps these discussions are indicative that Rust has grown to the point where having a single source of truth (i.e. rustc) is damaging to the language. If there were multiple implementations of Rust, it would not make sense to have a discussion about whether to accept a bug that has slipped through during implementation, because it wouldn't be compliant with other implementations (or, rather, the language reference itself). Recently there have been discussions about better references for the Rust language and I think that separating the implementation from the design is very important at this stage. If we are very concerned with making sure we don't break anyone, then perhaps we need to focus on developing better mitigations (e.g. a watertight rustfix for past compiler bugs) rather than accepting past mistakes. |
@varkor Yeah totally. Focusing on specification is something that is important and that we should work on this year. It just takes a long time and a whole lot of work to actually do it. |
I think that this is clearly unintentional behavior. As such, it should be treated like a bug, which means that it should start with a warning which will eventually become an error (this is our standard procedure for these sorts of situations). @Centril, I found this comment rather frustrating:
In particular, I don't think that you need to "agree" to use the standard procedure. What would need to be justified is going straight to a hard error. However, I appreciate the motivation of this later comment:
I realize I am sending some mixed signals here. This is in part because I don't quite know what to think. So let me clear it up. I am willing to agree that we should treat this case as an error and move to a hard error after some time (on all editions). I agree that the limited crater run suggests we can do this safely, and I don't think there is any question that the existing behavior is a bug. However, I still think we need to have a broader conversation on the topic of our backwards compatibility procedure. If nothing else, I'd like to see the compiler team triaging and handling future-compatibility warnings more carefully, and us adopting standard time frames (e.g., N releases or what have you). While I of course would like to see us make progress on a specification, I don't actually think it's the high order bit here. In this case, we all agree this is not what a specification would say, if one existed. It often happens that compilers accept some older behavior for reasons of backwards compatibility. I also think it's plausible that a specification might make space to accommodate the legacy behavior of rustc, particularly in older editions. It depends on what kinds of things we encounter. I don't think this particular bug needs to be such a time, thankfully. |
I apologize if I sounded harsh, but this is mainly why I wrote that.
Great, that's precisely the clarification I wanted. :) Seems we are agreed then.
I do strongly agree with standard time frames (ideally adjustable based on number of regressions) and in particular, I think scheduled checkups are a good idea. Having #59658 work (especially the
Sure. I agree in theory that some rustc bugs may warrant embracing into the specification.
Yeah, agreed. |
Temporarily accept [i|u][32|size] suffixes on a tuple index and warn Fix rust-lang#60138. rust-lang#59553 will need to be kept open to track the change back to rejecting this code a few versions down thee line.
Temporarily accept [i|u][32|size] suffixes on a tuple index and warn Fix rust-lang#60138. rust-lang#59553 will need to be kept open to track the change back to rejecting this code a few versions down thee line.
#59421 breaks some code generated by proc macros because quote converts integer to a tokenstream with a suffix.
Proc macro:
Calling code:
Error:
It can be avoided by using
syn::Index::from
orproc_macro::Literal::*_unsuffixed
.I have already fixed my library (taiki-e/pin-project@5f5cc35), but it can happen elsewhere.
The text was updated successfully, but these errors were encountered: