Skip to content

Overhaul const-checking diagnostics #77354

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

Merged
merged 23 commits into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4d343a5
Useful derives on `mir::LocalKind`
ecstatic-morse Sep 30, 2020
325b7d4
Continue const-checking after errors when easy
ecstatic-morse Sep 29, 2020
25c7753
Continue after `impl Trait` in `const fn`
ecstatic-morse Sep 30, 2020
c38aca0
`delay_span_bug` if const-checking an `async` function
ecstatic-morse Sep 30, 2020
20e07e7
Forbid generator-specific MIR in all const-contexts
ecstatic-morse Sep 30, 2020
782a595
Return a `DiagnosticBuilder` from structured errors
ecstatic-morse Sep 29, 2020
ce50939
Fix "unstable in stable" error
ecstatic-morse Sep 29, 2020
de35c42
Remove `ops::non_const`
ecstatic-morse Sep 29, 2020
b518ccb
Give `MutDeref` a real error message
ecstatic-morse Sep 29, 2020
a23297f
Bless mut tests
ecstatic-morse Sep 29, 2020
5b31455
Priority levels
ecstatic-morse Sep 30, 2020
b400871
Don't emit duplicate errors for the return place
ecstatic-morse Sep 30, 2020
51fbd55
Bless tests
ecstatic-morse Sep 30, 2020
37f37dc
Emit multiple function pointer errors from const-checker
ecstatic-morse Sep 30, 2020
879d379
Bless output
ecstatic-morse Sep 30, 2020
e02ea83
Don't stop const-checking after erroneous trait bound
ecstatic-morse Sep 30, 2020
4bbc79c
Bless tests
ecstatic-morse Sep 30, 2020
287993c
Remove machinery for halting error output
ecstatic-morse Sep 30, 2020
bed7b29
Update `compile-fail` test
ecstatic-morse Sep 30, 2020
1513904
Remove default `build_error` impl
ecstatic-morse Sep 30, 2020
7c6d685
Rewrite E0019 example
ecstatic-morse Sep 30, 2020
0c26144
Better span for attribute suggestions
ecstatic-morse Sep 30, 2020
1301f43
Remove E0019, use E0015 for inline assembly in a const
ecstatic-morse Sep 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ E0010: include_str!("./error_codes/E0010.md"),
E0013: include_str!("./error_codes/E0013.md"),
E0014: include_str!("./error_codes/E0014.md"),
E0015: include_str!("./error_codes/E0015.md"),
E0019: include_str!("./error_codes/E0019.md"),
E0023: include_str!("./error_codes/E0023.md"),
E0025: include_str!("./error_codes/E0025.md"),
E0026: include_str!("./error_codes/E0026.md"),
Expand Down Expand Up @@ -461,6 +460,7 @@ E0774: include_str!("./error_codes/E0774.md"),
;
// E0006, // merged with E0005
// E0008, // cannot bind by-move into a pattern guard
// E0019, merged into E0015
// E0035, merged into E0087/E0089
// E0036, merged into E0087/E0089
// E0068,
Expand Down
36 changes: 0 additions & 36 deletions compiler/rustc_error_codes/src/error_codes/E0019.md

This file was deleted.

2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ impl Atom for Local {
}

/// Classifies locals into categories. See `Body::local_kind`.
#[derive(PartialEq, Eq, Debug, HashStable)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, HashStable)]
pub enum LocalKind {
/// User-declared variable binding.
Var,
Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_mir/src/transform/check_consts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ impl ConstCx<'mir, 'tcx> {
&& self.tcx.features().staged_api
&& is_const_stable_const_fn(self.tcx, self.def_id.to_def_id())
}

/// Returns the function signature of the item being const-checked if it is a `fn` or `const fn`.
pub fn fn_sig(&self) -> Option<&'tcx hir::FnSig<'tcx>> {
// Get this from the HIR map instead of a query to avoid cycle errors.
//
// FIXME: Is this still an issue?
let hir_map = self.tcx.hir();
let hir_id = hir_map.local_def_id_to_hir_id(self.def_id);
hir_map.fn_sig_by_hir_id(hir_id)
}
}

/// Returns `true` if this `DefId` points to one of the official `panic` lang items.
Expand Down
Loading