diff options
| author | Michael Goulet <michael@errs.io> | 2025-06-18 17:57:22 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-06-25 15:42:11 +0000 |
| commit | 8cd3fa04e2e023967cf2cfe3e4170b636fd25019 (patch) | |
| tree | 42fc183b7cee5f294bde109c934bf417619062f0 /compiler/rustc_expand/src/expand.rs | |
| parent | 2801f9aaf9b7580d9b230b532b0700709857cc88 (diff) | |
| download | rust-8cd3fa04e2e023967cf2cfe3e4170b636fd25019.tar.gz rust-8cd3fa04e2e023967cf2cfe3e4170b636fd25019.zip | |
Don't give APITs names with macro expansion placeholder fragments in it
Diffstat (limited to 'compiler/rustc_expand/src/expand.rs')
| -rw-r--r-- | compiler/rustc_expand/src/expand.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index 0474413e762..2de09aa1a28 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -1778,6 +1778,16 @@ impl InvocationCollectorNode for ast::Ty { fragment.make_ty() } fn walk(&mut self, collector: &mut InvocationCollector<'_, '_>) { + // Save the pre-expanded name of this `ImplTrait`, so that later when defining + // an APIT we use a name that doesn't have any placeholder fragments in it. + if let ast::TyKind::ImplTrait(..) = self.kind { + // HACK: pprust breaks strings with newlines when the type + // gets too long. We don't want these to show up in compiler + // output or built artifacts, so replace them here... + // Perhaps we should instead format APITs more robustly. + let name = Symbol::intern(&pprust::ty_to_string(self).replace('\n', " ")); + collector.cx.resolver.insert_impl_trait_name(self.id, name); + } walk_ty(collector, self) } fn is_mac_call(&self) -> bool { |
