Replace allow attributes with expect and remove unused attributes

This commit is contained in:
Guillaume Gomez 2025-11-05 12:22:15 +01:00
parent e785c50dad
commit 1548ba6a46
11 changed files with 14 additions and 35 deletions

View file

@ -84,7 +84,7 @@ fn inline_attr<'gcc, 'tcx>(
/// attributes.
pub fn from_fn_attrs<'gcc, 'tcx>(
cx: &CodegenCx<'gcc, 'tcx>,
#[cfg_attr(not(feature = "master"), allow(unused_variables))] func: Function<'gcc>,
#[cfg_attr(not(feature = "master"), expect(unused_variables))] func: Function<'gcc>,
instance: ty::Instance<'tcx>,
) {
let codegen_fn_attrs = cx.tcx.codegen_instance_attrs(instance.def);

View file

@ -633,7 +633,7 @@ pub fn optimize_thin_module(
save_temp_bitcode(cgcx, &module, "thin-lto-after-pm");
}
}*/
#[allow(clippy::let_and_return)]
#[expect(clippy::let_and_return)]
module
}

View file

@ -1481,7 +1481,6 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
variable.to_rvalue()
}
#[allow(dead_code)]
fn va_arg(&mut self, _list: RValue<'gcc>, _ty: Type<'gcc>) -> RValue<'gcc> {
unimplemented!();
}
@ -2517,7 +2516,7 @@ impl ToGccComp for RealPredicate {
}
#[repr(C)]
#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
enum MemOrdering {
__ATOMIC_RELAXED,
__ATOMIC_CONSUME,

View file

@ -58,7 +58,6 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
global_value
}
#[cfg_attr(not(feature = "master"), allow(unused_mut))]
fn codegen_static(&mut self, def_id: DefId) {
let attrs = self.tcx.codegen_fn_attrs(def_id);
@ -162,7 +161,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
// TODO(antoyo)
}
#[cfg_attr(not(feature = "master"), allow(unused_variables))]
#[cfg_attr(not(feature = "master"), expect(unused_variables))]
pub fn add_used_function(&self, function: Function<'gcc>) {
#[cfg(feature = "master")]
function.add_attribute(FnAttribute::Used);

View file

@ -28,7 +28,7 @@ use crate::abi::conv_to_fn_attribute;
use crate::callee::get_fn;
use crate::common::SignType;
#[cfg_attr(not(feature = "master"), allow(dead_code))]
#[cfg_attr(not(feature = "master"), expect(dead_code))]
pub struct CodegenCx<'gcc, 'tcx> {
/// A cache of converted ConstAllocs
pub const_cache: RefCell<HashMap<Allocation, RValue<'gcc>>>,
@ -132,7 +132,7 @@ pub struct CodegenCx<'gcc, 'tcx> {
}
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
pub fn new(
context: &'gcc Context<'gcc>,
codegen_unit: &'tcx CodegenUnit<'tcx>,

View file

@ -156,7 +156,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
///
/// If theres a value with the same name already declared, the function will
/// update the declaration and return existing Value instead.
#[allow(clippy::let_and_return)]
#[expect(clippy::let_and_return)]
fn declare_raw_fn<'gcc>(
cx: &CodegenCx<'gcc, '_>,
name: &str,

View file

@ -10,7 +10,7 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
};
match arch {
"AMDGPU" => {
#[allow(non_snake_case)]
#[expect(non_snake_case)]
fn AMDGPU(name: &str, full_name: &str) -> &'static str {
match name {
// AMDGPU
@ -48,7 +48,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
AMDGPU(name, full_name)
}
"aarch64" => {
#[allow(non_snake_case)]
fn aarch64(name: &str, full_name: &str) -> &'static str {
match name {
// aarch64
@ -81,7 +80,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
aarch64(name, full_name)
}
"amdgcn" => {
#[allow(non_snake_case)]
fn amdgcn(name: &str, full_name: &str) -> &'static str {
match name {
// amdgcn
@ -524,7 +522,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
amdgcn(name, full_name)
}
"arm" => {
#[allow(non_snake_case)]
fn arm(name: &str, full_name: &str) -> &'static str {
match name {
// arm
@ -633,7 +630,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
arm(name, full_name)
}
"bpf" => {
#[allow(non_snake_case)]
fn bpf(name: &str, full_name: &str) -> &'static str {
match name {
// bpf
@ -655,7 +651,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
bpf(name, full_name)
}
"cuda" => {
#[allow(non_snake_case)]
fn cuda(name: &str, full_name: &str) -> &'static str {
match name {
// cuda
@ -666,7 +661,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
cuda(name, full_name)
}
"hexagon" => {
#[allow(non_snake_case)]
fn hexagon(name: &str, full_name: &str) -> &'static str {
match name {
// hexagon
@ -2653,7 +2647,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
hexagon(name, full_name)
}
"loongarch" => {
#[allow(non_snake_case)]
fn loongarch(name: &str, full_name: &str) -> &'static str {
match name {
// loongarch
@ -4162,7 +4155,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
loongarch(name, full_name)
}
"mips" => {
#[allow(non_snake_case)]
fn mips(name: &str, full_name: &str) -> &'static str {
match name {
// mips
@ -4843,7 +4835,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
mips(name, full_name)
}
"nvvm" => {
#[allow(non_snake_case)]
fn nvvm(name: &str, full_name: &str) -> &'static str {
match name {
// nvvm
@ -5652,7 +5643,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
nvvm(name, full_name)
}
"ppc" => {
#[allow(non_snake_case)]
fn ppc(name: &str, full_name: &str) -> &'static str {
match name {
// ppc
@ -6245,7 +6235,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
ppc(name, full_name)
}
"ptx" => {
#[allow(non_snake_case)]
fn ptx(name: &str, full_name: &str) -> &'static str {
match name {
// ptx
@ -6273,7 +6262,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
ptx(name, full_name)
}
"r600" => {
#[allow(non_snake_case)]
fn r600(name: &str, full_name: &str) -> &'static str {
match name {
// r600
@ -6298,7 +6286,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
r600(name, full_name)
}
"riscv" => {
#[allow(non_snake_case)]
fn riscv(name: &str, full_name: &str) -> &'static str {
match name {
// riscv
@ -6332,7 +6319,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
riscv(name, full_name)
}
"s390" => {
#[allow(non_snake_case)]
fn s390(name: &str, full_name: &str) -> &'static str {
match name {
// s390
@ -6526,7 +6512,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
s390(name, full_name)
}
"spv" => {
#[allow(non_snake_case)]
fn spv(name: &str, full_name: &str) -> &'static str {
match name {
// spv
@ -6543,7 +6528,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
spv(name, full_name)
}
"ve" => {
#[allow(non_snake_case)]
fn ve(name: &str, full_name: &str) -> &'static str {
match name {
// ve
@ -7816,7 +7800,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
ve(name, full_name)
}
"x86" => {
#[allow(non_snake_case)]
fn x86(name: &str, full_name: &str) -> &'static str {
match name {
// x86
@ -10384,7 +10367,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str {
x86(name, full_name)
}
"xcore" => {
#[allow(non_snake_case)]
fn xcore(name: &str, full_name: &str) -> &'static str {
match name {
// xcore

View file

@ -85,7 +85,7 @@ fn wide_aes_output_type<'a, 'gcc, 'tcx>(
(aes_output_type.as_type(), field1, field2)
}
#[cfg_attr(not(feature = "master"), allow(unused_variables))]
#[cfg_attr(not(feature = "master"), expect(unused_variables))]
pub fn adjust_function<'gcc>(
context: &'gcc Context<'gcc>,
func_name: &str,

View file

@ -13,7 +13,7 @@
* TODO(antoyo): remove the patches.
*/
#![allow(internal_features)]
#![expect(internal_features)]
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
#![feature(rustc_private)]
@ -21,7 +21,7 @@
#![warn(rust_2018_idioms)]
#![warn(unused_lifetimes)]
#![deny(clippy::pattern_type_mismatch)]
#![allow(clippy::needless_lifetimes, clippy::uninlined_format_args)]
#![expect(clippy::uninlined_format_args)]
// The rustc crates we need
extern crate rustc_abi;
@ -46,7 +46,7 @@ extern crate rustc_target;
extern crate rustc_type_ir;
// This prevents duplicating functions and statics that are already part of the host rustc process.
#[allow(unused_extern_crates)]
#[expect(unused_extern_crates)]
extern crate rustc_driver;
mod abi;

View file

@ -15,7 +15,7 @@ use crate::type_of::LayoutGccExt;
use crate::{attributes, base};
impl<'gcc, 'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
#[cfg_attr(not(feature = "master"), allow(unused_variables))]
#[cfg_attr(not(feature = "master"), expect(unused_variables))]
fn predefine_static(
&mut self,
def_id: DefId,
@ -41,7 +41,6 @@ impl<'gcc, 'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
self.instances.borrow_mut().insert(instance, global);
}
#[cfg_attr(not(feature = "master"), allow(unused_variables))]
fn predefine_fn(
&mut self,
instance: Instance<'tcx>,

View file

@ -299,7 +299,7 @@ impl<'gcc, 'tcx> BaseTypeCodegenMethods for CodegenCx<'gcc, 'tcx> {
value.get_type()
}
#[cfg_attr(feature = "master", allow(unused_mut))]
#[cfg_attr(feature = "master", expect(unused_mut))]
fn type_array(&self, ty: Type<'gcc>, mut len: u64) -> Type<'gcc> {
#[cfg(not(feature = "master"))]
if let Some(struct_type) = ty.is_struct()