mirror of https://github.com/rust-lang/rls
Fix RLS-internal breakage
A separate commit will be necessary to bump racer, which is also currently broken, but this at least gets us part of the way there.
This commit is contained in:
parent
d8478d82f5
commit
64b8292e61
|
@ -75,4 +75,6 @@ pub enum Edition {
|
|||
Edition2018,
|
||||
/// Rust 2021
|
||||
Edition2021,
|
||||
/// Rust 2024
|
||||
Edition2024,
|
||||
}
|
||||
|
|
|
@ -137,6 +137,7 @@ impl Callbacks for ShimCalls {
|
|||
rustc_span::edition::Edition::Edition2015 => Edition::Edition2015,
|
||||
rustc_span::edition::Edition::Edition2018 => Edition::Edition2018,
|
||||
rustc_span::edition::Edition::Edition2021 => Edition::Edition2021,
|
||||
rustc_span::edition::Edition::Edition2024 => Edition::Edition2024,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -697,6 +697,7 @@ fn reformat(
|
|||
Edition::Edition2015 => RustfmtEdition::Edition2015,
|
||||
Edition::Edition2018 => RustfmtEdition::Edition2018,
|
||||
Edition::Edition2021 => RustfmtEdition::Edition2021,
|
||||
Edition::Edition2024 => RustfmtEdition::Edition2024,
|
||||
};
|
||||
config.set().edition(edition);
|
||||
trace!("Detected edition {:?} for file `{}`", edition, path.display());
|
||||
|
|
|
@ -408,17 +408,18 @@ impl Executor for RlsExecutor {
|
|||
// Enforce JSON output so that we can parse the rustc output by
|
||||
// stripping --error-format if it was specified (e.g. Cargo pipelined
|
||||
// build)
|
||||
let filtered_args = filter_arg(cargo_cmd.get_args(), "--error-format");
|
||||
let filtered_args =
|
||||
filter_arg(&*cargo_cmd.get_args().collect::<Vec<_>>(), "--error-format");
|
||||
cargo_cmd.args_replace(&filtered_args);
|
||||
cargo_cmd.arg("--error-format=json");
|
||||
// Delete any stale data. We try and remove any json files with
|
||||
// the same crate name as Cargo would emit. This includes files
|
||||
// with the same crate name but different hashes, e.g., those
|
||||
// made with a different compiler.
|
||||
let cargo_args = cargo_cmd.get_args();
|
||||
let cargo_args = cargo_cmd.get_args().collect::<Vec<_>>();
|
||||
let crate_name =
|
||||
parse_arg(cargo_args, "--crate-name").expect("no crate-name in rustc command line");
|
||||
let cfg_test = cargo_args.iter().any(|arg| arg == "--test");
|
||||
parse_arg(&cargo_args, "--crate-name").expect("no crate-name in rustc command line");
|
||||
let cfg_test = cargo_args.iter().any(|arg| *arg == "--test");
|
||||
trace!("exec: {} {:?}", crate_name, cargo_cmd);
|
||||
|
||||
// Send off a window/progress notification for this compile target.
|
||||
|
@ -435,7 +436,8 @@ impl Executor for RlsExecutor {
|
|||
.expect("failed to send progress update");
|
||||
}
|
||||
|
||||
let out_dir = parse_arg(cargo_args, "--out-dir").expect("no out-dir in rustc command line");
|
||||
let out_dir =
|
||||
parse_arg(&cargo_args, "--out-dir").expect("no out-dir in rustc command line");
|
||||
let analysis_dir = Path::new(&out_dir).join("save-analysis");
|
||||
if let Ok(dir_contents) = read_dir(&analysis_dir) {
|
||||
let lib_crate_name = "lib".to_owned() + &crate_name;
|
||||
|
@ -478,7 +480,7 @@ impl Executor for RlsExecutor {
|
|||
|
||||
// Add args and envs to cmd.
|
||||
let mut args: Vec<_> =
|
||||
cargo_args.iter().map(|a| a.clone().into_string().unwrap()).collect();
|
||||
cargo_args.iter().map(|a| (*a).to_owned().into_string().unwrap()).collect();
|
||||
let envs = cargo_cmd.get_envs().clone();
|
||||
|
||||
let sysroot = super::rustc::current_sysroot()
|
||||
|
@ -508,7 +510,7 @@ impl Executor for RlsExecutor {
|
|||
"rustc not intercepted - {}{} - args: {:?} envs: {:?}",
|
||||
id.name(),
|
||||
build_script_notice,
|
||||
cmd.get_args(),
|
||||
cmd.get_args().collect::<Vec<_>>(),
|
||||
cmd.get_envs(),
|
||||
);
|
||||
|
||||
|
@ -712,9 +714,9 @@ pub fn make_cargo_config(
|
|||
config
|
||||
}
|
||||
|
||||
fn parse_arg(args: &[OsString], arg: &str) -> Option<String> {
|
||||
fn parse_arg(args: &[&OsString], arg: &str) -> Option<String> {
|
||||
for (i, a) in args.iter().enumerate() {
|
||||
if a == arg {
|
||||
if *a == arg {
|
||||
return Some(args[i + 1].clone().into_string().unwrap());
|
||||
}
|
||||
}
|
||||
|
@ -780,7 +782,7 @@ fn dedup_flags(flag_str: &str) -> String {
|
|||
}
|
||||
|
||||
/// Removes a selected flag of a `--flag=VALUE` or `--flag VALUE` shape from `args` (command line args for Rust).
|
||||
fn filter_arg(args: &[OsString], key: &str) -> Vec<String> {
|
||||
fn filter_arg(args: &[&OsString], key: &str) -> Vec<String> {
|
||||
let key_as_prefix = key.to_owned() + "=";
|
||||
let mut ret = vec![];
|
||||
|
||||
|
@ -934,12 +936,47 @@ mod test {
|
|||
input.split_whitespace().map(OsString::from).collect()
|
||||
}
|
||||
|
||||
assert!(filter_arg(&args("--error-format=json"), "--error-format").is_empty());
|
||||
assert!(filter_arg(&args("--error-format json"), "--error-format").is_empty());
|
||||
assert_eq!(filter_arg(&args("-a --error-format=json"), "--error-format"), ["-a"]);
|
||||
assert_eq!(filter_arg(&args("-a --error-format json"), "--error-format"), ["-a"]);
|
||||
assert_eq!(filter_arg(&args("-a --error-format=json -b"), "--error-format"), ["-a", "-b"]);
|
||||
assert_eq!(filter_arg(&args("-a --error-format json -b"), "--error-format"), ["-a", "-b"]);
|
||||
assert_eq!(filter_arg(&args("-a -b -x"), "--error-format"), ["-a", "-b", "-x"]);
|
||||
assert!(filter_arg(
|
||||
&args("--error-format=json").iter().collect::<Vec<_>>(),
|
||||
"--error-format"
|
||||
)
|
||||
.is_empty());
|
||||
assert!(filter_arg(
|
||||
&args("--error-format json").iter().collect::<Vec<_>>(),
|
||||
"--error-format"
|
||||
)
|
||||
.is_empty());
|
||||
assert_eq!(
|
||||
filter_arg(
|
||||
&args("-a --error-format=json").iter().collect::<Vec<_>>(),
|
||||
"--error-format"
|
||||
),
|
||||
["-a"]
|
||||
);
|
||||
assert_eq!(
|
||||
filter_arg(
|
||||
&args("-a --error-format json").iter().collect::<Vec<_>>(),
|
||||
"--error-format"
|
||||
),
|
||||
["-a"]
|
||||
);
|
||||
assert_eq!(
|
||||
filter_arg(
|
||||
&args("-a --error-format=json -b").iter().collect::<Vec<_>>(),
|
||||
"--error-format"
|
||||
),
|
||||
["-a", "-b"]
|
||||
);
|
||||
assert_eq!(
|
||||
filter_arg(
|
||||
&args("-a --error-format json -b").iter().collect::<Vec<_>>(),
|
||||
"--error-format"
|
||||
),
|
||||
["-a", "-b"]
|
||||
);
|
||||
assert_eq!(
|
||||
filter_arg(&args("-a -b -x").iter().collect::<Vec<_>>(), "--error-format"),
|
||||
["-a", "-b", "-x"]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ impl BuildKey for Invocation {
|
|||
let mut hash = DefaultHasher::new();
|
||||
|
||||
self.command.get_program().hash(&mut hash);
|
||||
let /*mut*/ args = self.command.get_args().to_owned();
|
||||
let /*mut*/ args = self.command.get_args().map(|a| a.to_owned()).collect::<Vec<_>>();
|
||||
// args.sort(); // TODO: parse 2-part args (e.g., `["--extern", "a=b"]`)
|
||||
args.hash(&mut hash);
|
||||
let mut envs: Vec<_> = self.command.get_envs().iter().collect();
|
||||
|
@ -417,10 +417,8 @@ fn guess_rustc_src_path(build_dir: &Path, cmd: &ProcessBuilder) -> Option<PathBu
|
|||
|
||||
let cwd = cmd.get_cwd().or_else(|| Some(build_dir));
|
||||
|
||||
let file = cmd
|
||||
.get_args()
|
||||
.iter()
|
||||
.find(|&a| Path::new(a).extension().map(|e| e == "rs").unwrap_or(false))?;
|
||||
let file =
|
||||
cmd.get_args().find(|&a| Path::new(a).extension().map(|e| e == "rs").unwrap_or(false))?;
|
||||
|
||||
src_path(cwd, file)
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ mod callbacks {
|
|||
rls_ipc::rpc::Edition::Edition2015 => crate::build::plan::Edition::Edition2015,
|
||||
rls_ipc::rpc::Edition::Edition2018 => crate::build::plan::Edition::Edition2018,
|
||||
rls_ipc::rpc::Edition::Edition2021 => crate::build::plan::Edition::Edition2021,
|
||||
rls_ipc::rpc::Edition::Edition2024 => crate::build::plan::Edition::Edition2024,
|
||||
},
|
||||
disambiguator: krate.disambiguator,
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ pub(crate) struct JobQueue(Vec<ProcessBuilder>);
|
|||
/// For example, if `[.., "--crate-name", "rls", ...]` arguments are specified,
|
||||
/// then proc_arg(prc, "--crate-name") returns Some(&OsStr::new("rls"));
|
||||
fn proc_argument_value<T: AsRef<OsStr>>(prc: &ProcessBuilder, key: T) -> Option<&std::ffi::OsStr> {
|
||||
let args = prc.get_args();
|
||||
let args = prc.get_args().collect::<Vec<_>>();
|
||||
let (idx, _) = args.iter().enumerate().find(|(_, arg)| arg.as_os_str() == key.as_ref())?;
|
||||
|
||||
Some(args.get(idx + 1)?.as_os_str())
|
||||
|
@ -125,7 +125,6 @@ impl JobQueue {
|
|||
trace!("Executing: {:#?}", job);
|
||||
let mut args: Vec<_> = job
|
||||
.get_args()
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|x| x.into_string().expect("cannot stringify job args"))
|
||||
.collect();
|
||||
|
@ -155,7 +154,7 @@ impl JobQueue {
|
|||
let crate_name = proc_argument_value(&job, "--crate-name").and_then(OsStr::to_str);
|
||||
let update = match crate_name {
|
||||
Some(name) => {
|
||||
let cfg_test = job.get_args().iter().any(|arg| arg == "--test");
|
||||
let cfg_test = job.get_args().any(|arg| *arg == "--test");
|
||||
ProgressUpdate::Message(if cfg_test {
|
||||
format!("{} cfg(test)", name)
|
||||
} else {
|
||||
|
@ -237,6 +236,7 @@ pub enum Edition {
|
|||
Edition2015,
|
||||
Edition2018,
|
||||
Edition2021,
|
||||
Edition2024,
|
||||
}
|
||||
|
||||
impl Default for Edition {
|
||||
|
@ -253,6 +253,7 @@ impl std::convert::TryFrom<&str> for Edition {
|
|||
"2015" => Edition::Edition2015,
|
||||
"2018" => Edition::Edition2018,
|
||||
"2021" => Edition::Edition2021,
|
||||
"2024" => Edition::Edition2024,
|
||||
_ => return Err("unknown"),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -255,6 +255,7 @@ impl rustc_driver::Callbacks for RlsRustcCalls {
|
|||
RustcEdition::Edition2015 => Edition::Edition2015,
|
||||
RustcEdition::Edition2018 => Edition::Edition2018,
|
||||
RustcEdition::Edition2021 => Edition::Edition2021,
|
||||
RustcEdition::Edition2024 => Edition::Edition2024,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue