mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Auto merge of #107546 - matthiaskrgr:rollup-9rgf2gx, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #107389 (Fixing confusion between mod and remainder) - #107442 (improve panic message for slice windows and chunks) - #107470 (Small bootstrap improvements) - #107487 (Make the "extra if in let...else block" hint a suggestion) - #107499 (Do not depend on Generator trait when deducing closure signature) - #107533 (Extend `-Z print-type-sizes` to distinguish generator upvars+locals from "normal" fields.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
3b639486c1
@ -15,6 +15,7 @@ use rustc_middle::ty::visit::TypeVisitable;
|
||||
use rustc_middle::ty::{self, Ty, TypeSuperVisitable, TypeVisitor};
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::sym;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use rustc_trait_selection::traits;
|
||||
use rustc_trait_selection::traits::error_reporting::ArgKind;
|
||||
@ -288,21 +289,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let trait_def_id = projection.trait_def_id(tcx);
|
||||
|
||||
let is_fn = tcx.is_fn_trait(trait_def_id);
|
||||
let gen_trait = tcx.require_lang_item(LangItem::Generator, cause_span);
|
||||
let is_gen = gen_trait == trait_def_id;
|
||||
|
||||
let gen_trait = tcx.lang_items().gen_trait();
|
||||
let is_gen = gen_trait == Some(trait_def_id);
|
||||
|
||||
if !is_fn && !is_gen {
|
||||
debug!("not fn or generator");
|
||||
return None;
|
||||
}
|
||||
|
||||
if is_gen {
|
||||
// Check that we deduce the signature from the `<_ as std::ops::Generator>::Return`
|
||||
// associated item and not yield.
|
||||
let return_assoc_item = self.tcx.associated_item_def_ids(gen_trait)[1];
|
||||
if return_assoc_item != projection.projection_def_id() {
|
||||
debug!("not return assoc item of generator");
|
||||
return None;
|
||||
}
|
||||
// Check that we deduce the signature from the `<_ as std::ops::Generator>::Return`
|
||||
// associated item and not yield.
|
||||
if is_gen && self.tcx.associated_item(projection.projection_def_id()).name != sym::Return {
|
||||
debug!("not `Return` assoc item of `Generator`");
|
||||
return None;
|
||||
}
|
||||
|
||||
let input_tys = if is_fn {
|
||||
|
@ -335,7 +335,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
format!("cannot divide `{lhs_ty}` by `{rhs_ty}`")
|
||||
}
|
||||
hir::BinOpKind::Rem => {
|
||||
format!("cannot mod `{lhs_ty}` by `{rhs_ty}`")
|
||||
format!(
|
||||
"cannot calculate the remainder of `{lhs_ty}` divided by `{rhs_ty}`"
|
||||
)
|
||||
}
|
||||
hir::BinOpKind::BitAnd => {
|
||||
format!("no implementation for `{lhs_ty} & {rhs_ty}`")
|
||||
|
@ -351,7 +351,7 @@ pub(crate) enum IfExpressionMissingThenBlockSub {
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[help(parse_extra_if_in_let_else)]
|
||||
#[suggestion(parse_extra_if_in_let_else, applicability = "maybe-incorrect", code = "")]
|
||||
pub(crate) struct IfExpressionLetSomeSub {
|
||||
#[primary_span]
|
||||
pub if_span: Span,
|
||||
|
@ -2290,7 +2290,7 @@ impl<'a> Parser<'a> {
|
||||
block
|
||||
} else {
|
||||
let let_else_sub = matches!(cond.kind, ExprKind::Let(..))
|
||||
.then(|| IfExpressionLetSomeSub { if_span: lo });
|
||||
.then(|| IfExpressionLetSomeSub { if_span: lo.until(cond_span) });
|
||||
|
||||
self.sess.emit_err(IfExpressionMissingThenBlock {
|
||||
if_span: lo,
|
||||
|
@ -19,8 +19,26 @@ pub enum SizeKind {
|
||||
Min,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
||||
pub enum FieldKind {
|
||||
AdtField,
|
||||
Upvar,
|
||||
GeneratorLocal,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for FieldKind {
|
||||
fn fmt(&self, w: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
FieldKind::AdtField => write!(w, "field"),
|
||||
FieldKind::Upvar => write!(w, "upvar"),
|
||||
FieldKind::GeneratorLocal => write!(w, "local"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
||||
pub struct FieldInfo {
|
||||
pub kind: FieldKind,
|
||||
pub name: Symbol,
|
||||
pub offset: u64,
|
||||
pub size: u64,
|
||||
@ -145,7 +163,7 @@ impl CodeStats {
|
||||
fields.sort_by_key(|f| (f.offset, f.size));
|
||||
|
||||
for field in fields {
|
||||
let FieldInfo { ref name, offset, size, align } = field;
|
||||
let FieldInfo { kind, ref name, offset, size, align } = field;
|
||||
|
||||
if offset > min_offset {
|
||||
let pad = offset - min_offset;
|
||||
@ -155,16 +173,16 @@ impl CodeStats {
|
||||
if offset < min_offset {
|
||||
// If this happens it's probably a union.
|
||||
println!(
|
||||
"print-type-size {indent}field `.{name}`: {size} bytes, \
|
||||
"print-type-size {indent}{kind} `.{name}`: {size} bytes, \
|
||||
offset: {offset} bytes, \
|
||||
alignment: {align} bytes"
|
||||
);
|
||||
} else if info.packed || offset == min_offset {
|
||||
println!("print-type-size {indent}field `.{name}`: {size} bytes");
|
||||
println!("print-type-size {indent}{kind} `.{name}`: {size} bytes");
|
||||
} else {
|
||||
// Include field alignment in output only if it caused padding injection
|
||||
println!(
|
||||
"print-type-size {indent}field `.{name}`: {size} bytes, \
|
||||
"print-type-size {indent}{kind} `.{name}`: {size} bytes, \
|
||||
alignment: {align} bytes"
|
||||
);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::cgu_reuse_tracker::CguReuseTracker;
|
||||
use crate::code_stats::CodeStats;
|
||||
pub use crate::code_stats::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
|
||||
pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo};
|
||||
use crate::config::Input;
|
||||
use crate::config::{self, CrateType, InstrumentCoverage, OptLevel, OutputType, SwitchWithOptPath};
|
||||
use crate::errors::{
|
||||
|
@ -9,7 +9,7 @@ use rustc_middle::ty::layout::{
|
||||
use rustc_middle::ty::{
|
||||
self, subst::SubstsRef, AdtDef, EarlyBinder, ReprOptions, Ty, TyCtxt, TypeVisitable,
|
||||
};
|
||||
use rustc_session::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
|
||||
use rustc_session::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::DUMMY_SP;
|
||||
use rustc_target::abi::*;
|
||||
@ -881,6 +881,7 @@ fn variant_info_for_adt<'tcx>(
|
||||
let offset = layout.fields.offset(i);
|
||||
min_size = min_size.max(offset + field_layout.size);
|
||||
FieldInfo {
|
||||
kind: FieldKind::AdtField,
|
||||
name,
|
||||
offset: offset.bytes(),
|
||||
size: field_layout.size.bytes(),
|
||||
@ -960,6 +961,7 @@ fn variant_info_for_generator<'tcx>(
|
||||
let offset = layout.fields.offset(field_idx);
|
||||
upvars_size = upvars_size.max(offset + field_layout.size);
|
||||
FieldInfo {
|
||||
kind: FieldKind::Upvar,
|
||||
name: Symbol::intern(&name),
|
||||
offset: offset.bytes(),
|
||||
size: field_layout.size.bytes(),
|
||||
@ -983,6 +985,7 @@ fn variant_info_for_generator<'tcx>(
|
||||
// The struct is as large as the last field's end
|
||||
variant_size = variant_size.max(offset + field_layout.size);
|
||||
FieldInfo {
|
||||
kind: FieldKind::GeneratorLocal,
|
||||
name: state_specific_names.get(*local).copied().flatten().unwrap_or(
|
||||
Symbol::intern(&format!(".generator_field{}", local.as_usize())),
|
||||
),
|
||||
|
@ -545,7 +545,7 @@ div_impl_float! { f32 f64 }
|
||||
#[lang = "rem"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_on_unimplemented(
|
||||
message = "cannot mod `{Self}` by `{Rhs}`",
|
||||
message = "cannot calculate the remainder of `{Self}` divided by `{Rhs}`",
|
||||
label = "no implementation for `{Self} % {Rhs}`"
|
||||
)]
|
||||
#[doc(alias = "%")]
|
||||
@ -981,7 +981,7 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
#[lang = "rem_assign"]
|
||||
#[stable(feature = "op_assign_traits", since = "1.8.0")]
|
||||
#[rustc_on_unimplemented(
|
||||
message = "cannot mod-assign `{Self}` by `{Rhs}``",
|
||||
message = "cannot calculate and assign the remainder of `{Self}` divided by `{Rhs}`",
|
||||
label = "no implementation for `{Self} %= {Rhs}`"
|
||||
)]
|
||||
#[doc(alias = "%")]
|
||||
|
@ -805,8 +805,9 @@ impl<T> [T] {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn windows(&self, size: usize) -> Windows<'_, T> {
|
||||
let size = NonZeroUsize::new(size).expect("size is zero");
|
||||
let size = NonZeroUsize::new(size).expect("window size must be non-zero");
|
||||
Windows::new(self, size)
|
||||
}
|
||||
|
||||
@ -839,8 +840,9 @@ impl<T> [T] {
|
||||
/// [`rchunks`]: slice::rchunks
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn chunks(&self, chunk_size: usize) -> Chunks<'_, T> {
|
||||
assert_ne!(chunk_size, 0, "chunks cannot have a size of zero");
|
||||
assert!(chunk_size != 0, "chunk size must be non-zero");
|
||||
Chunks::new(self, chunk_size)
|
||||
}
|
||||
|
||||
@ -877,8 +879,9 @@ impl<T> [T] {
|
||||
/// [`rchunks_mut`]: slice::rchunks_mut
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<'_, T> {
|
||||
assert_ne!(chunk_size, 0, "chunks cannot have a size of zero");
|
||||
assert!(chunk_size != 0, "chunk size must be non-zero");
|
||||
ChunksMut::new(self, chunk_size)
|
||||
}
|
||||
|
||||
@ -914,8 +917,9 @@ impl<T> [T] {
|
||||
/// [`rchunks_exact`]: slice::rchunks_exact
|
||||
#[stable(feature = "chunks_exact", since = "1.31.0")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn chunks_exact(&self, chunk_size: usize) -> ChunksExact<'_, T> {
|
||||
assert_ne!(chunk_size, 0, "chunks cannot have a size of zero");
|
||||
assert!(chunk_size != 0, "chunk size must be non-zero");
|
||||
ChunksExact::new(self, chunk_size)
|
||||
}
|
||||
|
||||
@ -956,8 +960,9 @@ impl<T> [T] {
|
||||
/// [`rchunks_exact_mut`]: slice::rchunks_exact_mut
|
||||
#[stable(feature = "chunks_exact", since = "1.31.0")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn chunks_exact_mut(&mut self, chunk_size: usize) -> ChunksExactMut<'_, T> {
|
||||
assert_ne!(chunk_size, 0, "chunks cannot have a size of zero");
|
||||
assert!(chunk_size != 0, "chunk size must be non-zero");
|
||||
ChunksExactMut::new(self, chunk_size)
|
||||
}
|
||||
|
||||
@ -1037,9 +1042,10 @@ impl<T> [T] {
|
||||
/// ```
|
||||
#[unstable(feature = "slice_as_chunks", issue = "74985")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[must_use]
|
||||
pub fn as_chunks<const N: usize>(&self) -> (&[[T; N]], &[T]) {
|
||||
assert_ne!(N, 0, "chunks cannot have a size of zero");
|
||||
assert!(N != 0, "chunk size must be non-zero");
|
||||
let len = self.len() / N;
|
||||
let (multiple_of_n, remainder) = self.split_at(len * N);
|
||||
// SAFETY: We already panicked for zero, and ensured by construction
|
||||
@ -1068,9 +1074,10 @@ impl<T> [T] {
|
||||
/// ```
|
||||
#[unstable(feature = "slice_as_chunks", issue = "74985")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[must_use]
|
||||
pub fn as_rchunks<const N: usize>(&self) -> (&[T], &[[T; N]]) {
|
||||
assert_ne!(N, 0, "chunks cannot have a size of zero");
|
||||
assert!(N != 0, "chunk size must be non-zero");
|
||||
let len = self.len() / N;
|
||||
let (remainder, multiple_of_n) = self.split_at(self.len() - len * N);
|
||||
// SAFETY: We already panicked for zero, and ensured by construction
|
||||
@ -1108,8 +1115,9 @@ impl<T> [T] {
|
||||
/// [`chunks_exact`]: slice::chunks_exact
|
||||
#[unstable(feature = "array_chunks", issue = "74985")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn array_chunks<const N: usize>(&self) -> ArrayChunks<'_, T, N> {
|
||||
assert_ne!(N, 0, "chunks cannot have a size of zero");
|
||||
assert!(N != 0, "chunk size must be non-zero");
|
||||
ArrayChunks::new(self)
|
||||
}
|
||||
|
||||
@ -1186,9 +1194,10 @@ impl<T> [T] {
|
||||
/// ```
|
||||
#[unstable(feature = "slice_as_chunks", issue = "74985")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[must_use]
|
||||
pub fn as_chunks_mut<const N: usize>(&mut self) -> (&mut [[T; N]], &mut [T]) {
|
||||
assert_ne!(N, 0, "chunks cannot have a size of zero");
|
||||
assert!(N != 0, "chunk size must be non-zero");
|
||||
let len = self.len() / N;
|
||||
let (multiple_of_n, remainder) = self.split_at_mut(len * N);
|
||||
// SAFETY: We already panicked for zero, and ensured by construction
|
||||
@ -1223,9 +1232,10 @@ impl<T> [T] {
|
||||
/// ```
|
||||
#[unstable(feature = "slice_as_chunks", issue = "74985")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[must_use]
|
||||
pub fn as_rchunks_mut<const N: usize>(&mut self) -> (&mut [T], &mut [[T; N]]) {
|
||||
assert_ne!(N, 0, "chunks cannot have a size of zero");
|
||||
assert!(N != 0, "chunk size must be non-zero");
|
||||
let len = self.len() / N;
|
||||
let (remainder, multiple_of_n) = self.split_at_mut(self.len() - len * N);
|
||||
// SAFETY: We already panicked for zero, and ensured by construction
|
||||
@ -1265,8 +1275,9 @@ impl<T> [T] {
|
||||
/// [`chunks_exact_mut`]: slice::chunks_exact_mut
|
||||
#[unstable(feature = "array_chunks", issue = "74985")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn array_chunks_mut<const N: usize>(&mut self) -> ArrayChunksMut<'_, T, N> {
|
||||
assert_ne!(N, 0, "chunks cannot have a size of zero");
|
||||
assert!(N != 0, "chunk size must be non-zero");
|
||||
ArrayChunksMut::new(self)
|
||||
}
|
||||
|
||||
@ -1297,8 +1308,9 @@ impl<T> [T] {
|
||||
/// [`windows`]: slice::windows
|
||||
#[unstable(feature = "array_windows", issue = "75027")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn array_windows<const N: usize>(&self) -> ArrayWindows<'_, T, N> {
|
||||
assert_ne!(N, 0, "windows cannot have a size of zero");
|
||||
assert!(N != 0, "window size must be non-zero");
|
||||
ArrayWindows::new(self)
|
||||
}
|
||||
|
||||
@ -1331,8 +1343,9 @@ impl<T> [T] {
|
||||
/// [`chunks`]: slice::chunks
|
||||
#[stable(feature = "rchunks", since = "1.31.0")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn rchunks(&self, chunk_size: usize) -> RChunks<'_, T> {
|
||||
assert!(chunk_size != 0);
|
||||
assert!(chunk_size != 0, "chunk size must be non-zero");
|
||||
RChunks::new(self, chunk_size)
|
||||
}
|
||||
|
||||
@ -1369,8 +1382,9 @@ impl<T> [T] {
|
||||
/// [`chunks_mut`]: slice::chunks_mut
|
||||
#[stable(feature = "rchunks", since = "1.31.0")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn rchunks_mut(&mut self, chunk_size: usize) -> RChunksMut<'_, T> {
|
||||
assert!(chunk_size != 0);
|
||||
assert!(chunk_size != 0, "chunk size must be non-zero");
|
||||
RChunksMut::new(self, chunk_size)
|
||||
}
|
||||
|
||||
@ -1408,8 +1422,9 @@ impl<T> [T] {
|
||||
/// [`chunks_exact`]: slice::chunks_exact
|
||||
#[stable(feature = "rchunks", since = "1.31.0")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn rchunks_exact(&self, chunk_size: usize) -> RChunksExact<'_, T> {
|
||||
assert!(chunk_size != 0);
|
||||
assert!(chunk_size != 0, "chunk size must be non-zero");
|
||||
RChunksExact::new(self, chunk_size)
|
||||
}
|
||||
|
||||
@ -1451,8 +1466,9 @@ impl<T> [T] {
|
||||
/// [`chunks_exact_mut`]: slice::chunks_exact_mut
|
||||
#[stable(feature = "rchunks", since = "1.31.0")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn rchunks_exact_mut(&mut self, chunk_size: usize) -> RChunksExactMut<'_, T> {
|
||||
assert!(chunk_size != 0);
|
||||
assert!(chunk_size != 0, "chunk size must be non-zero");
|
||||
RChunksExactMut::new(self, chunk_size)
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ from __future__ import absolute_import, division, print_function
|
||||
import argparse
|
||||
import contextlib
|
||||
import datetime
|
||||
import distutils.version
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
@ -13,17 +12,17 @@ import sys
|
||||
import tarfile
|
||||
import tempfile
|
||||
|
||||
from time import time, sleep
|
||||
from time import time
|
||||
|
||||
def support_xz():
|
||||
try:
|
||||
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
||||
temp_path = temp_file.name
|
||||
with tarfile.open(temp_path, "w:xz"):
|
||||
pass
|
||||
return True
|
||||
except tarfile.CompressionError:
|
||||
return False
|
||||
try:
|
||||
import lzma
|
||||
except ImportError:
|
||||
lzma = None
|
||||
|
||||
if sys.platform == 'win32':
|
||||
EXE_SUFFIX = ".exe"
|
||||
else:
|
||||
EXE_SUFFIX = ""
|
||||
|
||||
def get(base, url, path, checksums, verbose=False):
|
||||
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
||||
@ -61,7 +60,7 @@ def get(base, url, path, checksums, verbose=False):
|
||||
|
||||
|
||||
def download(path, url, probably_big, verbose):
|
||||
for _ in range(0, 4):
|
||||
for _ in range(4):
|
||||
try:
|
||||
_download(path, url, probably_big, verbose, True)
|
||||
return
|
||||
@ -395,17 +394,18 @@ class RustBuild(object):
|
||||
def __init__(self):
|
||||
self.checksums_sha256 = {}
|
||||
self.stage0_compiler = None
|
||||
self._download_url = ''
|
||||
self.download_url = ''
|
||||
self.build = ''
|
||||
self.build_dir = ''
|
||||
self.clean = False
|
||||
self.config_toml = ''
|
||||
self.rust_root = ''
|
||||
self.use_locked_deps = ''
|
||||
self.use_vendored_sources = ''
|
||||
self.use_locked_deps = False
|
||||
self.use_vendored_sources = False
|
||||
self.verbose = False
|
||||
self.git_version = None
|
||||
self.nix_deps_dir = None
|
||||
self._should_fix_bins_and_dylibs = None
|
||||
|
||||
def download_toolchain(self):
|
||||
"""Fetch the build system for Rust, written in Rust
|
||||
@ -426,7 +426,7 @@ class RustBuild(object):
|
||||
self.program_out_of_date(self.rustc_stamp(), key)):
|
||||
if os.path.exists(bin_root):
|
||||
shutil.rmtree(bin_root)
|
||||
tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz'
|
||||
tarball_suffix = '.tar.gz' if lzma is None else '.tar.xz'
|
||||
filename = "rust-std-{}-{}{}".format(
|
||||
rustc_channel, self.build, tarball_suffix)
|
||||
pattern = "rust-std-{}".format(self.build)
|
||||
@ -437,15 +437,17 @@ class RustBuild(object):
|
||||
filename = "cargo-{}-{}{}".format(rustc_channel, self.build,
|
||||
tarball_suffix)
|
||||
self._download_component_helper(filename, "cargo", tarball_suffix)
|
||||
self.fix_bin_or_dylib("{}/bin/cargo".format(bin_root))
|
||||
if self.should_fix_bins_and_dylibs():
|
||||
self.fix_bin_or_dylib("{}/bin/cargo".format(bin_root))
|
||||
|
||||
self.fix_bin_or_dylib("{}/bin/rustc".format(bin_root))
|
||||
self.fix_bin_or_dylib("{}/bin/rustdoc".format(bin_root))
|
||||
self.fix_bin_or_dylib("{}/libexec/rust-analyzer-proc-macro-srv".format(bin_root))
|
||||
lib_dir = "{}/lib".format(bin_root)
|
||||
for lib in os.listdir(lib_dir):
|
||||
if lib.endswith(".so"):
|
||||
self.fix_bin_or_dylib(os.path.join(lib_dir, lib))
|
||||
|
||||
self.fix_bin_or_dylib("{}/bin/rustc".format(bin_root))
|
||||
self.fix_bin_or_dylib("{}/bin/rustdoc".format(bin_root))
|
||||
self.fix_bin_or_dylib("{}/libexec/rust-analyzer-proc-macro-srv".format(bin_root))
|
||||
lib_dir = "{}/lib".format(bin_root)
|
||||
for lib in os.listdir(lib_dir):
|
||||
if lib.endswith(".so"):
|
||||
self.fix_bin_or_dylib(os.path.join(lib_dir, lib))
|
||||
with output(self.rustc_stamp()) as rust_stamp:
|
||||
rust_stamp.write(key)
|
||||
|
||||
@ -458,19 +460,62 @@ class RustBuild(object):
|
||||
if not os.path.exists(rustc_cache):
|
||||
os.makedirs(rustc_cache)
|
||||
|
||||
base = self._download_url
|
||||
url = "dist/{}".format(key)
|
||||
tarball = os.path.join(rustc_cache, filename)
|
||||
if not os.path.exists(tarball):
|
||||
get(
|
||||
base,
|
||||
"{}/{}".format(url, filename),
|
||||
self.download_url,
|
||||
"dist/{}/{}".format(key, filename),
|
||||
tarball,
|
||||
self.checksums_sha256,
|
||||
verbose=self.verbose,
|
||||
)
|
||||
unpack(tarball, tarball_suffix, self.bin_root(), match=pattern, verbose=self.verbose)
|
||||
|
||||
def should_fix_bins_and_dylibs(self):
|
||||
"""Whether or not `fix_bin_or_dylib` needs to be run; can only be True
|
||||
on NixOS.
|
||||
"""
|
||||
if self._should_fix_bins_and_dylibs is not None:
|
||||
return self._should_fix_bins_and_dylibs
|
||||
|
||||
def get_answer():
|
||||
default_encoding = sys.getdefaultencoding()
|
||||
try:
|
||||
ostype = subprocess.check_output(
|
||||
['uname', '-s']).strip().decode(default_encoding)
|
||||
except subprocess.CalledProcessError:
|
||||
return False
|
||||
except OSError as reason:
|
||||
if getattr(reason, 'winerror', None) is not None:
|
||||
return False
|
||||
raise reason
|
||||
|
||||
if ostype != "Linux":
|
||||
return False
|
||||
|
||||
# If the user has asked binaries to be patched for Nix, then
|
||||
# don't check for NixOS or `/lib`.
|
||||
if self.get_toml("patch-binaries-for-nix", "build") == "true":
|
||||
return True
|
||||
|
||||
# Use `/etc/os-release` instead of `/etc/NIXOS`.
|
||||
# The latter one does not exist on NixOS when using tmpfs as root.
|
||||
try:
|
||||
with open("/etc/os-release", "r") as f:
|
||||
if not any(l.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"') for l in f):
|
||||
return False
|
||||
except FileNotFoundError:
|
||||
return False
|
||||
if os.path.exists("/lib"):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
answer = self._should_fix_bins_and_dylibs = get_answer()
|
||||
if answer:
|
||||
print("info: You seem to be using Nix.")
|
||||
return answer
|
||||
|
||||
def fix_bin_or_dylib(self, fname):
|
||||
"""Modifies the interpreter section of 'fname' to fix the dynamic linker,
|
||||
or the RPATH section, to fix the dynamic library search path
|
||||
@ -480,38 +525,8 @@ class RustBuild(object):
|
||||
|
||||
Please see https://nixos.org/patchelf.html for more information
|
||||
"""
|
||||
default_encoding = sys.getdefaultencoding()
|
||||
try:
|
||||
ostype = subprocess.check_output(
|
||||
['uname', '-s']).strip().decode(default_encoding)
|
||||
except subprocess.CalledProcessError:
|
||||
return
|
||||
except OSError as reason:
|
||||
if getattr(reason, 'winerror', None) is not None:
|
||||
return
|
||||
raise reason
|
||||
|
||||
if ostype != "Linux":
|
||||
return
|
||||
|
||||
# If the user has asked binaries to be patched for Nix, then
|
||||
# don't check for NixOS or `/lib`, just continue to the patching.
|
||||
if self.get_toml('patch-binaries-for-nix', 'build') != 'true':
|
||||
# Use `/etc/os-release` instead of `/etc/NIXOS`.
|
||||
# The latter one does not exist on NixOS when using tmpfs as root.
|
||||
try:
|
||||
with open("/etc/os-release", "r") as f:
|
||||
if not any(l.strip() in ["ID=nixos", "ID='nixos'", 'ID="nixos"'] for l in f):
|
||||
return
|
||||
except FileNotFoundError:
|
||||
return
|
||||
if os.path.exists("/lib"):
|
||||
return
|
||||
|
||||
# At this point we're pretty sure the user is running NixOS or
|
||||
# using Nix
|
||||
nix_os_msg = "info: you seem to be using Nix. Attempting to patch"
|
||||
print(nix_os_msg, fname)
|
||||
assert self._should_fix_bins_and_dylibs is True
|
||||
print("attempting to patch", fname)
|
||||
|
||||
# Only build `.nix-deps` once.
|
||||
nix_deps_dir = self.nix_deps_dir
|
||||
@ -666,8 +681,7 @@ class RustBuild(object):
|
||||
config = self.get_toml(program)
|
||||
if config:
|
||||
return os.path.expanduser(config)
|
||||
return os.path.join(self.bin_root(), "bin", "{}{}".format(
|
||||
program, self.exe_suffix()))
|
||||
return os.path.join(self.bin_root(), "bin", "{}{}".format(program, EXE_SUFFIX))
|
||||
|
||||
@staticmethod
|
||||
def get_string(line):
|
||||
@ -692,13 +706,6 @@ class RustBuild(object):
|
||||
return line[start + 1:end]
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def exe_suffix():
|
||||
"""Return a suffix for executables"""
|
||||
if sys.platform == 'win32':
|
||||
return '.exe'
|
||||
return ''
|
||||
|
||||
def bootstrap_binary(self):
|
||||
"""Return the path of the bootstrap binary
|
||||
|
||||
@ -710,7 +717,7 @@ class RustBuild(object):
|
||||
"""
|
||||
return os.path.join(self.build_dir, "bootstrap", "debug", "bootstrap")
|
||||
|
||||
def build_bootstrap(self, color):
|
||||
def build_bootstrap(self, color, verbose_count):
|
||||
"""Build bootstrap"""
|
||||
print("Building bootstrap")
|
||||
build_dir = os.path.join(self.build_dir, "bootstrap")
|
||||
@ -757,7 +764,6 @@ class RustBuild(object):
|
||||
if target_linker is not None:
|
||||
env["RUSTFLAGS"] += " -C linker=" + target_linker
|
||||
env["RUSTFLAGS"] += " -Wrust_2018_idioms -Wunused_lifetimes"
|
||||
env["RUSTFLAGS"] += " -Wsemicolon_in_expressions_from_macros"
|
||||
if self.get_toml("deny-warnings", "rust") != "false":
|
||||
env["RUSTFLAGS"] += " -Dwarnings"
|
||||
|
||||
@ -768,8 +774,7 @@ class RustBuild(object):
|
||||
self.cargo()))
|
||||
args = [self.cargo(), "build", "--manifest-path",
|
||||
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")]
|
||||
for _ in range(0, self.verbose):
|
||||
args.append("--verbose")
|
||||
args.extend("--verbose" for _ in range(verbose_count))
|
||||
if self.use_locked_deps:
|
||||
args.append("--locked")
|
||||
if self.use_vendored_sources:
|
||||
@ -792,16 +797,7 @@ class RustBuild(object):
|
||||
so use `self.build` where possible.
|
||||
"""
|
||||
config = self.get_toml('build')
|
||||
if config:
|
||||
return config
|
||||
return default_build_triple(self.verbose)
|
||||
|
||||
def set_dist_environment(self, url):
|
||||
"""Set download URL for normal environment"""
|
||||
if 'RUSTUP_DIST_SERVER' in os.environ:
|
||||
self._download_url = os.environ['RUSTUP_DIST_SERVER']
|
||||
else:
|
||||
self._download_url = url
|
||||
return config or default_build_triple(self.verbose)
|
||||
|
||||
def check_vendored_status(self):
|
||||
"""Check that vendoring is configured properly"""
|
||||
@ -834,17 +830,10 @@ class RustBuild(object):
|
||||
if os.path.exists(cargo_dir):
|
||||
shutil.rmtree(cargo_dir)
|
||||
|
||||
def bootstrap(help_triggered):
|
||||
"""Configure, fetch, build and run the initial bootstrap"""
|
||||
|
||||
# If the user is asking for help, let them know that the whole download-and-build
|
||||
# process has to happen before anything is printed out.
|
||||
if help_triggered:
|
||||
print("info: Downloading and building bootstrap before processing --help")
|
||||
print(" command. See src/bootstrap/README.md for help with common")
|
||||
print(" commands.")
|
||||
|
||||
parser = argparse.ArgumentParser(description='Build rust')
|
||||
def parse_args():
|
||||
"""Parse the command line arguments that the python script needs."""
|
||||
parser = argparse.ArgumentParser(add_help=False)
|
||||
parser.add_argument('-h', '--help', action='store_true')
|
||||
parser.add_argument('--config')
|
||||
parser.add_argument('--build-dir')
|
||||
parser.add_argument('--build')
|
||||
@ -852,13 +841,14 @@ def bootstrap(help_triggered):
|
||||
parser.add_argument('--clean', action='store_true')
|
||||
parser.add_argument('-v', '--verbose', action='count', default=0)
|
||||
|
||||
args = [a for a in sys.argv if a != '-h' and a != '--help']
|
||||
args, _ = parser.parse_known_args(args)
|
||||
return parser.parse_known_args(sys.argv)[0]
|
||||
|
||||
def bootstrap(args):
|
||||
"""Configure, fetch, build and run the initial bootstrap"""
|
||||
# Configure initial bootstrap
|
||||
build = RustBuild()
|
||||
build.rust_root = os.path.abspath(os.path.join(__file__, '../../..'))
|
||||
build.verbose = args.verbose
|
||||
build.verbose = args.verbose != 0
|
||||
build.clean = args.clean
|
||||
|
||||
# Read from `--config`, then `RUST_BOOTSTRAP_CONFIG`, then `./config.toml`,
|
||||
@ -886,12 +876,12 @@ def bootstrap(help_triggered):
|
||||
with open(include_path) as included_toml:
|
||||
build.config_toml += os.linesep + included_toml.read()
|
||||
|
||||
config_verbose = build.get_toml('verbose', 'build')
|
||||
if config_verbose is not None:
|
||||
build.verbose = max(build.verbose, int(config_verbose))
|
||||
verbose_count = args.verbose
|
||||
config_verbose_count = build.get_toml('verbose', 'build')
|
||||
if config_verbose_count is not None:
|
||||
verbose_count = max(args.verbose, int(config_verbose_count))
|
||||
|
||||
build.use_vendored_sources = build.get_toml('vendor', 'build') == 'true'
|
||||
|
||||
build.use_locked_deps = build.get_toml('locked-deps', 'build') == 'true'
|
||||
|
||||
build.check_vendored_status()
|
||||
@ -903,8 +893,7 @@ def bootstrap(help_triggered):
|
||||
data = json.load(f)
|
||||
build.checksums_sha256 = data["checksums_sha256"]
|
||||
build.stage0_compiler = Stage0Toolchain(data["compiler"])
|
||||
|
||||
build.set_dist_environment(data["config"]["dist_server"])
|
||||
build.download_url = os.getenv("RUSTUP_DIST_SERVER") or data["config"]["dist_server"]
|
||||
|
||||
build.build = args.build or build.build_triple()
|
||||
|
||||
@ -914,7 +903,7 @@ def bootstrap(help_triggered):
|
||||
# Fetch/build the bootstrap
|
||||
build.download_toolchain()
|
||||
sys.stdout.flush()
|
||||
build.build_bootstrap(args.color)
|
||||
build.build_bootstrap(args.color, verbose_count)
|
||||
sys.stdout.flush()
|
||||
|
||||
# Run the bootstrap
|
||||
@ -932,25 +921,32 @@ def main():
|
||||
|
||||
# x.py help <cmd> ...
|
||||
if len(sys.argv) > 1 and sys.argv[1] == 'help':
|
||||
sys.argv = [sys.argv[0], '-h'] + sys.argv[2:]
|
||||
sys.argv[1] = '-h'
|
||||
|
||||
help_triggered = (
|
||||
'-h' in sys.argv) or ('--help' in sys.argv) or (len(sys.argv) == 1)
|
||||
args = parse_args()
|
||||
help_triggered = args.help or len(sys.argv) == 1
|
||||
|
||||
# If the user is asking for help, let them know that the whole download-and-build
|
||||
# process has to happen before anything is printed out.
|
||||
if help_triggered:
|
||||
print(
|
||||
"info: Downloading and building bootstrap before processing --help command.\n"
|
||||
" See src/bootstrap/README.md for help with common commands."
|
||||
)
|
||||
|
||||
exit_code = 0
|
||||
try:
|
||||
bootstrap(help_triggered)
|
||||
if not help_triggered:
|
||||
print("Build completed successfully in {}".format(
|
||||
format_build_time(time() - start_time)))
|
||||
bootstrap(args)
|
||||
except (SystemExit, KeyboardInterrupt) as error:
|
||||
if hasattr(error, 'code') and isinstance(error.code, int):
|
||||
exit_code = error.code
|
||||
else:
|
||||
exit_code = 1
|
||||
print(error)
|
||||
if not help_triggered:
|
||||
print("Build completed unsuccessfully in {}".format(
|
||||
format_build_time(time() - start_time)))
|
||||
sys.exit(exit_code)
|
||||
|
||||
if not help_triggered:
|
||||
print("Build completed successfully in", format_build_time(time() - start_time))
|
||||
sys.exit(exit_code)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -18,6 +18,8 @@ use crate::{
|
||||
Config,
|
||||
};
|
||||
|
||||
static SHOULD_FIX_BINS_AND_DYLIBS: OnceCell<bool> = OnceCell::new();
|
||||
|
||||
/// Generic helpers that are useful anywhere in bootstrap.
|
||||
impl Config {
|
||||
pub fn is_verbose(&self) -> bool {
|
||||
@ -70,6 +72,51 @@ impl Config {
|
||||
check_run(cmd, self.is_verbose())
|
||||
}
|
||||
|
||||
/// Whether or not `fix_bin_or_dylib` needs to be run; can only be true
|
||||
/// on NixOS
|
||||
fn should_fix_bins_and_dylibs(&self) -> bool {
|
||||
let val = *SHOULD_FIX_BINS_AND_DYLIBS.get_or_init(|| {
|
||||
match Command::new("uname").arg("-s").stderr(Stdio::inherit()).output() {
|
||||
Err(_) => return false,
|
||||
Ok(output) if !output.status.success() => return false,
|
||||
Ok(output) => {
|
||||
let mut os_name = output.stdout;
|
||||
if os_name.last() == Some(&b'\n') {
|
||||
os_name.pop();
|
||||
}
|
||||
if os_name != b"Linux" {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the user has asked binaries to be patched for Nix, then
|
||||
// don't check for NixOS or `/lib`.
|
||||
// NOTE: this intentionally comes after the Linux check:
|
||||
// - patchelf only works with ELF files, so no need to run it on Mac or Windows
|
||||
// - On other Unix systems, there is no stable syscall interface, so Nix doesn't manage the global libc.
|
||||
if self.patch_binaries_for_nix {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Use `/etc/os-release` instead of `/etc/NIXOS`.
|
||||
// The latter one does not exist on NixOS when using tmpfs as root.
|
||||
let is_nixos = match File::open("/etc/os-release") {
|
||||
Err(e) if e.kind() == ErrorKind::NotFound => false,
|
||||
Err(e) => panic!("failed to access /etc/os-release: {}", e),
|
||||
Ok(os_release) => BufReader::new(os_release).lines().any(|l| {
|
||||
let l = l.expect("reading /etc/os-release");
|
||||
matches!(l.trim(), "ID=nixos" | "ID='nixos'" | "ID=\"nixos\"")
|
||||
}),
|
||||
};
|
||||
is_nixos && !Path::new("/lib").exists()
|
||||
});
|
||||
if val {
|
||||
println!("info: You seem to be using Nix.");
|
||||
}
|
||||
val
|
||||
}
|
||||
|
||||
/// Modifies the interpreter section of 'fname' to fix the dynamic linker,
|
||||
/// or the RPATH section, to fix the dynamic library search path
|
||||
///
|
||||
@ -78,45 +125,8 @@ impl Config {
|
||||
///
|
||||
/// Please see https://nixos.org/patchelf.html for more information
|
||||
fn fix_bin_or_dylib(&self, fname: &Path) {
|
||||
// FIXME: cache NixOS detection?
|
||||
match Command::new("uname").arg("-s").stderr(Stdio::inherit()).output() {
|
||||
Err(_) => return,
|
||||
Ok(output) if !output.status.success() => return,
|
||||
Ok(output) => {
|
||||
let mut s = output.stdout;
|
||||
if s.last() == Some(&b'\n') {
|
||||
s.pop();
|
||||
}
|
||||
if s != b"Linux" {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the user has asked binaries to be patched for Nix, then
|
||||
// don't check for NixOS or `/lib`, just continue to the patching.
|
||||
// NOTE: this intentionally comes after the Linux check:
|
||||
// - patchelf only works with ELF files, so no need to run it on Mac or Windows
|
||||
// - On other Unix systems, there is no stable syscall interface, so Nix doesn't manage the global libc.
|
||||
if !self.patch_binaries_for_nix {
|
||||
// Use `/etc/os-release` instead of `/etc/NIXOS`.
|
||||
// The latter one does not exist on NixOS when using tmpfs as root.
|
||||
const NIX_IDS: &[&str] = &["ID=nixos", "ID='nixos'", "ID=\"nixos\""];
|
||||
let os_release = match File::open("/etc/os-release") {
|
||||
Err(e) if e.kind() == ErrorKind::NotFound => return,
|
||||
Err(e) => panic!("failed to access /etc/os-release: {}", e),
|
||||
Ok(f) => f,
|
||||
};
|
||||
if !BufReader::new(os_release).lines().any(|l| NIX_IDS.contains(&t!(l).trim())) {
|
||||
return;
|
||||
}
|
||||
if Path::new("/lib").exists() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// At this point we're pretty sure the user is running NixOS or using Nix
|
||||
println!("info: you seem to be using Nix. Attempting to patch {}", fname.display());
|
||||
assert_eq!(SHOULD_FIX_BINS_AND_DYLIBS.get(), Some(&true));
|
||||
println!("attempting to patch {}", fname.display());
|
||||
|
||||
// Only build `.nix-deps` once.
|
||||
static NIX_DEPS_DIR: OnceCell<PathBuf> = OnceCell::new();
|
||||
@ -340,8 +350,10 @@ impl Config {
|
||||
"rustfmt",
|
||||
);
|
||||
|
||||
self.fix_bin_or_dylib(&bin_root.join("bin").join("rustfmt"));
|
||||
self.fix_bin_or_dylib(&bin_root.join("bin").join("cargo-fmt"));
|
||||
if self.should_fix_bins_and_dylibs() {
|
||||
self.fix_bin_or_dylib(&bin_root.join("bin").join("rustfmt"));
|
||||
self.fix_bin_or_dylib(&bin_root.join("bin").join("cargo-fmt"));
|
||||
}
|
||||
|
||||
self.create(&rustfmt_stamp, &channel);
|
||||
Some(rustfmt_path)
|
||||
@ -370,16 +382,21 @@ impl Config {
|
||||
let filename = format!("rust-src-{version}.tar.xz");
|
||||
self.download_ci_component(filename, "rust-src", commit);
|
||||
|
||||
self.fix_bin_or_dylib(&bin_root.join("bin").join("rustc"));
|
||||
self.fix_bin_or_dylib(&bin_root.join("bin").join("rustdoc"));
|
||||
self.fix_bin_or_dylib(&bin_root.join("libexec").join("rust-analyzer-proc-macro-srv"));
|
||||
let lib_dir = bin_root.join("lib");
|
||||
for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) {
|
||||
let lib = t!(lib);
|
||||
if lib.path().extension() == Some(OsStr::new("so")) {
|
||||
self.fix_bin_or_dylib(&lib.path());
|
||||
if self.should_fix_bins_and_dylibs() {
|
||||
self.fix_bin_or_dylib(&bin_root.join("bin").join("rustc"));
|
||||
self.fix_bin_or_dylib(&bin_root.join("bin").join("rustdoc"));
|
||||
self.fix_bin_or_dylib(
|
||||
&bin_root.join("libexec").join("rust-analyzer-proc-macro-srv"),
|
||||
);
|
||||
let lib_dir = bin_root.join("lib");
|
||||
for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) {
|
||||
let lib = t!(lib);
|
||||
if lib.path().extension() == Some(OsStr::new("so")) {
|
||||
self.fix_bin_or_dylib(&lib.path());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t!(fs::write(rustc_stamp, commit));
|
||||
}
|
||||
}
|
||||
@ -471,8 +488,10 @@ impl Config {
|
||||
let key = format!("{}{}", llvm_sha, self.llvm_assertions);
|
||||
if program_out_of_date(&llvm_stamp, &key) && !self.dry_run() {
|
||||
self.download_ci_llvm(&llvm_sha);
|
||||
for entry in t!(fs::read_dir(llvm_root.join("bin"))) {
|
||||
self.fix_bin_or_dylib(&t!(entry).path());
|
||||
if self.should_fix_bins_and_dylibs() {
|
||||
for entry in t!(fs::read_dir(llvm_root.join("bin"))) {
|
||||
self.fix_bin_or_dylib(&t!(entry).path());
|
||||
}
|
||||
}
|
||||
|
||||
// Update the timestamp of llvm-config to force rustc_llvm to be
|
||||
@ -487,13 +506,16 @@ impl Config {
|
||||
let llvm_config = llvm_root.join("bin").join(exe("llvm-config", self.build));
|
||||
t!(filetime::set_file_times(&llvm_config, now, now));
|
||||
|
||||
let llvm_lib = llvm_root.join("lib");
|
||||
for entry in t!(fs::read_dir(&llvm_lib)) {
|
||||
let lib = t!(entry).path();
|
||||
if lib.extension().map_or(false, |ext| ext == "so") {
|
||||
self.fix_bin_or_dylib(&lib);
|
||||
if self.should_fix_bins_and_dylibs() {
|
||||
let llvm_lib = llvm_root.join("lib");
|
||||
for entry in t!(fs::read_dir(&llvm_lib)) {
|
||||
let lib = t!(entry).path();
|
||||
if lib.extension().map_or(false, |ext| ext == "so") {
|
||||
self.fix_bin_or_dylib(&lib);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t!(fs::write(llvm_stamp, key));
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ fn main() {
|
||||
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
let vr = v.iter().filter(|x| {
|
||||
*x % 2 == 0
|
||||
//~^ ERROR cannot mod `&&{integer}` by `{integer}`
|
||||
//~^ ERROR cannot calculate the remainder of `&&{integer}` divided by `{integer}`
|
||||
});
|
||||
println!("{:?}", vr);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ fn main() {
|
||||
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
let vr = v.iter().filter(|x| {
|
||||
x % 2 == 0
|
||||
//~^ ERROR cannot mod `&&{integer}` by `{integer}`
|
||||
//~^ ERROR cannot calculate the remainder of `&&{integer}` divided by `{integer}`
|
||||
});
|
||||
println!("{:?}", vr);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0369]: cannot mod `&&{integer}` by `{integer}`
|
||||
error[E0369]: cannot calculate the remainder of `&&{integer}` divided by `{integer}`
|
||||
--> $DIR/binary-op-on-double-ref.rs:5:11
|
||||
|
|
||||
LL | x % 2 == 0
|
||||
|
@ -11,7 +11,7 @@ fn main() {
|
||||
|
||||
a / a; //~ ERROR cannot divide `A` by `A`
|
||||
|
||||
a % a; //~ ERROR cannot mod `A` by `A`
|
||||
a % a; //~ ERROR cannot calculate the remainder of `A` divided by `A`
|
||||
|
||||
a & a; //~ ERROR no implementation for `A & A`
|
||||
|
||||
|
@ -62,7 +62,7 @@ LL | struct A;
|
||||
note: the trait `Div` must be implemented
|
||||
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
|
||||
|
||||
error[E0369]: cannot mod `A` by `A`
|
||||
error[E0369]: cannot calculate the remainder of `A` divided by `A`
|
||||
--> $DIR/issue-28837.rs:14:7
|
||||
|
|
||||
LL | a % a;
|
||||
|
@ -1,21 +0,0 @@
|
||||
// error-pattern: requires `generator` lang_item
|
||||
#![feature(no_core, lang_items, unboxed_closures, tuple_trait)]
|
||||
#![no_core]
|
||||
|
||||
#[lang = "sized"] pub trait Sized { }
|
||||
|
||||
#[lang = "tuple_trait"] pub trait Tuple { }
|
||||
|
||||
#[lang = "fn_once"]
|
||||
#[rustc_paren_sugar]
|
||||
pub trait FnOnce<Args: Tuple> {
|
||||
type Output;
|
||||
|
||||
extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
|
||||
}
|
||||
|
||||
pub fn abc() -> impl FnOnce(f32) {
|
||||
|_| {}
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,15 +0,0 @@
|
||||
error[E0635]: unknown feature `tuple_trait`
|
||||
--> $DIR/lang-item-missing-generator.rs:2:51
|
||||
|
|
||||
LL | #![feature(no_core, lang_items, unboxed_closures, tuple_trait)]
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: requires `generator` lang_item
|
||||
--> $DIR/lang-item-missing-generator.rs:17:17
|
||||
|
|
||||
LL | pub fn abc() -> impl FnOnce(f32) {
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0635`.
|
@ -10,10 +10,10 @@ help: add a block here
|
||||
LL | if let Some(y) = x else {
|
||||
| ^
|
||||
help: remove the `if` if you meant to write a `let...else` statement
|
||||
--> $DIR/accidental-if.rs:3:5
|
||||
|
|
||||
LL | if let Some(y) = x else {
|
||||
| ^^
|
||||
LL - if let Some(y) = x else {
|
||||
LL + let Some(y) = x else {
|
||||
|
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
print-type-size type: `[async fn body@$DIR/async.rs:8:36: 11:2]`: 16386 bytes, alignment: 1 bytes
|
||||
print-type-size discriminant: 1 bytes
|
||||
print-type-size variant `Suspend0`: 16385 bytes
|
||||
print-type-size field `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size field `.arg`: 8192 bytes
|
||||
print-type-size field `.__awaitee`: 1 bytes
|
||||
print-type-size upvar `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size local `.arg`: 8192 bytes
|
||||
print-type-size local `.__awaitee`: 1 bytes
|
||||
print-type-size variant `Unresumed`: 8192 bytes
|
||||
print-type-size field `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size upvar `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size variant `Returned`: 8192 bytes
|
||||
print-type-size field `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size upvar `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size variant `Panicked`: 8192 bytes
|
||||
print-type-size field `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size upvar `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size type: `std::mem::ManuallyDrop<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes
|
||||
print-type-size field `.value`: 8192 bytes
|
||||
print-type-size type: `std::mem::MaybeUninit<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes
|
||||
|
@ -1,10 +1,10 @@
|
||||
print-type-size type: `[generator@$DIR/generator.rs:10:5: 10:14]`: 8193 bytes, alignment: 1 bytes
|
||||
print-type-size discriminant: 1 bytes
|
||||
print-type-size variant `Unresumed`: 8192 bytes
|
||||
print-type-size field `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size upvar `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size variant `Returned`: 8192 bytes
|
||||
print-type-size field `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size upvar `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size variant `Panicked`: 8192 bytes
|
||||
print-type-size field `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size upvar `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size variant `Suspend0`: 8192 bytes
|
||||
print-type-size field `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size upvar `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
|
@ -2,10 +2,10 @@ print-type-size type: `[generator@$DIR/generator_discr_placement.rs:11:13: 11:15
|
||||
print-type-size discriminant: 1 bytes
|
||||
print-type-size variant `Suspend0`: 7 bytes
|
||||
print-type-size padding: 3 bytes
|
||||
print-type-size field `.w`: 4 bytes, alignment: 4 bytes
|
||||
print-type-size local `.w`: 4 bytes, alignment: 4 bytes
|
||||
print-type-size variant `Suspend1`: 7 bytes
|
||||
print-type-size padding: 3 bytes
|
||||
print-type-size field `.z`: 4 bytes, alignment: 4 bytes
|
||||
print-type-size local `.z`: 4 bytes, alignment: 4 bytes
|
||||
print-type-size variant `Unresumed`: 0 bytes
|
||||
print-type-size variant `Returned`: 0 bytes
|
||||
print-type-size variant `Panicked`: 0 bytes
|
||||
|
@ -38,10 +38,10 @@ help: add a block here
|
||||
LL | if let Some(n) = opt else {
|
||||
| ^
|
||||
help: remove the `if` if you meant to write a `let...else` statement
|
||||
--> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:24:5
|
||||
|
|
||||
LL | if let Some(n) = opt else {
|
||||
| ^^
|
||||
LL - if let Some(n) = opt else {
|
||||
LL + let Some(n) = opt else {
|
||||
|
|
||||
|
||||
error: this `if` expression is missing a block after the condition
|
||||
--> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:28:5
|
||||
|
3
x.py
3
x.py
@ -22,7 +22,8 @@ if sys.version_info.major < 3:
|
||||
pass
|
||||
|
||||
rust_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.append(os.path.join(rust_dir, "src", "bootstrap"))
|
||||
# For the import below, have Python search in src/bootstrap first.
|
||||
sys.path.insert(0, os.path.join(rust_dir, "src", "bootstrap"))
|
||||
|
||||
import bootstrap
|
||||
bootstrap.main()
|
||||
|
Loading…
Reference in New Issue
Block a user