Please teach copilot about size_of and align_of in rust #205643
Replies: 2 comments
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
|
You're right — 1. Give Copilot an explicit repo rule. Copilot reads custom instructions from ## Rust rules
- `std::mem::{size_of, align_of, size_of_val, align_of_val}` are **prelude items**.
- They need `use std::mem::...` ONLY when the crate has `#![no_implicit_prelude]`.
- Do not flag them as "cannot find function" or suggest importing them in normal crates.
- These compile as-is: `size_of::<T>()`, `align_of::<T>()`, `size_of_val(&value)`.2. Workspace-level fallback. If a PR review happens where the instruction file isn't picked up (or your toolchain skips it), put the same rules into the workspace-level instructions (Copilot settings → Instructions in VS Code). The two scopes together cover repo review and local chat. 3. Use the 👎 on the review comment. "Don't flag prelude functions" feedback does feed back into the model quality loop — with the instruction file and consistent downvotes, this class of false positive usually drops to near zero. Also: linking your PRs as examples here (100+ false positives across public PRs is a far more actionable review-quality signal than "review is wrong") is worth doing — GitHub staff route these. If this nails it, marking it as the accepted answer would be appreciated. 🦀 |
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Bug
💬 Feature/Topic Area
Copilot in GitHub
Body
Every time I have copilot review rust code that uses the
size_ofandalign_offunctions, it tells me that my code won't compile. For example: mahkoh/jay#1208 (comment)But obviously it does compile because those functions are in the prelude. This exact "bug", as copilot calls it, has been a copilot comment probably at least 100 times for me.
All reactions