-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Move a wf-check into the site where the value is instantiated #103525
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me after the nit
match impl_.constness { | ||
hir::Constness::Const => { | ||
if let Some(trait_def_id) = ast_trait_ref.trait_def_id() && !tcx.has_attr(trait_def_id, sym::const_trait) { | ||
let trait_name = tcx.item_name(trait_def_id); | ||
let mut err = tcx.sess.struct_span_err( | ||
ast_trait_ref.path.span, | ||
&format!("const `impl` for trait `{trait_name}` which is not marked with `#[const_trait]`"), | ||
); | ||
if trait_def_id.is_local() { | ||
let sp = tcx.def_span(trait_def_id).shrink_to_lo(); | ||
err.span_suggestion(sp, &format!("mark `{trait_name}` as const"), "#[const_trait]", rustc_errors::Applicability::MachineApplicable); | ||
} | ||
err.note("marking a trait with `#[const_trait]` ensures all default method bodies are `const`"); | ||
err.note("adding a non-const method body in the future would be a breaking change"); | ||
err.emit(); | ||
ty::BoundConstness::NotConst | ||
} else { | ||
ty::BoundConstness::ConstIfConst | ||
} | ||
}, | ||
hir::Constness::NotConst => ty::BoundConstness::NotConst, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move that out of the instantiate_mono_trait_ref
call?
cc @davidtwco, @compiler-errors, @JohnTitor, @estebank, @TaKO8Ki |
@bors r=lcnr |
…ait, r=lcnr Move a wf-check into the site where the value is instantiated r? `@lcnr`
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#103035 (Even nicer errors from assert_unsafe_precondition) - rust-lang#103106 (Try to say that memory outside the AM is always exposed) - rust-lang#103475 (Make param index generation a bit more robust) - rust-lang#103525 (Move a wf-check into the site where the value is instantiated) - rust-lang#103564 (library: allow some unused things in Miri) - rust-lang#103586 (Process registered region obligation in `resolve_regions_with_wf_tys`) - rust-lang#103592 (rustdoc: remove redundant CSS selector `.notable-traits .notable`) - rust-lang#103593 (Remove an unused parser function (`Expr::returns`)) - rust-lang#103611 (Add test for issue 103574) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
r? @lcnr