move bug and span_bug macros to rustc_span - #161873
Conversation
|
Some changes occurred to the CTFE machinery changes to the core type system cc @lcnr Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred to constck cc @fee1-dead Some changes occurred in coverage instrumentation. cc @Zalathar changes to the core type system cc @lcnr Some changes occurred in compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs cc @ZuseZ4 Some changes occurred in compiler/rustc_codegen_llvm/src/builder/autodiff.rs cc @ZuseZ4 Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr Some changes occurred in match checking cc @Nadrieril Some changes occurred in match lowering cc @Nadrieril
Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri HIR ty lowering was modified cc @fmease |
|
|
|
Neat. :) |
This comment has been minimized.
This comment has been minimized.
Mark `extern_item_impls` feature as incomplete context: rust-lang#161873 (comment) > If they are so unstable, maybe they should have a separate feature gate that's marked as `incomplete`. Or the entire `extern_item_impls` should be marked "incomplete". I think it's just best to mark the entire thing as incomplete for now. Later, when the implementation matures we can consider removing the incompleteness or splitting the feature in unstable and incomplete parts. r? @bjorn3 @RalfJung
Mark `extern_item_impls` feature as incomplete context: rust-lang#161873 (comment) > If they are so unstable, maybe they should have a separate feature gate that's marked as `incomplete`. Or the entire `extern_item_impls` should be marked "incomplete". I think it's just best to mark the entire thing as incomplete for now. Later, when the implementation matures we can consider removing the incompleteness or splitting the feature in unstable and incomplete parts. r? @bjorn3 @RalfJung
Mark `extern_item_impls` feature as incomplete context: rust-lang#161873 (comment) > If they are so unstable, maybe they should have a separate feature gate that's marked as `incomplete`. Or the entire `extern_item_impls` should be marked "incomplete". I think it's just best to mark the entire thing as incomplete for now. Later, when the implementation matures we can consider removing the incompleteness or splitting the feature in unstable and incomplete parts. r? @bjorn3 @RalfJung
Rollup merge of #161891 - mejrs:eii_incomplete, r=RalfJung Mark `extern_item_impls` feature as incomplete context: #161873 (comment) > If they are so unstable, maybe they should have a separate feature gate that's marked as `incomplete`. Or the entire `extern_item_impls` should be marked "incomplete". I think it's just best to mark the entire thing as incomplete for now. Later, when the implementation matures we can consider removing the incompleteness or splitting the feature in unstable and incomplete parts. r? @bjorn3 @RalfJung
This comment has been minimized.
This comment has been minimized.
2b61a0e to
aed9a77
Compare
|
cc @Muscraft |
|
cc @bjorn3 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I will only be able to review this on Saturday. If this is bitrotty, feel free to re-roll another reviewer :> |
This comment has been minimized.
This comment has been minimized.
That's fine, it's best to merge these bitrotty prs during the weekend anyway. |
|
I am slowly reviewing this, a question that came to mind is what is the motivation of moving these macros to |
It allows us to use |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| /// If the bug should only be emitted when compilation didn't fail, | ||
| /// [`DiagCtxtHandle::span_delayed_bug`] may be useful. | ||
| /// | ||
| /// [`DiagCtxtHandle::span_delayed_bug`]: ../rustc_errors/struct.DiagCtxtHandle.html#method.span_delayed_bug |
There was a problem hiding this comment.
This path doesn't seem correct as ../ will be compiler/rustc_span/, where the rustc_errors path is compiler/rustc_errors. Also, relative path can be confusing at times, so I think it is nicer to keep the original representation rustc_errors::DiagCtxtHandle::span_delayed_bug.
There was a problem hiding this comment.
Oh right, thanks. fixed.
I think it is nicer to keep the original representation
rustc_errors::DiagCtxtHandle::span_delayed_bug.
that can't be done, rustc_errors depends on rustc_span so this would be a circular dependency,
| tls::with_opt(move |tcx| { | ||
| if let Some(tcx) = tcx { | ||
| let message = format!("{location}: {args}"); | ||
| if let Some(span) = span { |
There was a problem hiding this comment.
In what case tcx will be none here, and what will happen if that's the case?
There was a problem hiding this comment.
That can happen if the compiler hasn't initialized, like when running unit tests in individual rustc_* crates for example. If not then it will just do what bug! does, which is panicking with a custom message.
| #[track_caller] | ||
| pub fn bug_impl(span: Option<Span>, args: fmt::Arguments<'_>, location: &Location<'_>) -> ! { | ||
| (*EMIT_BUG_DIAGNOSTIC)(span, args, location); | ||
| panic!("{args}") |
There was a problem hiding this comment.
Does this mean that the call to bug_impl will always panic? This seems different from previous behaviour, may I know why?
There was a problem hiding this comment.
It's the same as what opt_span_bug_fmt did, the panic calls are implicit there because TyCtxt::{span_bug, bug} bottoms out at panicking.
previous logic:
- if there is a tcx, create a Bug diagnostic which panics when it's emitted
- if there is no tcx, panic
current logic:
- if there is a tcx, emit a diagnostic
- panic
the latter approach also plays much nicer with backtraces because otherwise the panic comes from deep inside the diagnostics machinery.
View all comments
This allows them to be used without depending on rustc_middle.
This is done by using a rustc_interface callback so that, if the callback is set, a internal compiler error diagnostic is printed through that. After that the panic is initiated.
r? @jdonszelmann @bjorn3