Skip to content

Various fixes in macro code. - #1606

Closed
kevina wants to merge 7 commits into
rust-lang:masterfrom
kevina:macro-fixup
Closed

Various fixes in macro code.#1606
kevina wants to merge 7 commits into
rust-lang:masterfrom
kevina:macro-fixup

Conversation

@kevina

Copy link
Copy Markdown
Contributor

Correctly fixes Issue #1362. Fixes#1387 and #1448.

See the bug reports and commit messages for details.

Note my work on a #rust as discussed with Graydon will depend on these commits.

@kevina

Copy link
Copy Markdown
ContributorAuthor

This code should't have any portability problems, but just in case can you please test it on the build bots before merging. Thanks.

@brson

Copy link
Copy Markdown
Contributor

This fixes several issues but doesn't appear to include regression tests. Can you add some compile-fail tests for the two issues this closes? They will include probably an //! ERROR comment indicating where the error should appear, and should include a comment linking them to the issue they test. See https://github.com/mozilla/rust/wiki/Note-testsuite for details about how the tests work.

@kevina

Copy link
Copy Markdown
ContributorAuthor

Note: Please don't accept until I give the all clear. Want to rebase now after some more testing...

Need a better fix, right now it is just causing even more confusion,
for example in issue rust-lang#1448 and rust-lang#1387.
This reverts commit 1e4de33.
This correctly fixes issue rust-lang#1362.
chpos/byte_pos are now the offsets within a particular file, but
rather the offsets within a virtual file with is formed by combing all
of the modules within a crate. Thus, resetting them to 0 causes an
overlap and hence, bogus source locations.
Fixrust-lang#1362 by moving chpos/byte_pos to parse_sess so that
new_parser_from_source_str has access to them and hence can chose an
initial value that is not already been used in the crate.
Note that the trigger for bug 1361 was that syntax/ext/expand.rs calls
parse_expr_from_source_str (which calls new_parser_from_source_str)
using the same codemap as the current crate (and hence causing overlap
with files in the crate as new_parser_from_source_str resets the
chpos/byte_pos to 0).
This involved changing the prototype for the callbacks to thread the
span though. A wrapper function, fold::wrap, can be used to wrap the
old style callbacks.
the replacement and not the span of the pattern variable.
Fixes issue rust-lang#1448, and rust-lang#1387.
@kevina

Copy link
Copy Markdown
ContributorAuthor

Okay, ready to be accepted.

I fixed the bug brson pointed out on IRC and it looks like it passed the build bot build, but just in case please try it on the build-bots again accepting.

@kevina

Copy link
Copy Markdown
ContributorAuthor

Still ready to go, just rebased to fix an incorrect issue reference in the commit message.

Although its not really needed. Without that fix, reported spans will
likely be bogus if the error is within the first couple of lines
(probable around 5) of that file. Thus, many of the compile-fail
tests will fail due to incorrect location.
@brson

Copy link
Copy Markdown
Contributor

This looks good to me. Pushing to try one last time.

@brson

Copy link
Copy Markdown
Contributor

It's in!

@brsonbrson closed this Jan 24, 2012
U007D pushed a commit to U007D/rust-mos that referenced this pull request Aug 21, 2026
1606: Add `if let`, `while let` and match arm inlay hints r=matklad a=SomeoneToIgnore
<img width="693" alt="image" src="https://user-images.githubusercontent.com/2690773/62013363-152f1d80-b19a-11e9-90ea-07568757baa2.png">
Add more inline hints support.
Looks like `while let` type inference support is missing currently, so the corresponding hint tests lack the actual results.
I've also could not find a good way to distinguish between `a` and `b` pats in the following expressions:
`if let Some(Test { a: None, b: y }) = &test {};`
In this case we don't need to add a hint for first pat (`a: None`), since it's matched against the particular enum variant and need a hint for `y`, since it's a new variable.
But both `a` and `b` are `BIND_PAT` with similar contents, so looks like there's nothing I can check for to find any differences.
I don't display any hints for such cases now, to avoid confusion, but would be nice to know if there's a way to fix this behavior.
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
U007D pushed a commit to U007D/rust-mos that referenced this pull request Aug 21, 2026
Sign up for freeto 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.

invalid location with #debug type error

2 participants

@kevina@brson