-
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
Keep track of the start of the argument block of a closure #104199
Conversation
Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt |
Yes this will almost certainly be problematic (especially looking at the diff to the rustfmt source) and should be reverted |
8e10fa7
to
591a2fe
Compare
@calebcartwright I removed the formatting. |
☔ The latest upstream changes (presumably #101562) made this pull request unmergeable. Please resolve the merge conflicts. |
591a2fe
to
1247ce6
Compare
☔ The latest upstream changes (presumably #104776) made this pull request unmergeable. Please resolve the merge conflicts. |
1247ce6
to
2db3f64
Compare
compiler/rustc_ast/src/ast.rs
Outdated
@@ -1282,6 +1282,7 @@ pub struct Closure { | |||
pub body: P<Expr>, | |||
/// The span of the argument block `|...|`. |
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.
Could you correct the comment to mention it contains the eventual move
too?
compiler/rustc_ast/src/ast.rs
Outdated
@@ -1282,6 +1282,7 @@ pub struct Closure { | |||
pub body: P<Expr>, | |||
/// The span of the argument block `|...|`. | |||
pub fn_decl_span: Span, | |||
pub cl_pipe_start: BytePos, |
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.
Could you add a comment?
Should we just have a span for move || -> ty
and one for just ||
?
Like fn_arg_span
you made for HIR.
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 wrote this before #101562 to try to minimize the size of ast::Expr
. Now that ast::Closure
is boxed inside ast::Expr
I agree changing this to the span of |...|
will be better.
@@ -639,6 +642,8 @@ impl<'hir> LoweringContext<'_, 'hir> { | |||
fn_decl, | |||
body, | |||
fn_decl_span: self.lower_span(span), | |||
// FIXME(SarthakSingh31): This span needs to only span the arguments but it doesn't |
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.
This span comes from a desugaring, nothing corresponds to the arguments.
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.
Made the hir::Closure::fn_arg_span
Option<Span>
to better represent this
2db3f64
to
8f705e2
Compare
Thanks @SarthakSingh31. |
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#104199 (Keep track of the start of the argument block of a closure) - rust-lang#105050 (Remove useless borrows and derefs) - rust-lang#105153 (Create a hacky fail-fast mode that stops tests at the first failure) - rust-lang#105164 (Restore `use` suggestion for `dyn` method call requiring `Sized`) - rust-lang#105193 (Disable coverage instrumentation for naked functions) - rust-lang#105200 (Remove useless filter in unused extern crate check.) - rust-lang#105201 (Do not call fn_sig on non-functions.) - rust-lang#105208 (Add AmbiguityError for inconsistent resolution for an import) - rust-lang#105214 (update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…gillot Keep track of the start of the argument block of a closure This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by rust-lang#97417. VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem. r? `@cjgillot`
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#104199 (Keep track of the start of the argument block of a closure) - rust-lang#105050 (Remove useless borrows and derefs) - rust-lang#105153 (Create a hacky fail-fast mode that stops tests at the first failure) - rust-lang#105164 (Restore `use` suggestion for `dyn` method call requiring `Sized`) - rust-lang#105193 (Disable coverage instrumentation for naked functions) - rust-lang#105200 (Remove useless filter in unused extern crate check.) - rust-lang#105201 (Do not call fn_sig on non-functions.) - rust-lang#105208 (Add AmbiguityError for inconsistent resolution for an import) - rust-lang#105214 (update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…gillot Keep track of the start of the argument block of a closure This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by rust-lang#97417. VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem. r? `@cjgillot`
This removes a call to
tcx.sess.source_map()
from compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs as required by #97417.VsCode automatically applied
rustfmt
to the files I edited undersrc/tools
. I can undo that if its a problem.r? @cjgillot