mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-07 20:58:39 +00:00
Auto merge of #4209 - lzutao:TyCtxt-lifetime, r=Manishearth
Fix wrong lifetime of TyCtxt Rustup rust-lang/rust#61817 changelog: none
This commit is contained in:
commit
be5d17feb2
@ -121,7 +121,7 @@ impl Hash for Constant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Constant {
|
impl Constant {
|
||||||
pub fn partial_cmp(tcx: TyCtxt<'_, '_>, cmp_type: Ty<'_>, left: &Self, right: &Self) -> Option<Ordering> {
|
pub fn partial_cmp(tcx: TyCtxt<'_>, cmp_type: Ty<'_>, left: &Self, right: &Self) -> Option<Ordering> {
|
||||||
match (left, right) {
|
match (left, right) {
|
||||||
(&Constant::Str(ref ls), &Constant::Str(ref rs)) => Some(ls.cmp(rs)),
|
(&Constant::Str(ref ls), &Constant::Str(ref rs)) => Some(ls.cmp(rs)),
|
||||||
(&Constant::Char(ref l), &Constant::Char(ref r)) => Some(l.cmp(r)),
|
(&Constant::Char(ref l), &Constant::Char(ref r)) => Some(l.cmp(r)),
|
||||||
|
@ -860,7 +860,7 @@ declare_clippy_lint! {
|
|||||||
|
|
||||||
/// Returns the size in bits of an integral type.
|
/// Returns the size in bits of an integral type.
|
||||||
/// Will return 0 if the type is not an int or uint variant
|
/// Will return 0 if the type is not an int or uint variant
|
||||||
fn int_ty_to_nbits(typ: Ty<'_>, tcx: TyCtxt<'_, '_>) -> u64 {
|
fn int_ty_to_nbits(typ: Ty<'_>, tcx: TyCtxt<'_>) -> u64 {
|
||||||
match typ.sty {
|
match typ.sty {
|
||||||
ty::Int(i) => match i {
|
ty::Int(i) => match i {
|
||||||
IntTy::Isize => tcx.data_layout.pointer_size.bits(),
|
IntTy::Isize => tcx.data_layout.pointer_size.bits(),
|
||||||
|
@ -911,7 +911,7 @@ pub fn get_arg_name(pat: &Pat) -> Option<ast::Name> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn int_bits(tcx: TyCtxt<'_, '_>, ity: ast::IntTy) -> u64 {
|
pub fn int_bits(tcx: TyCtxt<'_>, ity: ast::IntTy) -> u64 {
|
||||||
layout::Integer::from_attr(&tcx, attr::IntType::SignedInt(ity))
|
layout::Integer::from_attr(&tcx, attr::IntType::SignedInt(ity))
|
||||||
.size()
|
.size()
|
||||||
.bits()
|
.bits()
|
||||||
@ -919,20 +919,20 @@ pub fn int_bits(tcx: TyCtxt<'_, '_>, ity: ast::IntTy) -> u64 {
|
|||||||
|
|
||||||
#[allow(clippy::cast_possible_wrap)]
|
#[allow(clippy::cast_possible_wrap)]
|
||||||
/// Turn a constant int byte representation into an i128
|
/// Turn a constant int byte representation into an i128
|
||||||
pub fn sext(tcx: TyCtxt<'_, '_>, u: u128, ity: ast::IntTy) -> i128 {
|
pub fn sext(tcx: TyCtxt<'_>, u: u128, ity: ast::IntTy) -> i128 {
|
||||||
let amt = 128 - int_bits(tcx, ity);
|
let amt = 128 - int_bits(tcx, ity);
|
||||||
((u as i128) << amt) >> amt
|
((u as i128) << amt) >> amt
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::cast_sign_loss)]
|
#[allow(clippy::cast_sign_loss)]
|
||||||
/// clip unused bytes
|
/// clip unused bytes
|
||||||
pub fn unsext(tcx: TyCtxt<'_, '_>, u: i128, ity: ast::IntTy) -> u128 {
|
pub fn unsext(tcx: TyCtxt<'_>, u: i128, ity: ast::IntTy) -> u128 {
|
||||||
let amt = 128 - int_bits(tcx, ity);
|
let amt = 128 - int_bits(tcx, ity);
|
||||||
((u as u128) << amt) >> amt
|
((u as u128) << amt) >> amt
|
||||||
}
|
}
|
||||||
|
|
||||||
/// clip unused bytes
|
/// clip unused bytes
|
||||||
pub fn clip(tcx: TyCtxt<'_, '_>, u: u128, ity: ast::UintTy) -> u128 {
|
pub fn clip(tcx: TyCtxt<'_>, u: u128, ity: ast::UintTy) -> u128 {
|
||||||
let bits = layout::Integer::from_attr(&tcx, attr::IntType::UnsignedInt(ity))
|
let bits = layout::Integer::from_attr(&tcx, attr::IntType::UnsignedInt(ity))
|
||||||
.size()
|
.size()
|
||||||
.bits();
|
.bits();
|
||||||
@ -973,7 +973,7 @@ pub fn without_block_comments(lines: Vec<&str>) -> Vec<&str> {
|
|||||||
without
|
without
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn any_parent_is_automatically_derived(tcx: TyCtxt<'_, '_>, node: HirId) -> bool {
|
pub fn any_parent_is_automatically_derived(tcx: TyCtxt<'_>, node: HirId) -> bool {
|
||||||
let map = &tcx.hir();
|
let map = &tcx.hir();
|
||||||
let mut prev_enclosing_node = None;
|
let mut prev_enclosing_node = None;
|
||||||
let mut enclosing_node = node;
|
let mut enclosing_node = node;
|
||||||
|
Loading…
Reference in New Issue
Block a user