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

Don't run MIR unsafeck at all when using -Zthir-unsafeck #87527

Merged
merged 1 commit into from
Jul 29, 2021

Conversation

LeSeulArtichaut
Copy link
Contributor

I don't know how I missed this :D
r? @oli-obk

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 27, 2021
@oli-obk
Copy link
Contributor

oli-obk commented Jul 28, 2021

Huh 😄

how does it then work that we don't see MIR unsafeck messages with -Zthir-unsafeck? Do we abort compilation before we get there if there are any errors?

@LeSeulArtichaut
Copy link
Contributor Author

That's because the unsafety_check_result query doesn't actually report any errors, that is left to the check_unsafety function:

pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: LocalDefId) {
debug!("check_unsafety({:?})", def_id);
// closures are handled by their parent fn.
if tcx.is_closure(def_id.to_def_id()) {
return;
}
let UnsafetyCheckResult { violations, unsafe_blocks } = tcx.unsafety_check_result(def_id);
for &UnsafetyViolation { source_info, lint_root, kind, details } in violations.iter() {
let (description, note) = details.description_and_note();
// Report an error.
let unsafe_fn_msg =
if unsafe_op_in_unsafe_fn_allowed(tcx, lint_root) { " function or" } else { "" };
match kind {
UnsafetyViolationKind::General => {
// once
struct_span_err!(
tcx.sess,
source_info.span,
E0133,
"{} is unsafe and requires unsafe{} block",
description,
unsafe_fn_msg,
)
.span_label(source_info.span, description)
.note(note)
.emit();
}
UnsafetyViolationKind::UnsafeFn => tcx.struct_span_lint_hir(
UNSAFE_OP_IN_UNSAFE_FN,
lint_root,
source_info.span,
|lint| {
lint.build(&format!(
"{} is unsafe and requires unsafe block (error E0133)",
description,
))
.span_label(source_info.span, description)
.note(note)
.emit();
},
),
}
}
let (mut unsafe_used, mut unsafe_unused): (FxHashSet<_>, Vec<_>) = Default::default();
for &(block_id, is_used) in unsafe_blocks.iter() {
if is_used {
unsafe_used.insert(block_id);
} else {
unsafe_unused.push(block_id);
}
}
// The unused unsafe blocks might not be in source order; sort them so that the unused unsafe
// error messages are properly aligned and the issue-45107 and lint-unused-unsafe tests pass.
unsafe_unused.sort_by_cached_key(|hir_id| tcx.hir().span(*hir_id));
for &block_id in &unsafe_unused {
report_unused_unsafe(tcx, &unsafe_used, block_id);
}
}

@oli-obk
Copy link
Contributor

oli-obk commented Jul 28, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Jul 28, 2021

📌 Commit 40b57be has been approved by oli-obk

@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 Jul 28, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jul 28, 2021
…oli-obk

Don't run MIR unsafeck at all when using `-Zthir-unsafeck`

I don't know how I missed this :D
r? `@oli-obk`
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 28, 2021
Rollup of 10 pull requests

Successful merges:

 - rust-lang#81050 (Stabilize core::task::ready!)
 - rust-lang#81363 (Remove P: Unpin bound on impl Future for Pin)
 - rust-lang#86839 (Add doc aliases to fs.rs)
 - rust-lang#87435 (fix example code for E0617)
 - rust-lang#87451 (Add support for tuple struct field documentation)
 - rust-lang#87491 (Integrate context into the memorial to Anna)
 - rust-lang#87521 (Add long explanation for E0498)
 - rust-lang#87527 (Don't run MIR unsafeck at all when using `-Zthir-unsafeck`)
 - rust-lang#87550 (Add `CI_ONLY_WHEN_CHANNEL` and run `x86_64-gnu-stable` only on nightly)
 - rust-lang#87565 (Use backticks when referring to `core::future::Ready` in panic message)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9e94d7b into rust-lang:master Jul 29, 2021
@rustbot rustbot added this to the 1.56.0 milestone Jul 29, 2021
@LeSeulArtichaut LeSeulArtichaut deleted the no-mir-unsafeck branch August 25, 2021 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants