Skip to content

fixed indentation in AST pretty printed expanded dump of trait. - #1810

Merged
bors[bot] merged 1 commit into
Rust-GCC:masterfrom
00AR:bug-1785
Feb 10, 2023
Merged

bors[bot] merged 1 commit into
Rust-GCC:masterfrom
00AR:bug-1785

Conversation

@00AR

@00AR 00AR commented Feb 1, 2023

Copy link
Copy Markdown
Contributor

fixes #1785

Signed-off-by: Abdul Rafey abdulrafeyq@gmail.com

In Dump::visit (TraitImpl), the for loop adds indentation before calling visit () on every iteration. I think when Dump::visit (Method) is executed it adds extra indentation on top of it.

@CohenArthur

Copy link
Copy Markdown
Member

@00AR this is the output I get when running your commit on the testcase in #1785:

#[lang = "clone"]
trait Copy{
		fn clone(&self) -> Self;

		fn clone_from(& mut self, source: &Self)
}

there's still one extra indentation level.

I think the changes you need to make are within the Trait visitor, so Dump::visit(Trait &trait). There is probably an extra indentation.increment() somewhere. Hope it's not too annoying to fix haha :D

Let me know if you'd like any tips or if anything in the code is unclear.

@00AR

00AR commented Feb 1, 2023

Copy link
Copy Markdown
Contributor Author

It was strange at first because it gave correct output on my system. But I may have undid this second change(Sorry!) because the lines looks exactly the same without building gccrs freshly 😅
This is the output now : -
image

Let me know if you'd like any tips or if anything in the code is unclear.

@CohenArthur Thanks! I will surely ask on Zulip :)

@CohenArthur

Copy link
Copy Markdown
Member

@00AR here's a simpler testcase which should help you:

trait Foo {
    fn a();
    fn b(&self);
}

impl Foo for i32 {
    fn a() {}
    fn b(&self) {}
}

On master branch, the output is as follows:

trait Foo{
		fn a() ;

		fn b(&self) ;

}

impl Foo for i32 {
	fn a() {
	}

		fn b(&self) {
	}


}

with this PR:

trait Foo{
		fn a() ;

	fn b(&self) ;

}

impl Foo for i32 {
	fn a() {
	}

	fn b(&self) {
	}


}

so you fixed almost all of the issues :) thank you

@00AR

00AR commented Feb 2, 2023

Copy link
Copy Markdown
Contributor Author

I am learning rust in parallel to make new relevant testcases for the future changes I will make.
Also, this Changelog check, is it relevant for this PR?

@CohenArthur

Copy link
Copy Markdown
Member

I am learning rust in parallel to make new relevant testcases for the future changes I will make.

Nice :D Thanks for getting into this :)

Also, this Changelog check, is it relevant for this PR?

Yes, moving forward all commits will need to conform to the GNU guidelines. We're putting together automation to make the process less painful.

@CohenArthur

Copy link
Copy Markdown
Member

@00AR if you're done with this PR let me know and I'll post the Changelog content here for you to add to your commit. Then, we can merge this.

@00AR

00AR commented Feb 3, 2023

Copy link
Copy Markdown
Contributor Author

@CohenArthur Thanks. I will ping you once I finish testing some other parts that I suspect may also need some correction.

@00AR

00AR commented Feb 8, 2023

Copy link
Copy Markdown
Contributor Author

@CohenArthur You can merge this PR when you get time.
My eyes couldn't find any more indentations to remove but this PR has helped me in getting started with HIR dump project ;-)
I was able to add a small change to HIR dump comfortably. I will focus on making a GSOC proposal for the same. I also have some questions now :D

@CohenArthur

Copy link
Copy Markdown
Member

Great stuff @00AR thank you! The one thing remaining for you is to add a Changelog to your commit according to the following structure:

gcc/rust/ChangeLog:

	* ast/rust-ast-dump.cc (Dump::visit):

Also, feel free to ping me on Zulip and ask your questions :)

@CohenArthur

Copy link
Copy Markdown
Member

The Changelog needs to sit above the Signed-off-by line. Then we can merge this PR :)

@00AR
00AR force-pushed the bug-1785 branch 2 times, most recently from f66ee53 to 8c4ab3d Compare February 9, 2023 15:07
…geLog:

	* ast/rust-ast-dump.cc (Dump::visit): removed extra indentations in trait ast dump

Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
@CohenArthur

Copy link
Copy Markdown
Member

bors r+

@philberty philberty added the bug label Feb 10, 2023
@philberty philberty added this to the Final upstream patches milestone Feb 10, 2023
@bors
bors Bot merged commit 0d5d7a6 into Rust-GCC:master Feb 10, 2023
@bors

bors Bot commented Feb 10, 2023

Copy link
Copy Markdown
Contributor

@00AR
00AR deleted the bug-1785 branch April 6, 2023 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Bad formatting in AST pretty printed expanded dump

3 participants