-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Move errors from libsyntax into their own crate #34403
Conversation
potentially plugin-[breaking-change] |
//! | ||
//! This API is completely unstable and subject to change. | ||
|
||
#![crate_name = "syntax_pos"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's too late for this, but maybe this crate should be called rustc_codemap
to follow the trend of rustc_*
and it's basically where the module came from as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me and @alexcrichton chatted offline a bit about this. A rustc_* name may make sense but we couldn't think of a good fit. Will probably move that way in the future, but the name seems good enough for now.
Looks good to me! cc @Manishearth, is there a protocol for negotiating landing these kinds of changes nowadays? |
thanks @alexcrichton - updated with your suggestions (minus the name one which we chatted about offline). |
(travis fails) @alexcrichton yes! you just say |
@Manishearth: yikes, this is definitely going to cause some syntex fallout. Thanks for the heads up. |
@Manishearth - thanks! This PR touches a fair number of files, so I'm all for batching it up with the other breaking changes. With luck I'll have fixed the last of the travis issues... |
@Manishearth yeah this is good to go whenever at this point (r+ from me) @jonathandturner looks like the travis failure may be legit? |
@alexcrichton - it's legit, chasing down the last(?) of the errors as we speak |
Once merged, I'll add missing error codes into libsyntax (FINALLY!). Very nice work! 👍 |
☔ The latest upstream changes (presumably #34253) made this pull request unmergeable. Please resolve the merge conflicts. |
@jonathandturner If we re-export I think it would be a good idea to re-export everything relevant to plugin authors in |
@jseyfried - Hmm I think the idea is more "refactor so that we can make deeper changes". This has the unfortunate side effect that it may break plugin authors from time to time. The current errors system has layers of different styles and approaches, but I'd like to get it simplified to one style that we can use and then output multiple types of output. |
@jonathandturner Would we ever not be able to re-export everything relevant to plugin authors in Also, perhaps we could add the re-exports for plugin authors in the PR but not use them in rustc itself? We could always remove the re-exports when we make deeper changes that would cause breakage for plugin authors anyway. |
@jseyfried - yeah, I can definitely do that. I think you're right that this would prevent immediate breakage. We can still give plugin authors a heads up that the further simplifications might break them down the road... |
Hopefully they know that -- we try to minimize and batch up plugin-[breaking-changes] but we still make them fairly often (c.f. #31645). |
Woot! Pinging @Manishearth - looks like we've passed travis and cut down the number of breaking changes for this patch. |
@jonathandturner Nice!
Are there any syntax-[breaking-changes] left? If so, what are they? |
@jseyfried - Ah good point. In theory, this should be source compatible with what we had before, though I'm not 100% sure (a fair bit got moved around). Still might be worth batching with breaking changes... |
@Manishearth what do you think? |
We still have the batch going on; @jseyfried want to finish it? Make a PR that includes this and send it to try. We can merge it tomorrow. |
@Manishearth I'll finish up #34424 (and include #34436) in a couple of hours. |
…excrichton This PR refactors the 'errors' part of libsyntax into its own crate (librustc_errors). This is the first part of a few refactorings to simplify error reporting and potentially support more output formats (like a standardized JSON output and possibly an --explain mode that can work with the user's code), though this PR stands on its own and doesn't assume further changes. As part of separating out the errors crate, I have also refactored the code position portion of codemap into its own crate (libsyntax_pos). While it's helpful to have the common code positions in a separate crate for the new errors crate, this may also enable further simplifications in the future.
Batch up libsyntax breaking changes Batch of the following syntax-[breaking-change] changes: - #34213: Add a variant `Macro` to `TraitItemKind` - #34368: Merge the variant `QPath` of `PatKind` into the variant `PatKind::Path` - #34385: Move `syntax::ast::TokenTree` into a new module `syntax::tokenstream` - #33943: - Remove the type parameter from `visit::Visitor` - Remove `attr::WithAttrs` -- use `attr::HasAttrs` instead. - Change `fold_tt`/`fold_tts` to take token trees by value and avoid wrapping token trees in `Rc`. - Remove the field `ctxt` of `ast::Mac_` - Remove inherent method `attrs()` of types -- use the method `attrs` of `HasAttrs` instead. - #34316: - Remove `ast::Decl`/`ast::DeclKind` and add variants `Local` and `Item` to `StmtKind`. - Move the node id for statements from the `StmtKind` variants to a field of `Stmt` (making `Stmt` a struct instead of an alias for `Spanned<StmtKind>`) - Rename `ast::ExprKind::Again` to `Continue`. - #34339: Generalize and abstract `ThinAttributes` to `ThinVec<Attribute>` - Use `.into()` in convert between `Vec<Attribute>` and `ThinVec<Attribute>` - Use autoderef instead of `.as_attr_slice()` - #34436: Remove the optional expression from `ast::Block` and instead use a `StmtKind::Expr` at the end of the statement list. - #34403: Move errors into a separate crate (unlikely to cause breakage)
Batch up libsyntax breaking changes Batch of the following syntax-[breaking-change] changes: - #34213: Add a variant `Macro` to `TraitItemKind` - #34368: Merge the variant `QPath` of `PatKind` into the variant `PatKind::Path` - #34385: Move `syntax::ast::TokenTree` into a new module `syntax::tokenstream` - #33943: - Remove the type parameter from `visit::Visitor` - Remove `attr::WithAttrs` -- use `attr::HasAttrs` instead. - Change `fold_tt`/`fold_tts` to take token trees by value and avoid wrapping token trees in `Rc`. - Remove the field `ctxt` of `ast::Mac_` - Remove inherent method `attrs()` of types -- use the method `attrs` of `HasAttrs` instead. - #34316: - Remove `ast::Decl`/`ast::DeclKind` and add variants `Local` and `Item` to `StmtKind`. - Move the node id for statements from the `StmtKind` variants to a field of `Stmt` (making `Stmt` a struct instead of an alias for `Spanned<StmtKind>`) - Rename `ast::ExprKind::Again` to `Continue`. - #34339: Generalize and abstract `ThinAttributes` to `ThinVec<Attribute>` - Use `.into()` in convert between `Vec<Attribute>` and `ThinVec<Attribute>` - Use autoderef instead of `.as_attr_slice()` - #34436: Remove the optional expression from `ast::Block` and instead use a `StmtKind::Expr` at the end of the statement list. - #34403: Move errors into a separate crate (unlikely to cause breakage)
☔ The latest upstream changes (presumably #34424) made this pull request unmergeable. Please resolve the merge conflicts. |
@jonathandturner I believe this didn't get automatically marked as merged because of the above commit you added. |
So I can start my part of the work! :D |
Simplify librustc_errors This is part 2 of the error crate refactor, starting with #34403. In this refactor, I focused on slimming down the error crate to fewer moving parts. As such, I've removed quite a few parts and replaced the with simpler, straight-line code. Specifically, this PR: * Removes BasicEmitter * Remove emit from emitter, leaving emit_struct * Renames emit_struct to emit * Removes CoreEmitter and focuses on a single Emitter * Implements the latest changes to error format RFC (#1644) * Removes (now-unused) code in emitter.rs and snippet.rs * Moves more tests to the UI tester, removing some duplicate tests in the process There is probably more that could be done with some additional refactoring, but this felt like it was getting to a good state. r? @alexcrichton cc: @Manishearth (as there may be breaking changes in stuff I removed/changed)
This PR refactors the 'errors' part of libsyntax into its own crate (librustc_errors). This is the first part of a few refactorings to simplify error reporting and potentially support more output formats (like a standardized JSON output and possibly an --explain mode that can work with the user's code), though this PR stands on its own and doesn't assume further changes.
As part of separating out the errors crate, I have also refactored the code position portion of codemap into its own crate (libsyntax_pos). While it's helpful to have the common code positions in a separate crate for the new errors crate, this may also enable further simplifications in the future.
r? @alexcrichton