Skip to content
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

Do not panic when analyzing the malformed origin of a format string #10401

Merged
merged 1 commit into from
Feb 25, 2023

Conversation

samueltardieu
Copy link
Contributor

@samueltardieu samueltardieu commented Feb 25, 2023

Fixes #10148. This will trigger only when generating format strings while accepting weird things in a procedural macro and setting the span to something which is not a string.

changelog: none

@rustbot
Copy link
Collaborator

rustbot commented Feb 25, 2023

r? @Alexendoo

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 25, 2023
@Alexendoo
Copy link
Member

Thanks!

We have a nice utility for testing proc macro weirdness, you can add

// aux-build: proc_macro_with_span.rs

#[macro_use]
extern crate proc_macro_with_span;

to tests/ui/format.rs or a similar file, and test it with

with_span!(""something format!(""));

@samueltardieu
Copy link
Contributor Author

We have a nice utility for testing proc macro weirdness

Nice indeed! I've added a test, without even having to write a proc_macro, confirmed panicking before this patch.

@Alexendoo
Copy link
Member

Great, thanks again!

@bors r+

@bors
Copy link
Contributor

bors commented Feb 25, 2023

📌 Commit 64775f3 has been approved by Alexendoo

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Feb 25, 2023

⌛ Testing commit 64775f3 with merge 5155119...

@bors
Copy link
Contributor

bors commented Feb 25, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Alexendoo
Pushing 5155119 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'rustc' panicked at 'EscapeOnlyChar'
4 participants