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

Rustc 1.79.0 #1173

Merged
merged 10 commits into from
Oct 31, 2024
Merged

Rustc 1.79.0 #1173

merged 10 commits into from
Oct 31, 2024

Conversation

utaal
Copy link
Collaborator

@utaal utaal commented Jun 22, 2024

This has taken a while but I think it's almost there.

After merging main there's this issue which I think is related to treating the marker trait specially for erasure:
(solved, see below)

trait T3254_Pointee {
    type A3255_Metadata : T3256_Freeze+T3249_Debug+T3176_Hash+T3253_Ord+T3252_PartialOrd<<Self as T3254_Pointee>::A3255_Metadata, >+T3251_PartialEq<<Self as T3254_Pointee>::A3255_Metadata, >+T3175_Eq+T3245_Clone+?Sized;
}

error[E0405]: cannot find trait `T3256_Freeze` in this scope
   --> dummyrs.rs:263:27
    |
263 |     type A3255_Metadata : T3256_Freeze+T3249_Debug+T3176_Hash+T3253_Ord+T3252_PartialOrd<<Self as T3254_Pointee>::A3255_Metadata, >+T3251...
    |                           ^^^^^^^^^^^^ not found in this scope

@ziqiaozhou
Copy link
Collaborator

This has taken a while but I think it's almost there.

After merging main there's this issue which I think is related to treating the marker trait specially for erasure:

trait T3254_Pointee {
    type A3255_Metadata : T3256_Freeze+T3249_Debug+T3176_Hash+T3253_Ord+T3252_PartialOrd<<Self as T3254_Pointee>::A3255_Metadata, >+T3251_PartialEq<<Self as T3254_Pointee>::A3255_Metadata, >+T3175_Eq+T3245_Clone+?Sized;
}

error[E0405]: cannot find trait `T3256_Freeze` in this scope
   --> dummyrs.rs:263:27
    |
263 |     type A3255_Metadata : T3256_Freeze+T3249_Debug+T3176_Hash+T3253_Ord+T3252_PartialOrd<<Self as T3254_Pointee>::A3255_Metadata, >+T3251...
    |                           ^^^^^^^^^^^^ not found in this scope

@utaal, the freeze issue could be fixed by adding the external specification for Freeze trait in vstd. ziqiaozhou@7e824a2

@utaal utaal marked this pull request as ready for review October 28, 2024 19:21
@utaal
Copy link
Collaborator Author

utaal commented Oct 28, 2024

Thank you for the pointer @ziqiaozhou!

@ziqiaozhou
Copy link
Collaborator

ziqiaozhou commented Oct 28, 2024

I deleted my prior comment since I was thinking that error was due to other reasons, since the error only happens in a large project where the code may use some new features. The error disappears if I extract that specific chunk of code out. Later on, I realized that it is fixable by const_header_wrapper.

To support that in the new macro, I need to change the rewrite similar to the change in syntax.rs. I just lazily set that const_header_wrapper for all spec function calls. I think we can just set it by default no matter whether the function is const or non-const. I also noticed that some macros rely on syntax::rewrite_expr or proof_block or others will need to set is_const: true as default.

ziqiaozhou@ae239c6

@utaal
Copy link
Collaborator Author

utaal commented Oct 30, 2024

@Chris-Hawblitzel ran veritas and found that my fixes for the new const rules are not sufficient, specifically for this case, from https://github.com/utaal/verified-nrkernel

pub exec const x86_arch_exec: ArchExec ensures x86_arch_exec@ == x86_arch_spec {
    let layers = [
        ArchLayerExec { entry_size: L0_ENTRY_SIZE, num_entries: 512 },
        ArchLayerExec { entry_size: L1_ENTRY_SIZE, num_entries: 512 },
        ArchLayerExec { entry_size: L2_ENTRY_SIZE, num_entries: 512 },
        ArchLayerExec { entry_size: L3_ENTRY_SIZE, num_entries: 512 },
    ];
    assert(x86_arch_spec.layers =~= layers@.map(|n,e:ArchLayerExec| e@));
    ArchExec { layers }
}

where there is a mix of proof code, which should be allowed to call anything, and exec code which should conform to the const rules. At the moment I don't know how we can address this.

Comment on lines +2774 to +2778
// Do not actually evaluate consts if we are not compiling, as doing so triggers the
// constness checker, which is more restrictive than necessary for verification.
// Doing this will delay some const-ness errors to when verus is run with `--compile`.
providers.eval_to_const_value_raw =
|_tcx, _key| Ok(rustc_middle::mir::ConstValue::ZeroSized);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Chris-Hawblitzel I did this, which is quite heavy-handed, but seems to work.

@utaal utaal merged commit d830b89 into main Oct 31, 2024
11 checks passed
@utaal utaal deleted the rustc-1.79.0 branch October 31, 2024 06:42
utaal added a commit to principled-systems/verus that referenced this pull request Nov 21, 2024
* port to rust 1.79.0

* fix vstd error in pointer missing Freeze

* prevent const-eval from failing 32-bit usize tests

* additional fix for const bodies that mix exec and proof code

---------

Co-authored-by: Ziqiao Zhou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants