Skip to content

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

Merged
merged 2 commits into from
Oct 27, 2022

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Oct 25, 2022

r? @lcnr

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 25, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 25, 2022
Copy link
Contributor

@lcnr lcnr left a 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

Comment on lines 1297 to 1318
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,
},
Copy link
Contributor

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?

@rustbot rustbot added the A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic label Oct 25, 2022
@rustbot
Copy link
Collaborator

rustbot commented Oct 25, 2022

rustc_error_messages was changed

cc @davidtwco, @compiler-errors, @JohnTitor, @estebank, @TaKO8Ki

@oli-obk
Copy link
Contributor Author

oli-obk commented Oct 25, 2022

@bors r=lcnr

@bors
Copy link
Collaborator

bors commented Oct 25, 2022

📌 Commit 1c26a27 has been approved by lcnr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 25, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 27, 2022
…ait, r=lcnr

Move a wf-check into the site where the value is instantiated

r? `@lcnr`
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 27, 2022
…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
@bors bors merged commit 2bd49c3 into rust-lang:master Oct 27, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 27, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants