Skip to content

Rollup of 8 pull requests #104080

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

Closed
wants to merge 24 commits into from
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5965af7
rustdoc: render late-bound lifetimes in generic parameter list of cro…
fmease Nov 2, 2022
9cdab67
rustdoc: render unnamed arguments as underscores in cross-crate funct…
fmease Nov 2, 2022
2d9755f
rustdoc: move cross-crate lifetime/outlives bounds on GAT params from…
fmease Nov 2, 2022
1ac7034
rustdoc: render `for<>` param lists of cross-crate trait-object types
fmease Nov 2, 2022
71561f8
rustdoc: render the return type of cross-crate `Fn`-family trait boun…
fmease Nov 2, 2022
7ec50b6
rustdoc: add test for cross-crate trait-object types
fmease Nov 2, 2022
5ccaed2
rustdoc: create helper `GenericParamDef::lifetime`
fmease Nov 2, 2022
299bc61
Add type_array to BaseTypeMethods
Ayush1325 Nov 6, 2022
e15c406
fix: typo
Rejyr Nov 6, 2022
b34fdd3
rustdoc: remove unused CSS `#sidebar-filler`
notriddle Nov 6, 2022
24d86a1
Migrate rust logo filter to CSS variables
GuillaumeGomez Nov 6, 2022
f414715
LLVM 16: Update RISCV data layout
TimNN Nov 6, 2022
0e23d90
Extend rust-logo GUI test to check there is no filter for other logos
GuillaumeGomez Nov 6, 2022
dba6fc3
Make underscore_literal_suffix a hard error.
nnethercote Nov 3, 2022
f28875e
Distinguish `--dry-run` from the automatic dry run check
jyn514 Nov 6, 2022
fd1a393
Print "Checking/Building ..." message even when --dry-run is passed
jyn514 Nov 6, 2022
5fadbd0
Rollup merge of #103885 - fmease:rustdoc-various-cross-crate-reexport…
Nov 6, 2022
ceff97a
Rollup merge of #103914 - nnethercote:close-42326, r=petrochenkov
Nov 6, 2022
874e795
Rollup merge of #104045 - Ayush1325:type_array, r=nikic
Nov 6, 2022
77d938c
Rollup merge of #104059 - Rejyr:rustc_middle-lint-typo, r=petrochenkov
Nov 6, 2022
4d5860c
Rollup merge of #104062 - notriddle:notriddle/sidebar-filler, r=Guill…
Nov 6, 2022
94334d3
Rollup merge of #104065 - GuillaumeGomez:css-migrate-logo-filter, r=n…
Nov 6, 2022
6b59653
Rollup merge of #104066 - TimNN:riscv-layout, r=nikic
Nov 6, 2022
e35059d
Rollup merge of #104078 - jyn514:dry-run-progress, r=Mark-Simulacrum
Nov 6, 2022
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
42 changes: 21 additions & 21 deletions compiler/rustc_codegen_gcc/src/type_.rs
Original file line number Diff line number Diff line change
@@ -201,6 +201,27 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
fn val_ty(&self, value: RValue<'gcc>) -> Type<'gcc> {
value.get_type()
}

fn type_array(&self, ty: Type<'gcc>, mut len: u64) -> Type<'gcc> {
if let Some(struct_type) = ty.is_struct() {
if struct_type.get_field_count() == 0 {
// NOTE: since gccjit only supports i32 for the array size and libcore's tests uses a
// size of usize::MAX in test_binary_search, we workaround this by setting the size to
// zero for ZSTs.
// FIXME(antoyo): fix gccjit API.
len = 0;
}
}

// NOTE: see note above. Some other test uses usize::MAX.
if len == u64::MAX {
len = 0;
}

let len: i32 = len.try_into().expect("array len");

self.context.new_array_type(None, ty, len)
}
}

impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
@@ -227,27 +248,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
self.context.new_opaque_struct_type(None, name)
}

pub fn type_array(&self, ty: Type<'gcc>, mut len: u64) -> Type<'gcc> {
if let Some(struct_type) = ty.is_struct() {
if struct_type.get_field_count() == 0 {
// NOTE: since gccjit only supports i32 for the array size and libcore's tests uses a
// size of usize::MAX in test_binary_search, we workaround this by setting the size to
// zero for ZSTs.
// FIXME(antoyo): fix gccjit API.
len = 0;
}
}

// NOTE: see note above. Some other test uses usize::MAX.
if len == u64::MAX {
len = 0;
}

let len: i32 = len.try_into().expect("array len");

self.context.new_array_type(None, ty, len)
}

pub fn type_bool(&self) -> Type<'gcc> {
self.context.new_type::<bool>()
}
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
@@ -158,6 +158,10 @@ pub unsafe fn create_module<'ll>(
if sess.target.arch == "s390x" {
target_data_layout = target_data_layout.replace("-v128:64", "");
}

if sess.target.arch == "riscv64" {
target_data_layout = target_data_layout.replace("-n32:64-", "-n64-");
}
}

// Ensure the data-layout values hardcoded remain the defaults.
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_llvm/src/type_.rs
Original file line number Diff line number Diff line change
@@ -127,10 +127,6 @@ impl<'ll> CodegenCx<'ll, '_> {
pub(crate) fn type_variadic_func(&self, args: &[&'ll Type], ret: &'ll Type) -> &'ll Type {
unsafe { llvm::LLVMFunctionType(ret, args.as_ptr(), args.len() as c_uint, True) }
}

pub(crate) fn type_array(&self, ty: &'ll Type, len: u64) -> &'ll Type {
unsafe { llvm::LLVMRustArrayType(ty, len) }
}
}

impl<'ll, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
@@ -231,6 +227,10 @@ impl<'ll, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
fn val_ty(&self, v: &'ll Value) -> &'ll Type {
common::val_ty(v)
}

fn type_array(&self, ty: &'ll Type, len: u64) -> &'ll Type {
unsafe { llvm::LLVMRustArrayType(ty, len) }
}
}

impl Type {
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/traits/type_.rs
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ pub trait BaseTypeMethods<'tcx>: Backend<'tcx> {
fn type_f32(&self) -> Self::Type;
fn type_f64(&self) -> Self::Type;

fn type_array(&self, ty: Self::Type, len: u64) -> Self::Type;
fn type_func(&self, args: &[Self::Type], ret: Self::Type) -> Self::Type;
fn type_struct(&self, els: &[Self::Type], packed: bool) -> Self::Type;
fn type_kind(&self, ty: Self::Type) -> TypeKind;
9 changes: 6 additions & 3 deletions compiler/rustc_lexer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -88,7 +88,9 @@ pub enum TokenKind {
/// tokens.
UnknownPrefix,

/// Examples: `"12_u8"`, `"1.0e-40"`, `b"123`.
/// Examples: `12u8`, `1.0e-40`, `b"123"`. Note that `_` is an invalid
/// suffix, but may be present here on string and float literals. Users of
/// this type will need to check for and reject that case.
///
/// See [LiteralKind] for more details.
Literal { kind: LiteralKind, suffix_start: u32 },
@@ -840,12 +842,13 @@ impl Cursor<'_> {
self.eat_decimal_digits()
}

// Eats the suffix of the literal, e.g. "_u8".
// Eats the suffix of the literal, e.g. "u8".
fn eat_literal_suffix(&mut self) {
self.eat_identifier();
}

// Eats the identifier.
// Eats the identifier. Note: succeeds on `_`, which isn't a valid
// identifer.
fn eat_identifier(&mut self) {
if !is_id_start(self.first()) {
return;
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
@@ -276,7 +276,7 @@ pub fn explain_lint_level_source(

/// The innermost function for emitting lints.
///
/// If you are loocking to implement a lint, look for higher level functions,
/// If you are looking to implement a lint, look for higher level functions,
/// for example:
/// - [`TyCtxt::emit_spanned_lint`]
/// - [`TyCtxt::struct_span_lint_hir`]
12 changes: 1 addition & 11 deletions compiler/rustc_parse/src/lexer/mod.rs
Original file line number Diff line number Diff line change
@@ -175,20 +175,10 @@ impl<'a> StringReader<'a> {
if string == "_" {
self.sess
.span_diagnostic
.struct_span_warn(
.struct_span_err(
self.mk_sp(suffix_start, self.pos),
"underscore literal suffix is not allowed",
)
.warn(
"this was previously accepted by the compiler but is \
being phased out; it will become a hard error in \
a future release!",
)
.note(
"see issue #42326 \
<https://github.com/rust-lang/rust/issues/42326> \
for more information",
)
.emit();
None
} else {
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ pub fn target() -> Target {
Target {
llvm_target: "riscv64-unknown-freebsd".into(),
pointer_width: 64,
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
arch: "riscv64".into(),
options: TargetOptions {
code_model: Some(CodeModel::Medium),
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ pub fn target() -> Target {
Target {
llvm_target: "riscv64-unknown-linux-gnu".into(),
pointer_width: 64,
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
arch: "riscv64".into(),
options: TargetOptions {
code_model: Some(CodeModel::Medium),
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ pub fn target() -> Target {
Target {
llvm_target: "riscv64-unknown-linux-musl".into(),
pointer_width: 64,
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
arch: "riscv64".into(),
options: TargetOptions {
code_model: Some(CodeModel::Medium),
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ use crate::spec::{RelocModel, Target, TargetOptions};

pub fn target() -> Target {
Target {
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
llvm_target: "riscv64".into(),
pointer_width: 64,
arch: "riscv64".into(),
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ pub fn target() -> Target {
Target {
llvm_target: "riscv64-unknown-openbsd".into(),
pointer_width: 64,
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
arch: "riscv64".into(),
options: TargetOptions {
code_model: Some(CodeModel::Medium),
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ use crate::spec::{RelocModel, Target, TargetOptions};

pub fn target() -> Target {
Target {
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
llvm_target: "riscv64".into(),
pointer_width: 64,
arch: "riscv64".into(),
12 changes: 6 additions & 6 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
@@ -1073,11 +1073,11 @@ impl<'a> Builder<'a> {
let mut hasher = sha2::Sha256::new();
// FIXME: this is ok for rustfmt (4.1 MB large at time of writing), but it seems memory-intensive for rustc and larger components.
// Consider using streaming IO instead?
let contents = if self.config.dry_run { vec![] } else { t!(fs::read(path)) };
let contents = if self.config.dry_run() { vec![] } else { t!(fs::read(path)) };
hasher.update(&contents);
let found = hex::encode(hasher.finalize().as_slice());
let verified = found == expected;
if !verified && !self.config.dry_run {
if !verified && !self.config.dry_run() {
println!(
"invalid checksum: \n\
found: {found}\n\
@@ -1291,7 +1291,7 @@ impl<'a> Builder<'a> {
/// Note that this returns `None` if LLVM is disabled, or if we're in a
/// check build or dry-run, where there's no need to build all of LLVM.
fn llvm_config(&self, target: TargetSelection) -> Option<PathBuf> {
if self.config.llvm_enabled() && self.kind != Kind::Check && !self.config.dry_run {
if self.config.llvm_enabled() && self.kind != Kind::Check && !self.config.dry_run() {
let llvm_config = self.ensure(native::Llvm { target });
if llvm_config.is_file() {
return Some(llvm_config);
@@ -1643,7 +1643,7 @@ impl<'a> Builder<'a> {
//
// Only clear out the directory if we're compiling std; otherwise, we
// should let Cargo take care of things for us (via depdep info)
if !self.config.dry_run && mode == Mode::Std && cmd == "build" {
if !self.config.dry_run() && mode == Mode::Std && cmd == "build" {
self.clear_if_dirty(&out_dir, &self.rustc(compiler));
}

@@ -2141,7 +2141,7 @@ impl<'a> Builder<'a> {
(out, dur - deps)
};

if self.config.print_step_timings && !self.config.dry_run {
if self.config.print_step_timings && !self.config.dry_run() {
let step_string = format!("{:?}", step);
let brace_index = step_string.find("{").unwrap_or(0);
let type_string = type_name::<S>();
@@ -2215,7 +2215,7 @@ impl<'a> Builder<'a> {
}

pub(crate) fn open_in_browser(&self, path: impl AsRef<Path>) {
if self.config.dry_run || !self.config.cmd.open() {
if self.config.dry_run() || !self.config.cmd.open() {
return;
}

12 changes: 6 additions & 6 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
@@ -447,7 +447,7 @@ fn copy_sanitizers(
) -> Vec<PathBuf> {
let runtimes: Vec<native::SanitizerRuntime> = builder.ensure(native::Sanitizers { target });

if builder.config.dry_run {
if builder.config.dry_run() {
return Vec::new();
}

@@ -986,7 +986,7 @@ impl Step for CodegenBackend {
compiler.stage, backend, &compiler.host, target
));
let files = run_cargo(builder, cargo, vec![], &tmp_stamp, vec![], false);
if builder.config.dry_run {
if builder.config.dry_run() {
return;
}
let mut files = files.into_iter().filter(|f| {
@@ -1034,7 +1034,7 @@ fn copy_codegen_backends_to_sysroot(
let dst = builder.sysroot_codegen_backends(target_compiler);
t!(fs::create_dir_all(&dst), dst);

if builder.config.dry_run {
if builder.config.dry_run() {
return;
}

@@ -1332,7 +1332,7 @@ impl Step for Assemble {

if builder.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) {
let llvm_config_bin = builder.ensure(native::Llvm { target: target_compiler.host });
if !builder.config.dry_run {
if !builder.config.dry_run() {
let llvm_bin_dir = output(Command::new(llvm_config_bin).arg("--bindir"));
let llvm_bin_dir = Path::new(llvm_bin_dir.trim());

@@ -1402,7 +1402,7 @@ pub fn run_cargo(
additional_target_deps: Vec<(PathBuf, DependencyType)>,
is_check: bool,
) -> Vec<PathBuf> {
if builder.config.dry_run {
if builder.config.dry_run() {
return Vec::new();
}

@@ -1542,7 +1542,7 @@ pub fn stream_cargo(
cb: &mut dyn FnMut(CargoMessage<'_>),
) -> bool {
let mut cargo = Command::from(cargo);
if builder.config.dry_run {
if builder.config.dry_run() {
return true;
}
// Instruct Cargo to give us json messages on stdout, critically leaving
30 changes: 24 additions & 6 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
@@ -33,6 +33,17 @@ macro_rules! check_ci_llvm {
};
}

#[derive(Clone, Default)]
pub enum DryRun {
/// This isn't a dry run.
#[default]
Disabled,
/// This is a dry run enabled by bootstrap itself, so it can verify that no work is done.
SelfCheck,
/// This is a dry run enabled by the `--dry-run` flag.
UserSelected,
}

/// Global configuration for the entire build and/or bootstrap.
///
/// This structure is derived from a combination of both `config.toml` and
@@ -84,7 +95,7 @@ pub struct Config {
pub jobs: Option<u32>,
pub cmd: Subcommand,
pub incremental: bool,
pub dry_run: bool,
pub dry_run: DryRun,
/// `None` if we shouldn't download CI compiler artifacts, or the commit to download if we should.
#[cfg(not(test))]
download_rustc_commit: Option<String>,
@@ -820,7 +831,7 @@ impl Config {
config.jobs = flags.jobs.map(threads_from_config);
config.cmd = flags.cmd;
config.incremental = flags.incremental;
config.dry_run = flags.dry_run;
config.dry_run = if flags.dry_run { DryRun::UserSelected } else { DryRun::Disabled };
config.keep_stage = flags.keep_stage;
config.keep_stage_std = flags.keep_stage_std;
config.color = flags.color;
@@ -964,7 +975,7 @@ impl Config {
.unwrap_or_else(|| config.out.join(config.build.triple).join("stage0/bin/cargo"));

// NOTE: it's important this comes *after* we set `initial_rustc` just above.
if config.dry_run {
if config.dry_run() {
let dir = config.out.join("tmp-dry-run");
t!(fs::create_dir_all(&dir));
config.out = dir;
@@ -1371,6 +1382,13 @@ impl Config {
config
}

pub(crate) fn dry_run(&self) -> bool {
match self.dry_run {
DryRun::Disabled => false,
DryRun::SelfCheck | DryRun::UserSelected => true,
}
}

/// A git invocation which runs inside the source directory.
///
/// Use this rather than `Command::new("git")` in order to support out-of-tree builds.
@@ -1460,7 +1478,7 @@ impl Config {
/// This is computed on demand since LLVM might have to first be downloaded from CI.
pub(crate) fn llvm_link_shared(builder: &Builder<'_>) -> bool {
let mut opt = builder.config.llvm_link_shared.get();
if opt.is_none() && builder.config.dry_run {
if opt.is_none() && builder.config.dry_run() {
// just assume static for now - dynamic linking isn't supported on all platforms
return false;
}
@@ -1487,7 +1505,7 @@ impl Config {
/// Return whether we will use a downloaded, pre-compiled version of rustc, or just build from source.
pub(crate) fn download_rustc(builder: &Builder<'_>) -> bool {
static DOWNLOAD_RUSTC: OnceCell<bool> = OnceCell::new();
if builder.config.dry_run && DOWNLOAD_RUSTC.get().is_none() {
if builder.config.dry_run() && DOWNLOAD_RUSTC.get().is_none() {
// avoid trying to actually download the commit
return false;
}
@@ -1506,7 +1524,7 @@ impl Config {
RustfmtState::SystemToolchain(p) | RustfmtState::Downloaded(p) => Some(p.clone()),
RustfmtState::Unavailable => None,
r @ RustfmtState::LazyEvaluated => {
if builder.config.dry_run {
if builder.config.dry_run() {
return Some(PathBuf::new());
}
let path = maybe_download_rustfmt(builder);
Loading