diff options
| author | bors <bors@rust-lang.org> | 2022-11-24 20:29:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-11-24 20:29:13 +0000 |
| commit | b3bc6bf31265ac10946a0832092dbcedf9b26805 (patch) | |
| tree | 5d839466b9602bf1ae6eb4e42883b68a2aa05545 /compiler/rustc_lint/src | |
| parent | 5dfb4b0afaf6acace0845d00e85a934fb4289d83 (diff) | |
| parent | 390a637e296ccfaac4c6abd1291b0523e8a8e00b (diff) | |
| download | rust-b3bc6bf31265ac10946a0832092dbcedf9b26805.tar.gz rust-b3bc6bf31265ac10946a0832092dbcedf9b26805.zip | |
Auto merge of #103693 - HKalbasi:master, r=oli-obk
Make rustc_target usable outside of rustc I'm working on showing type size in rust-analyzer (https://github.com/rust-lang/rust-analyzer/pull/13490) and I currently copied rustc code inside rust-analyzer, which works, but is bad. With this change, I would become able to use `rustc_target` and `rustc_index` directly in r-a, reducing the amount of copy needed. This PR contains some feature flag to put nightly features behind them to make crates buildable on the stable compiler + makes layout related types generic over index type + removes interning of nested layouts.
Diffstat (limited to 'compiler/rustc_lint/src')
| -rw-r--r-- | compiler/rustc_lint/src/types.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index afc568f3a50..297b509d402 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -12,7 +12,7 @@ use rustc_middle::ty::{self, AdtKind, DefIdTree, Ty, TyCtxt, TypeSuperVisitable, use rustc_span::source_map; use rustc_span::symbol::sym; use rustc_span::{Span, Symbol}; -use rustc_target::abi::{Abi, WrappingRange}; +use rustc_target::abi::{Abi, Size, WrappingRange}; use rustc_target::abi::{Integer, TagEncoding, Variants}; use rustc_target::spec::abi::Abi as SpecAbi; @@ -225,11 +225,11 @@ fn report_bin_hex_error( cx: &LateContext<'_>, expr: &hir::Expr<'_>, ty: attr::IntType, + size: Size, repr_str: String, val: u128, negative: bool, ) { - let size = Integer::from_attr(&cx.tcx, ty).size(); cx.struct_span_lint( OVERFLOWING_LITERALS, expr.span, @@ -352,6 +352,7 @@ fn lint_int_literal<'tcx>( cx, e, attr::IntType::SignedInt(ty::ast_int_ty(t)), + Integer::from_int_ty(cx, t).size(), repr_str, v, negative, @@ -437,6 +438,7 @@ fn lint_uint_literal<'tcx>( cx, e, attr::IntType::UnsignedInt(ty::ast_uint_ty(t)), + Integer::from_uint_ty(cx, t).size(), repr_str, lit_val, false, @@ -1376,7 +1378,7 @@ impl<'tcx> LateLintPass<'tcx> for VariantSizeDifferences { let (largest, slargest, largest_index) = iter::zip(enum_definition.variants, variants) .map(|(variant, variant_layout)| { // Subtract the size of the enum tag. - let bytes = variant_layout.size().bytes().saturating_sub(tag_size); + let bytes = variant_layout.size.bytes().saturating_sub(tag_size); debug!("- variant `{}` is {} bytes large", variant.ident, bytes); bytes |
