Skip to content

Commit

Permalink
Auto merge of #117716 - GuillaumeGomez:rollup-83gnhll, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Rollup of 5 pull requests

Successful merges:

 - #117263 (handle the case when the change-id isn't found)
 - #117282 (Recover from incorrectly ordered/duplicated function keywords)
 - #117679 (tests/rustdoc-json: Avoid needless use of `no_core` and `lang_items`)
 - #117702 (target: move base and target specifications)
 - #117713 (Add test for reexported hidden item with `--document-hidden-items`)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Nov 8, 2023
2 parents 341efb1 + 9d3c802 commit 90fdc1f
Show file tree
Hide file tree
Showing 341 changed files with 706 additions and 712 deletions.
40 changes: 37 additions & 3 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2401,22 +2401,39 @@ impl<'a> Parser<'a> {
Misplaced(Span),
}

// We may be able to recover
let mut recover_constness = constness;
let mut recover_asyncness = asyncness;
let mut recover_unsafety = unsafety;
// This will allow the machine fix to directly place the keyword in the correct place or to indicate
// that the keyword is already present and the second instance should be removed.
let wrong_kw = if self.check_keyword(kw::Const) {
match constness {
Const::Yes(sp) => Some(WrongKw::Duplicated(sp)),
Const::No => Some(WrongKw::Misplaced(async_start_sp)),
Const::No => {
recover_constness = Const::Yes(self.token.span);
Some(WrongKw::Misplaced(async_start_sp))
}
}
} else if self.check_keyword(kw::Async) {
match asyncness {
Async::Yes { span, .. } => Some(WrongKw::Duplicated(span)),
Async::No => Some(WrongKw::Misplaced(unsafe_start_sp)),
Async::No => {
recover_asyncness = Async::Yes {
span: self.token.span,
closure_id: DUMMY_NODE_ID,
return_impl_trait_id: DUMMY_NODE_ID,
};
Some(WrongKw::Misplaced(unsafe_start_sp))
}
}
} else if self.check_keyword(kw::Unsafe) {
match unsafety {
Unsafe::Yes(sp) => Some(WrongKw::Duplicated(sp)),
Unsafe::No => Some(WrongKw::Misplaced(ext_start_sp)),
Unsafe::No => {
recover_unsafety = Unsafe::Yes(self.token.span);
Some(WrongKw::Misplaced(ext_start_sp))
}
}
} else {
None
Expand Down Expand Up @@ -2486,6 +2503,23 @@ impl<'a> Parser<'a> {
}
}
}

if wrong_kw.is_some()
&& self.may_recover()
&& self.look_ahead(1, |tok| tok.is_keyword_case(kw::Fn, case))
{
// Advance past the misplaced keyword and `fn`
self.bump();
self.bump();
err.emit();
return Ok(FnHeader {
constness: recover_constness,
unsafety: recover_unsafety,
asyncness: recover_asyncness,
ext,
});
}

return Err(err);
}
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/aarch64_fuchsia.rs

This file was deleted.

File renamed without changes.
5 changes: 0 additions & 5 deletions compiler/rustc_target/src/spec/avr_unknown_gnu_atmega328.rs

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::spec::{SanitizerSet, TargetOptions};
use crate::spec::{base, SanitizerSet, TargetOptions};

pub fn opts() -> TargetOptions {
let mut base = super::linux_base::opts();
let mut base = base::linux::opts();
base.os = "android".into();
base.is_like_android = true;
base.default_dwarf_version = 2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::{borrow::Cow, env};

use crate::spec::{add_link_args, add_link_args_iter};
use crate::spec::{cvs, Cc, DebuginfoKind, FramePointer, LinkArgs};
use crate::spec::{LinkerFlavor, Lld, SplitDebuginfo, StaticCow, Target, TargetOptions};

#[cfg(test)]
#[path = "apple/tests.rs"]
mod tests;

use Arch::*;
Expand Down Expand Up @@ -102,13 +102,13 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs {
LinkerFlavor::Darwin(Cc::No, Lld::No),
&["-arch", arch, "-platform_version"],
);
super::add_link_args_iter(
add_link_args_iter(
&mut args,
LinkerFlavor::Darwin(Cc::No, Lld::No),
[platform_name, platform_version.clone(), platform_version].into_iter(),
);
if abi != "macabi" {
super::add_link_args(&mut args, LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-arch", arch]);
add_link_args(&mut args, LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-arch", arch]);
}

args
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{
use crate::spec::targets::{
aarch64_apple_darwin, aarch64_apple_ios_sim, aarch64_apple_watchos_sim, i686_apple_darwin,
x86_64_apple_darwin, x86_64_apple_ios, x86_64_apple_tvos, x86_64_apple_watchos_sim,
};
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions compiler/rustc_target/src/spec/base/hurd_gnu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use crate::spec::{base, TargetOptions};

pub fn opts() -> TargetOptions {
TargetOptions { env: "gnu".into(), ..base::hurd::opts() }
}
File renamed without changes.
5 changes: 5 additions & 0 deletions compiler/rustc_target/src/spec/base/linux_gnu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use crate::spec::{base, TargetOptions};

pub fn opts() -> TargetOptions {
TargetOptions { env: "gnu".into(), ..base::linux::opts() }
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::spec::crt_objects;
use crate::spec::{LinkSelfContainedDefault, TargetOptions};
use crate::spec::{base, LinkSelfContainedDefault, TargetOptions};

pub fn opts() -> TargetOptions {
let mut base = super::linux_base::opts();
let mut base = base::linux::opts();

base.env = "musl".into();
base.pre_link_objects_self_contained = crt_objects::pre_musl_self_contained();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::spec::TargetOptions;
use crate::spec::{base, TargetOptions};

pub fn opts() -> TargetOptions {
let mut base = super::linux_base::opts();
let mut base = base::linux::opts();

base.env = "ohos".into();
base.crt_static_default = false;
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_target/src/spec/base/linux_uclibc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use crate::spec::{base, TargetOptions};

pub fn opts() -> TargetOptions {
TargetOptions { env: "uclibc".into(), ..base::linux::opts() }
}
37 changes: 37 additions & 0 deletions compiler/rustc_target/src/spec/base/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pub(crate) mod aix;
pub(crate) mod android;
pub(crate) mod apple;
pub(crate) mod avr_gnu;
pub(crate) mod bpf;
pub(crate) mod dragonfly;
pub(crate) mod freebsd;
pub(crate) mod fuchsia;
pub(crate) mod haiku;
pub(crate) mod hermit;
pub(crate) mod hurd;
pub(crate) mod hurd_gnu;
pub(crate) mod illumos;
pub(crate) mod l4re;
pub(crate) mod linux;
pub(crate) mod linux_gnu;
pub(crate) mod linux_musl;
pub(crate) mod linux_ohos;
pub(crate) mod linux_uclibc;
pub(crate) mod msvc;
pub(crate) mod netbsd;
pub(crate) mod nto_qnx;
pub(crate) mod openbsd;
pub(crate) mod redox;
pub(crate) mod solaris;
pub(crate) mod solid;
pub(crate) mod teeos;
pub(crate) mod thumb;
pub(crate) mod uefi_msvc;
pub(crate) mod unikraft_linux_musl;
pub(crate) mod vxworks;
pub(crate) mod wasm;
pub(crate) mod windows_gnu;
pub(crate) mod windows_gnullvm;
pub(crate) mod windows_msvc;
pub(crate) mod windows_uwp_gnu;
pub(crate) mod windows_uwp_msvc;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use super::FramePointer;
use crate::spec::TargetOptions;
use crate::spec::{FramePointer, TargetOptions};

pub fn opts(kernel: &str) -> TargetOptions {
TargetOptions {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use super::{Cc, LinkerFlavor, Lld, PanicStrategy};
use crate::spec::{RelroLevel, TargetOptions};
use crate::spec::{add_link_args, Cc, LinkerFlavor, Lld, PanicStrategy, RelroLevel, TargetOptions};

pub fn opts() -> TargetOptions {
let lld_args = &["-zmax-page-size=4096", "-znow", "-ztext", "--execute-only"];
let cc_args = &["-Wl,-zmax-page-size=4096", "-Wl,-znow", "-Wl,-ztext", "-mexecute-only"];

let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), lld_args);
super::add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), cc_args);
add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), cc_args);

TargetOptions {
os: "teeos".into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
// the timer-interrupt. Device-drivers are required to use polling-based models. Furthermore, all
// code runs in the same environment, no process separation is supported.

use crate::spec::{LinkerFlavor, Lld, PanicStrategy, StackProbeType, TargetOptions};
use crate::spec::{base, LinkerFlavor, Lld, PanicStrategy, StackProbeType, TargetOptions};

pub fn opts() -> TargetOptions {
let mut base = super::msvc_base::opts();
let mut base = base::msvc::opts();

base.add_pre_link_args(
LinkerFlavor::Msvc(Lld::No),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use super::LinkSelfContainedDefault;
use super::{cvs, Cc, LinkerFlavor, PanicStrategy, RelocModel, TargetOptions, TlsModel};
use crate::spec::{
add_link_args, cvs, Cc, LinkSelfContainedDefault, LinkerFlavor, PanicStrategy, RelocModel,
TargetOptions, TlsModel,
};

pub fn options() -> TargetOptions {
macro_rules! args {
Expand Down Expand Up @@ -50,7 +52,7 @@ pub fn options() -> TargetOptions {
}

let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::WasmLld(Cc::No), args!(""));
super::add_link_args(&mut pre_link_args, LinkerFlavor::WasmLld(Cc::Yes), args!("-Wl,"));
add_link_args(&mut pre_link_args, LinkerFlavor::WasmLld(Cc::Yes), args!("-Wl,"));

TargetOptions {
is_like_wasm: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::crt_objects;
use crate::spec::LinkSelfContainedDefault;
use crate::spec::{add_link_args, crt_objects};
use crate::spec::{cvs, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions};
use std::borrow::Cow;

Expand All @@ -13,7 +13,7 @@ pub fn opts() -> TargetOptions {
"--disable-auto-image-base",
],
);
super::add_link_args(
add_link_args(
&mut pre_link_args,
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
&[
Expand Down Expand Up @@ -45,14 +45,14 @@ pub fn opts() -> TargetOptions {
];
let mut late_link_args =
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), mingw_libs);
super::add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs);
add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs);
// If any of our crates are dynamically linked then we need to use
// the shared libgcc_s-dw2-1.dll. This is required to support
// unwinding across DLL boundaries.
let dynamic_unwind_libs = &["-lgcc_s"];
let mut late_link_args_dynamic =
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), dynamic_unwind_libs);
super::add_link_args(
add_link_args(
&mut late_link_args_dynamic,
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
dynamic_unwind_libs,
Expand All @@ -65,7 +65,7 @@ pub fn opts() -> TargetOptions {
let static_unwind_libs = &["-lgcc_eh", "-l:libpthread.a"];
let mut late_link_args_static =
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), static_unwind_libs);
super::add_link_args(
add_link_args(
&mut late_link_args_static,
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
static_unwind_libs,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::spec::{cvs, TargetOptions};
use crate::spec::{base, cvs, TargetOptions};

pub fn opts() -> TargetOptions {
let base = super::msvc_base::opts();
let base = base::msvc::opts();

TargetOptions {
os: "windows".into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::spec::{Cc, LinkArgs, LinkerFlavor, Lld, TargetOptions};
use crate::spec::{add_link_args, base, Cc, LinkArgs, LinkerFlavor, Lld, TargetOptions};

pub fn opts() -> TargetOptions {
let base = super::windows_gnu_base::opts();
let base = base::windows_gnu::opts();

// FIXME: This should be updated for the exception machinery changes from #67502
// and inherit from `windows_gnu_base`, at least partially.
Expand All @@ -17,7 +17,7 @@ pub fn opts() -> TargetOptions {
];
let mut late_link_args =
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), mingw_libs);
super::add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs);
add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs);
// Reset the flags back to empty until the FIXME above is addressed.
let late_link_args_dynamic = LinkArgs::new();
let late_link_args_static = LinkArgs::new();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::spec::{LinkerFlavor, Lld, TargetOptions};
use crate::spec::{base, LinkerFlavor, Lld, TargetOptions};

pub fn opts() -> TargetOptions {
let mut opts = super::windows_msvc_base::opts();
let mut opts = base::windows_msvc::opts();

opts.abi = "uwp".into();
opts.vendor = "uwp".into();
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_target/src/spec/hurd_gnu_base.rs

This file was deleted.

5 changes: 0 additions & 5 deletions compiler/rustc_target/src/spec/linux_gnu_base.rs

This file was deleted.

5 changes: 0 additions & 5 deletions compiler/rustc_target/src/spec/linux_uclibc_base.rs

This file was deleted.

Loading

0 comments on commit 90fdc1f

Please sign in to comment.