Skip to content

Switch to 2024 edition and remove let_chains feature #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
name = "rustc_codegen_gcc"
version = "0.1.0"
authors = ["Antoni Boucher <bouanto@zoho.com>"]
edition = "2018"
edition = "2024"
license = "MIT OR Apache-2.0"

[lib]
2 changes: 1 addition & 1 deletion build_system/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "y"
version = "0.1.0"
edition = "2021"
edition = "2024"

[dependencies]
boml = "0.3.1"
4 changes: 3 additions & 1 deletion build_system/src/main.rs
Original file line number Diff line number Diff line change
@@ -60,7 +60,9 @@ pub enum Command {

fn main() {
if env::var("RUST_BACKTRACE").is_err() {
env::set_var("RUST_BACKTRACE", "1");
unsafe {
env::set_var("RUST_BACKTRACE", "1");
}
}

let command = match env::args().nth(1).as_deref() {
2 changes: 1 addition & 1 deletion build_system/src/utils.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ use std::path::{Path, PathBuf};
use std::process::{Command, ExitStatus, Output};

#[cfg(unix)]
extern "C" {
unsafe extern "C" {
fn raise(signal: c_int) -> c_int;
}

2 changes: 1 addition & 1 deletion src/back/lto.rs
Original file line number Diff line number Diff line change
@@ -589,7 +589,7 @@ fn thin_lto(
Ok((opt_jobs, copy_jobs))
}

pub unsafe fn optimize_thin_module(
pub fn optimize_thin_module(
thin_module: ThinModule<GccCodegenBackend>,
_cgcx: &CodegenContext<GccCodegenBackend>,
) -> Result<ModuleCodegen<GccContext>, FatalError> {
2 changes: 1 addition & 1 deletion src/back/write.rs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ use crate::base::add_pic_option;
use crate::errors::CopyBitcode;
use crate::{GccCodegenBackend, GccContext};

pub(crate) unsafe fn codegen(
pub(crate) fn codegen(
cgcx: &CodegenContext<GccCodegenBackend>,
dcx: DiagCtxtHandle<'_>,
module: ModuleCodegen<GccContext>,
6 changes: 2 additions & 4 deletions src/consts.rs
Original file line number Diff line number Diff line change
@@ -191,13 +191,11 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
// TODO(antoyo): check if it's okay that no link_section is set.

let typ = self.val_ty(cv).get_aligned(align.bytes());
let global = self.declare_private_global(&name[..], typ);
global
self.declare_private_global(&name[..], typ)
}
_ => {
let typ = self.val_ty(cv).get_aligned(align.bytes());
let global = self.declare_unnamed_global(typ);
global
self.declare_unnamed_global(typ)
}
};
global.global_set_initializer_rvalue(cv);
5 changes: 2 additions & 3 deletions src/debuginfo.rs
Original file line number Diff line number Diff line change
@@ -289,7 +289,7 @@ impl<'gcc, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
) -> Self::DILocation {
let pos = span.lo();
let DebugLoc { file, line, col } = self.lookup_debug_loc(pos);
let loc = match file.name {
match file.name {
rustc_span::FileName::Real(ref name) => match *name {
rustc_span::RealFileName::LocalPath(ref name) => {
if let Some(name) = name.to_str() {
@@ -314,7 +314,6 @@ impl<'gcc, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
}
},
_ => Location::null(),
};
loc
}
}
}
1 change: 1 addition & 0 deletions src/declare.rs
Original file line number Diff line number Diff line change
@@ -157,6 +157,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
///
/// If there’s a value with the same name already declared, the function will
/// update the declaration and return existing Value instead.
#[allow(clippy::let_and_return)]
fn declare_raw_fn<'gcc>(
cx: &CodegenCx<'gcc, '_>,
name: &str,
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
#![allow(internal_features)]
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
#![feature(rustc_private, decl_macro, never_type, trusted_len, let_chains)]
#![feature(rustc_private, decl_macro, never_type, trusted_len)]
#![allow(broken_intra_doc_links)]
#![recursion_limit = "256"]
#![warn(rust_2018_idioms)]
@@ -454,7 +454,7 @@ impl WriteBackendMethods for GccCodegenBackend {
}

/// This is the entrypoint for a hot plugged rustc_codegen_gccjit
#[no_mangle]
#[unsafe(no_mangle)]
pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> {
#[cfg(feature = "master")]
let info = {
9 changes: 5 additions & 4 deletions tests/lang_tests_common.rs
Original file line number Diff line number Diff line change
@@ -42,7 +42,9 @@ pub fn main_inner(profile: Profile) {
.expect("failed to get absolute path of `gcc-path`")
.display()
.to_string();
env::set_var("LD_LIBRARY_PATH", gcc_path);
unsafe {
env::set_var("LD_LIBRARY_PATH", gcc_path);
}

fn rust_filter(path: &Path) -> bool {
path.is_file() && path.extension().expect("extension").to_str().expect("to_str") == "rs"
@@ -67,15 +69,14 @@ pub fn main_inner(profile: Profile) {
.test_dir("tests/run")
.test_path_filter(filter)
.test_extract(|path| {
let lines = std::fs::read_to_string(path)
std::fs::read_to_string(path)
.expect("read file")
.lines()
.skip_while(|l| !l.starts_with("//"))
.take_while(|l| l.starts_with("//"))
.map(|l| &l[2..])
.collect::<Vec<_>>()
.join("\n");
lines
.join("\n")
})
.test_cmds(move |path| {
// Test command 1: Compile `x.rs` into `tempdir/x`.