profile
viewpoint

Ask questionsrustc_metadata: Deduplicate code between `encode_info_for_item` and `encode_info_for_foreign_item`

The set of data to record for regular items and foreign items is pretty similar, but slightly different. When metadata encoding is done independently for them, issues like https://github.com/rust-lang/rust/pull/77375 arise.

encode_info_for_trait_item and encode_info_for_impl_item are also similar, and also slightly different (all in different directions), so they may be included into the refactoring as well.

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"pitaj"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END --> <!-- TRIAGEBOT_END -->

rust-lang/rust

Answer questions petrochenkov

@pitaj

Does the order of record!s matter?

No, it shouldn't matter. (And if it does you'll get test suit failures anyway.)

What is the difference between tcx.def_span() and item.span?

For functions def_span returns the span of its header, not the whole function with body, for other items it will return item.span. def_span is preferable by default.

useful!

Related questions

Spurious NaNs produced by trig functions with valid inputs on Windows GNU toolchains hot 3
Archive all nightlies hot 3
using 'cargo install xsv' on windows 10 triggers rustc internal error hot 2
if/while Some(n) = &mut foo sugar will leak a temporary mutable borrow to current scope in particular situation hot 2
under latest MinGW, cannot link with C code using stdout hot 2
chain() make collect very slow hot 1
build an empty project failed (undefined reference to `__onexitbegin') hot 1
Invalid collision with TryFrom implementation? hot 1
Crater runs for Rust 1.38.0 hot 1
Spurious NaNs produced by trig functions with valid inputs on Windows GNU toolchains hot 1
Building LLVM with Clang fails hot 1
Internal compiler error: can't buffer lints after HIR lowering hot 1
E0373 help suggests `move async` but the correct syntax is `async move` hot 1
Tracking issue for `Option::contains` and `Result::contains` hot 1
async fn + rustfmt don't "just work" inside of RLS hot 1
source:https://uonfu.com/
Github User Rank List