Skip to content
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

Rollup of 6 pull requests #117714

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
be0b42f
Recover from incorrectly ordered/duplicated function keywords
clubby789 Oct 27, 2023
f784fa7
tests/rustdoc-json: Remove some needless uses of `#![no_core]`.
aDotInTheVoid Nov 7, 2023
0875f45
tests/rustdoc-json: Remove more needless uses of `#![no_core]`.
aDotInTheVoid Nov 7, 2023
434b69a
tests/rustdoc-json: Rewrite tests no not use `#![no_core]`.
aDotInTheVoid Nov 7, 2023
94eb6b0
Move `BorrowedBuf` and `BorrowedCursor` from `std:io` to `core::io`
jmillikin Nov 8, 2023
76aa83e
target: move base specs to spec/base
davidtwco Nov 8, 2023
1af256f
targets: move target specs to spec/targets
davidtwco Nov 8, 2023
ef7ebaa
rustc_target: move file for uniformity
davidtwco Nov 8, 2023
ae4d18b
handle the case when the change-id isn't found
onur-ozkan Oct 27, 2023
e878100
bootstrap: improve `fn check_version`
onur-ozkan Oct 27, 2023
e0cb1cc
bootstrap: add more detail on change-id comments
onur-ozkan Nov 7, 2023
33edea6
Add test for reexported hidden item with `--document-hidden-items`
GuillaumeGomez Nov 8, 2023
fb31b00
Rollup merge of #117263 - onur-ozkan:change-id-fix, r=saethlin
GuillaumeGomez Nov 8, 2023
fb50ed7
Rollup merge of #117282 - clubby789:recover-wrong-function-header, r=…
GuillaumeGomez Nov 8, 2023
301b4ed
Rollup merge of #117679 - aDotInTheVoid:yes-core, r=GuillaumeGomez
GuillaumeGomez Nov 8, 2023
2627f72
Rollup merge of #117694 - jmillikin:core-io-borrowed-buf, r=m-ou-se
GuillaumeGomez Nov 8, 2023
259b749
Rollup merge of #117702 - davidtwco:target-tier-refactors, r=petroche…
GuillaumeGomez Nov 8, 2023
bf09474
Rollup merge of #117713 - GuillaumeGomez:document-hidden-json, r=notr…
GuillaumeGomez Nov 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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: 1 addition & 0 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(array_windows)]
#![feature(cfg_match)]
#![feature(core_io_borrowed_buf)]
#![feature(if_let_guard)]
#![feature(let_chains)]
#![feature(min_specialization)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/aarch64_fuchsia.rs

This file was deleted.

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

This file was deleted.

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
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() }
}
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;
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
Loading