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

Use debug impl in rendering const eval result #15230

Merged
merged 1 commit into from Jul 7, 2023
Merged

Conversation

HKalbasi
Copy link
Member

@HKalbasi HKalbasi commented Jul 7, 2023

fix #15188

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 7, 2023
@HKalbasi
Copy link
Member Author

HKalbasi commented Jul 7, 2023

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 7, 2023

📌 Commit 2c57a2d has been approved by HKalbasi

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jul 7, 2023

⌛ Testing commit 2c57a2d with merge 0af727f...

bors added a commit that referenced this pull request Jul 7, 2023
Use debug impl in rendering const eval result

fix #15188
@bors
Copy link
Collaborator

bors commented Jul 7, 2023

💔 Test failed - checks-actions

@HKalbasi
Copy link
Member Author

HKalbasi commented Jul 7, 2023

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 7, 2023

📌 Commit f0ba0db has been approved by HKalbasi

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jul 7, 2023

⌛ Testing commit f0ba0db with merge db0add1...

@bors
Copy link
Collaborator

bors commented Jul 7, 2023

☀️ Test successful - checks-actions
Approved by: HKalbasi
Pushing db0add1 to master...

@bors bors merged commit db0add1 into rust-lang:master Jul 7, 2023
8 checks passed
@Veykril
Copy link
Member

Veykril commented Jul 8, 2023

Fwiw, this fails on latest nightly in general. (And on stable my code that spawned this idea also fails on a specific debug impl, though I guess that is to be expected).

@HKalbasi
Copy link
Member Author

HKalbasi commented Jul 8, 2023

Fwiw, this fails on latest nightly in general.

That's bad. I tried to make it working. Will look at it.

also fails on a specific debug impl

I may be able to fix it if I know the problem. You can see why it fails by using the Interpret Function command on a function containing format!("{:?}", C).

@Veykril
Copy link
Member

Veykril commented Jul 8, 2023

Mir eval error:
In function f (FunctionId(19684))
In function format (FunctionId(18759))
In ClosureId(39)
file://C:\Users\lukas\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\option.rs#1193:20
In function format (FunctionId(18759))
In function format_inner (FunctionId(55204))
file://C:\Users\lukas\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\fmt.rs#612:8
In function write_fmt (FunctionId(29913))
In function write (FunctionId(12864))
file://C:\Users\lukas\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\fmt\mod.rs#1244:10
In function fmt (FunctionId(19811))
file://c:\workspace\rust\glaive\crates\parser\src\token_set.rs#61:20
In function next (FunctionId(28724))
In function spec_next (FunctionId(28712))
file://C:\Users\lukas\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\iter\range.rs#539:38
In function replace (FunctionId(12702))
NotSupported("unknown intrinsic read_via_copy")

Clearly something is going very much wrong here. The problem manifest iwth the following debu impl

impl fmt::Debug for TokenSet {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "TokenSet(")?;
        let mut first = true;
        for kind in 0..SyntaxKind::LAST_TOKEN.to_raw().0 {
            // let kind = SyntaxKind::from_raw(rowan::RawSyntaxKind(kind));
            // if self.contains(kind) {
            //     if first {
            //         first = false;
            //     } else {
            //         f.write_str(" | ")?;
            //     }
            //     write!(f, "{:?}", kind)?;
            // }
        }
        write!(f, ")")?;
        Ok(())
    }
}

Commenting out the loop makes it pass. Seems like just havin a for kind in 0..10 {} fails with the intrinsic

@HKalbasi
Copy link
Member Author

HKalbasi commented Jul 8, 2023

Ah, I'm using a patched std from 1.69, and this read_via_copy stuff is added in 1.70 so doesn't exists in my world. I will try to bump my std to 1.70 in following days. read_via_copy on its own is very trivial, but it might be tip of the iceberg.

@HKalbasi
Copy link
Member Author

HKalbasi commented Jul 9, 2023

It seems the only problem was read_via_copy and after #15244 mir interpreter should work with its full power on stable, so you can try again. On nightly it seems there is a more serious problem, something in the allocator is broken, so vector doesn't work, string which is just a Vec<u8> doesn't work, and so std::fmt::format doesn't work. Will look at it.

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.

Hover on constants should render the display/debug impl if available
4 participants