Skip to content

Fix Bad formatting in AST expanded dump with associated types#2122

Merged
CohenArthur merged 1 commit into
Rust-GCC:masterfrom
ArberSephirotheca:ast_dump_associated_type
Apr 20, 2023
Merged

Fix Bad formatting in AST expanded dump with associated types#2122
CohenArthur merged 1 commit into
Rust-GCC:masterfrom
ArberSephirotheca:ast_dump_associated_type

Conversation

@ArberSephirotheca

@ArberSephirotheca ArberSephirotheca commented Apr 13, 2023

Copy link
Copy Markdown
Contributor

gcc/rust/ChangeLog:

    * ast/rust-ast-dump.cc: implement visit() function for QualifiedPathInType.
                            Fixed bad formatting of type alias in ast dump.

Fixes #2023

Output of AST expanded dump when running the code the linked issue:

macro_rules! forward_ref_binop{
	(impl $imp:ident , $method:ident for $t:ty , $u:ty) => 
		{ forward_ref_binop ! ( impl $ imp , $ method for $ t , $ u , # [ stable ( feature = "rust1" , since = "1.0.0" ) ] ) ; }
	;
	(impl $imp:ident , $method:ident for $t:ty , $u:ty , # [$attr:meta]) => 
		{ # [ $ attr ] impl < a > $ imp < $ u > for & a $ t { type Output = < $ t as $ imp < $ u >> :: Output ; # [ inline ] fn $ method ( self , other : $ u ) -> < $ t as $ imp < $ u >> :: Output { $ imp :: $ method ( * self , other ) } } # [ $ attr ] impl < a > $ imp < & a $ u > for $ t { type Output = < $ t as $ imp < $ u >> :: Output ; # [ inline ] fn $ method ( self , other : & a $ u ) -> < $ t as $ imp < $ u >> :: Output { $ imp :: $ method ( self , * other ) } } # [ $ attr ] impl < a , b > $ imp < & a $ u > for & b $ t { type Output = < $ t as $ imp < $ u >> :: Output ; # [ inline ] fn $ method ( self , other : & a $ u ) -> < $ t as $ imp < $ u >> :: Output { $ imp :: $ method ( * self , * other ) } } }
	;
}

#[lang = "add"]
pub trait Add{
		type Output;

	fn add(self, rhs: RHS) -> Self::Output;

}

macro_rules! add_impl{
	($($t:ty)*) => 
		( $ ( # [ stable ( feature = "rust1" , since = "1.0.0" ) ] impl Add for $ t { type Output = $ t ; fn add ( self , other : $ t ) -> $ t { self + other } } forward_ref_binop ! { impl Add , add for $ t , $ t } ) * )
	;
}

impl Add for usize {
	type Output = usize;
	fn add(self, other: usize) -> usize {
		self + other /* tail expr */

	}


}

impl Add<usize> for &'a usize {
	type Output = <usize as Add<usize>>::Output;
	fn add(self, other: usize) -> <usize as Add<usize>>::Output {
		Add::add(
			*self,
			other,
		) /* tail expr */

	}


}

impl Add<&'a usize> for usize {
	type Output = <usize as Add<usize>>::Output;
	fn add(self, other: &'a usize) -> <usize as Add<usize>>::Output {
		Add::add(
			self,
			*other,
		) /* tail expr */

	}


}

impl Add<&'a usize> for &'b usize {
	type Output = <usize as Add<usize>>::Output;
	fn add(self, other: &'a usize) -> <usize as Add<usize>>::Output {
		Add::add(
			*self,
			*other,
		) /* tail expr */

	}


}

impl Add for u8 {
	type Output = u8;
	fn add(self, other: u8) -> u8 {
		self + other /* tail expr */

	}


}

impl Add<u8> for &'a u8 {
	type Output = <u8 as Add<u8>>::Output;
	fn add(self, other: u8) -> <u8 as Add<u8>>::Output {
		Add::add(
			*self,
			other,
		) /* tail expr */

	}


}

impl Add<&'a u8> for u8 {
	type Output = <u8 as Add<u8>>::Output;
	fn add(self, other: &'a u8) -> <u8 as Add<u8>>::Output {
		Add::add(
			self,
			*other,
		) /* tail expr */

	}


}

impl Add<&'a u8> for &'b u8 {
	type Output = <u8 as Add<u8>>::Output;
	fn add(self, other: &'a u8) -> <u8 as Add<u8>>::Output {
		Add::add(
			*self,
			*other,
		) /* tail expr */

	}


}

impl Add for u16 {
	type Output = u16;
	fn add(self, other: u16) -> u16 {
		self + other /* tail expr */

	}


}

impl Add<u16> for &'a u16 {
	type Output = <u16 as Add<u16>>::Output;
	fn add(self, other: u16) -> <u16 as Add<u16>>::Output {
		Add::add(
			*self,
			other,
		) /* tail expr */

	}


}

impl Add<&'a u16> for u16 {
	type Output = <u16 as Add<u16>>::Output;
	fn add(self, other: &'a u16) -> <u16 as Add<u16>>::Output {
		Add::add(
			self,
			*other,
		) /* tail expr */

	}


}

impl Add<&'a u16> for &'b u16 {
	type Output = <u16 as Add<u16>>::Output;
	fn add(self, other: &'a u16) -> <u16 as Add<u16>>::Output {
		Add::add(
			*self,
			*other,
		) /* tail expr */

	}


}

impl Add for u32 {
	type Output = u32;
	fn add(self, other: u32) -> u32 {
		self + other /* tail expr */

	}


}

impl Add<u32> for &'a u32 {
	type Output = <u32 as Add<u32>>::Output;
	fn add(self, other: u32) -> <u32 as Add<u32>>::Output {
		Add::add(
			*self,
			other,
		) /* tail expr */

	}


}

impl Add<&'a u32> for u32 {
	type Output = <u32 as Add<u32>>::Output;
	fn add(self, other: &'a u32) -> <u32 as Add<u32>>::Output {
		Add::add(
			self,
			*other,
		) /* tail expr */

	}


}

impl Add<&'a u32> for &'b u32 {
	type Output = <u32 as Add<u32>>::Output;
	fn add(self, other: &'a u32) -> <u32 as Add<u32>>::Output {
		Add::add(
			*self,
			*other,
		) /* tail expr */

	}


}

impl Add for u64 {
	type Output = u64;
	fn add(self, other: u64) -> u64 {
		self + other /* tail expr */

	}


}

impl Add<u64> for &'a u64 {
	type Output = <u64 as Add<u64>>::Output;
	fn add(self, other: u64) -> <u64 as Add<u64>>::Output {
		Add::add(
			*self,
			other,
		) /* tail expr */

	}


}

impl Add<&'a u64> for u64 {
	type Output = <u64 as Add<u64>>::Output;
	fn add(self, other: &'a u64) -> <u64 as Add<u64>>::Output {
		Add::add(
			self,
			*other,
		) /* tail expr */

	}


}

impl Add<&'a u64> for &'b u64 {
	type Output = <u64 as Add<u64>>::Output;
	fn add(self, other: &'a u64) -> <u64 as Add<u64>>::Output {
		Add::add(
			*self,
			*other,
		) /* tail expr */

	}


}

impl Add for u128 {
	type Output = u128;
	fn add(self, other: u128) -> u128 {
		self + other /* tail expr */

	}


}

impl Add<u128> for &'a u128 {
	type Output = <u128 as Add<u128>>::Output;
	fn add(self, other: u128) -> <u128 as Add<u128>>::Output {
		Add::add(
			*self,
			other,
		) /* tail expr */

	}


}

impl Add<&'a u128> for u128 {
	type Output = <u128 as Add<u128>>::Output;
	fn add(self, other: &'a u128) -> <u128 as Add<u128>>::Output {
		Add::add(
			self,
			*other,
		) /* tail expr */

	}


}

impl Add<&'a u128> for &'b u128 {
	type Output = <u128 as Add<u128>>::Output;
	fn add(self, other: &'a u128) -> <u128 as Add<u128>>::Output {
		Add::add(
			*self,
			*other,
		) /* tail expr */

	}


}

impl Add for isize {
	type Output = isize;
	fn add(self, other: isize) -> isize {
		self + other /* tail expr */

	}


}

impl Add<isize> for &'a isize {
	type Output = <isize as Add<isize>>::Output;
	fn add(self, other: isize) -> <isize as Add<isize>>::Output {
		Add::add(
			*self,
			other,
		) /* tail expr */

	}


}

impl Add<&'a isize> for isize {
	type Output = <isize as Add<isize>>::Output;
	fn add(self, other: &'a isize) -> <isize as Add<isize>>::Output {
		Add::add(
			self,
			*other,
		) /* tail expr */

	}


}

impl Add<&'a isize> for &'b isize {
	type Output = <isize as Add<isize>>::Output;
	fn add(self, other: &'a isize) -> <isize as Add<isize>>::Output {
		Add::add(
			*self,
			*other,
		) /* tail expr */

	}


}

impl Add for i8 {
	type Output = i8;
	fn add(self, other: i8) -> i8 {
		self + other /* tail expr */

	}


}

impl Add<i8> for &'a i8 {
	type Output = <i8 as Add<i8>>::Output;
	fn add(self, other: i8) -> <i8 as Add<i8>>::Output {
		Add::add(
			*self,
			other,
		) /* tail expr */

	}


}

impl Add<&'a i8> for i8 {
	type Output = <i8 as Add<i8>>::Output;
	fn add(self, other: &'a i8) -> <i8 as Add<i8>>::Output {
		Add::add(
			self,
			*other,
		) /* tail expr */

	}


}

impl Add<&'a i8> for &'b i8 {
	type Output = <i8 as Add<i8>>::Output;
	fn add(self, other: &'a i8) -> <i8 as Add<i8>>::Output {
		Add::add(
			*self,
			*other,
		) /* tail expr */

	}


}

impl Add for i16 {
	type Output = i16;
	fn add(self, other: i16) -> i16 {
		self + other /* tail expr */

	}


}

impl Add<i16> for &'a i16 {
	type Output = <i16 as Add<i16>>::Output;
	fn add(self, other: i16) -> <i16 as Add<i16>>::Output {
		Add::add(
			*self,
			other,
		) /* tail expr */

	}


}

impl Add<&'a i16> for i16 {
	type Output = <i16 as Add<i16>>::Output;
	fn add(self, other: &'a i16) -> <i16 as Add<i16>>::Output {
		Add::add(
			self,
			*other,
		) /* tail expr */

	}


}

impl Add<&'a i16> for &'b i16 {
	type Output = <i16 as Add<i16>>::Output;
	fn add(self, other: &'a i16) -> <i16 as Add<i16>>::Output {
		Add::add(
			*self,
			*other,
		) /* tail expr */

	}


}

impl Add for i32 {
	type Output = i32;
	fn add(self, other: i32) -> i32 {
		self + other /* tail expr */

	}


}

impl Add<i32> for &'a i32 {
	type Output = <i32 as Add<i32>>::Output;
	fn add(self, other: i32) -> <i32 as Add<i32>>::Output {
		Add::add(
			*self,
			other,
		) /* tail expr */

	}


}

impl Add<&'a i32> for i32 {
	type Output = <i32 as Add<i32>>::Output;
	fn add(self, other: &'a i32) -> <i32 as Add<i32>>::Output {
		Add::add(
			self,
			*other,
		) /* tail expr */

	}


}

impl Add<&'a i32> for &'b i32 {
	type Output = <i32 as Add<i32>>::Output;
	fn add(self, other: &'a i32) -> <i32 as Add<i32>>::Output {
		Add::add(
			*self,
			*other,
		) /* tail expr */

	}


}

impl Add for i64 {
	type Output = i64;
	fn add(self, other: i64) -> i64 {
		self + other /* tail expr */

	}


}

impl Add<i64> for &'a i64 {
	type Output = <i64 as Add<i64>>::Output;
	fn add(self, other: i64) -> <i64 as Add<i64>>::Output {
		Add::add(
			*self,
			other,
		) /* tail expr */

	}


}

impl Add<&'a i64> for i64 {
	type Output = <i64 as Add<i64>>::Output;
	fn add(self, other: &'a i64) -> <i64 as Add<i64>>::Output {
		Add::add(
			self,
			*other,
		) /* tail expr */

	}


}

impl Add<&'a i64> for &'b i64 {
	type Output = <i64 as Add<i64>>::Output;
	fn add(self, other: &'a i64) -> <i64 as Add<i64>>::Output {
		Add::add(
			*self,
			*other,
		) /* tail expr */

	}


}

impl Add for i128 {
	type Output = i128;
	fn add(self, other: i128) -> i128 {
		self + other /* tail expr */

	}


}

impl Add<i128> for &'a i128 {
	type Output = <i128 as Add<i128>>::Output;
	fn add(self, other: i128) -> <i128 as Add<i128>>::Output {
		Add::add(
			*self,
			other,
		) /* tail expr */

	}


}

impl Add<&'a i128> for i128 {
	type Output = <i128 as Add<i128>>::Output;
	fn add(self, other: &'a i128) -> <i128 as Add<i128>>::Output {
		Add::add(
			self,
			*other,
		) /* tail expr */

	}


}

impl Add<&'a i128> for &'b i128 {
	type Output = <i128 as Add<i128>>::Output;
	fn add(self, other: &'a i128) -> <i128 as Add<i128>>::Output {
		Add::add(
			*self,
			*other,
		) /* tail expr */

	}


}

impl Add for f32 {
	type Output = f32;
	fn add(self, other: f32) -> f32 {
		self + other /* tail expr */

	}


}

impl Add<f32> for &'a f32 {
	type Output = <f32 as Add<f32>>::Output;
	fn add(self, other: f32) -> <f32 as Add<f32>>::Output {
		Add::add(
			*self,
			other,
		) /* tail expr */

	}


}

impl Add<&'a f32> for f32 {
	type Output = <f32 as Add<f32>>::Output;
	fn add(self, other: &'a f32) -> <f32 as Add<f32>>::Output {
		Add::add(
			self,
			*other,
		) /* tail expr */

	}


}

impl Add<&'a f32> for &'b f32 {
	type Output = <f32 as Add<f32>>::Output;
	fn add(self, other: &'a f32) -> <f32 as Add<f32>>::Output {
		Add::add(
			*self,
			*other,
		) /* tail expr */

	}


}

impl Add for f64 {
	type Output = f64;
	fn add(self, other: f64) -> f64 {
		self + other /* tail expr */

	}


}

impl Add<f64> for &'a f64 {
	type Output = <f64 as Add<f64>>::Output;
	fn add(self, other: f64) -> <f64 as Add<f64>>::Output {
		Add::add(
			*self,
			other,
		) /* tail expr */

	}


}

impl Add<&'a f64> for f64 {
	type Output = <f64 as Add<f64>>::Output;
	fn add(self, other: &'a f64) -> <f64 as Add<f64>>::Output {
		Add::add(
			self,
			*other,
		) /* tail expr */

	}


}

impl Add<&'a f64> for &'b f64 {
	type Output = <f64 as Add<f64>>::Output;
	fn add(self, other: &'a f64) -> <f64 as Add<f64>>::Output {
		Add::add(
			*self,
			*other,
		) /* tail expr */

	}


}


@ArberSephirotheca ArberSephirotheca force-pushed the ast_dump_associated_type branch 4 times, most recently from fd02831 to 776eda2 Compare April 14, 2023 00:08

@CohenArthur CohenArthur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide the output of the dump when running it on the code in the issue you linked? This way we'll see how it looks. I think this is great otherwise :)

Comment thread gcc/rust/ast/rust-ast-dump.cc Outdated
@ArberSephirotheca

Copy link
Copy Markdown
Contributor Author

Can you provide the output of the dump when running it on the code in the issue you linked? This way we'll see how it looks. I think this is great otherwise :)

No problem!

@P-E-P P-E-P left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like a few changes related to this settings file, otherwise the changes are good and I will be glad to approve this PR.

Comment thread gcc/rust/.vscode/settings.json Outdated
@ArberSephirotheca ArberSephirotheca force-pushed the ast_dump_associated_type branch from cdd9a9a to 5067c92 Compare April 15, 2023 13:38

@CohenArthur CohenArthur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :) Thanks!

Comment thread gcc/rust/ast/rust-ast-dump.cc Outdated
@P-E-P P-E-P mentioned this pull request Apr 17, 2023

@CohenArthur CohenArthur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thank you!

gcc/rust/ChangeLog:

	* ast/rust-ast-dump.cc: fix bad formatting for associated type.

Signed-off-by: Zheyuan Chen <sephirotheca17@gmail.com>
@ArberSephirotheca ArberSephirotheca force-pushed the ast_dump_associated_type branch from a68caf7 to e8e8434 Compare April 19, 2023 17:34

@philberty philberty left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@CohenArthur CohenArthur added this pull request to the merge queue Apr 20, 2023
Merged via the queue into Rust-GCC:master with commit 3013c40 Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Bad formatting in AST expanded dump with associated types

4 participants