Uh oh!
There was an error while loading. Please reload this page.
Move E0379 check from typeck to ast validation - #35480
Conversation
There was a problem hiding this comment.
Someone should double-check this - make_items should cover the case for macro trait impl fns and trait fns, so when make_impl_items is called, we can be certain that this is going to be a plain impl (i.e. impl without traits), hence this here is false.
petrochenkov
commented
Aug 8, 2016
@KiChjang |
a552d03 to
7912ae2CompareKiChjang
commented
Aug 10, 2016
Moved the error from the parser to the ast validator. |
KiChjang
commented
Aug 10, 2016
There was a problem hiding this comment.
can you add an assertion here that the fn is not const? (and maybe a comment pointing out that this is checked in the AST validator?)
There was a problem hiding this comment.
But that will cause ICEs in erroneous code - the error in the validation pass is not fatal and compilation continues until type checking is done.
There was a problem hiding this comment.
Yes, this would cause an ICE with const unsafe fn.
nikomatsakis
commented
Aug 10, 2016
nikomatsakis
commented
Aug 10, 2016
Yes, that is generally in the parser (and, in that context, it's ok to do subtraction of this kind, though always a bit sketchy -- but in any case there we know that macro expansion hasn't happened yet, so the spans of different files and so forth are not mixed up). If you look in the parser, you'll see that it tracks If we wanted to track the span of just this keyword, then, I would probably change the AST to have |
nikomatsakis
commented
Aug 10, 2016
OK, sorry, forget the assertions, you're right :) |
nikomatsakis
commented
Aug 10, 2016
In that case, can you just add some comments? |
nikomatsakis
commented
Aug 10, 2016
Meh, I guess that's not necessary. |
(To be clear, I'd still like to see the "span munging" changed.) |
KiChjang
commented
Aug 10, 2016
Just a heads up, I've changed my mind. I'll be incorporating the changes to make |
KiChjang
commented
Aug 10, 2016
Okay, I've made it so that all |
nikomatsakis
commented
Aug 11, 2016
@KiChjang this all looks good; one thought is that if you convert the test into a What do you think? |
petrochenkov
commented
Aug 11, 2016
Adding a span to constness seems pretty random. Why does it have a span while |
sophiajt
commented
Aug 11, 2016
@petrochenkov - there can be multiple PRs that address different issues, so a later PR could add a span to cc @nikomatsakis - since we were just chatting about AST nodes getting spans. There may be a cost, which hopefully we can detect and address it if any exists, but the ergonomics of being able to have the spans and give better error messages is helpful. |
KiChjang
commented
Aug 11, 2016
@nikomatsakis I'm fine with adding them to this PR, but I think we'll need to make it so that everyone working on #35233 should also write UI tests, if they have tightened the spans for some errors. |
nikomatsakis
commented
Aug 11, 2016
@petrochenkov we are already somewhat inconsistent about where we include spans -- e.g., we sometimes put spans on identifiers, sometimes not. It seems... ok to me. |
KiChjang
commented
Aug 17, 2016
Dummy spans removed from |
nikomatsakis
commented
Aug 18, 2016
@bors r+ |
bors
commented
Aug 18, 2016
📌 Commit 9fae2f3 has been approved by |
KiChjang
commented
Aug 18, 2016
Rebased. |
sophiajt
commented
Aug 19, 2016
Huh, looks like a test in the |
KiChjang
commented
Aug 19, 2016
Fixed the unit test in the latest force-push. |
sophiajt
commented
Aug 22, 2016
@bors r+ rollup |
bors
commented
Aug 22, 2016
📌 Commit b5b667d has been approved by |
sophiajt
commented
Aug 22, 2016
@bors r=nikomatsakis |
bors
commented
Aug 22, 2016
💡 This pull request was already approved, no need to approve it again.
|
bors
commented
Aug 22, 2016
📌 Commit b5b667d has been approved by |
jseyfried
commented
Aug 22, 2016
@bors r- |
Move E0379 check from typeck to ast validation Part of rust-lang#35233. Extension of rust-lang#35338, rust-lang#35364. Fixesrust-lang#35404.
Batch up libsyntax breaking changes Batch of the following syntax-[breaking-change] changes: - #35591: Add a field `span: Span` to `ast::Generics`. - #35618: Remove variant `Mod` of `ast::PathListItemKind` and refactor the remaining variant `ast::PathListKind::Ident` to a struct `ast::PathListKind_`. - #35480: Change uses of `Constness` in the AST to `Spanned<Constness>`. - c.f. `MethodSig`, `ItemKind` - #35728: Refactor `cx.pat_enum()` into `cx.pat_tuple_struct()` and `cx.pat_path()`. - #35850: Generalize the elements of lists in attributes from `MetaItem` to a new type `NestedMetaItem` that can represent a `MetaItem` or a literal. - #35917: Remove traits `AttrMetaMethods`, `AttributeMethods`, and `AttrNestedMetaItemMethods`. - Besides removing imports of these traits, this won't cause fallout. - Add a variant `Union` to `ItemKind` to future proof for `union` (c.f. #36016). - Remove inherent methods `attrs` and `fold_attrs` of `Annotatable`. - Use methods `attrs` and `map_attrs` of `HasAttrs` instead. r? @Manishearth
Part of #35233.
Extension of #35338, #35364.
Fixes#35404.
r? @jonathandturner