Skip to content

Rollup of 12 pull requests #76652

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 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0151061
NRVO: Allow occurrences of the return place in var debug info
tmiasko Sep 3, 2020
283d4c4
Ignore `|` and `+` tokens during proc-macro pretty-print check
Aaron1011 Sep 10, 2020
15aa6f3
add debug-logging to config.toml
guswynn Sep 10, 2020
fb8d070
Add ui test for 74672 and 76571
tesuji Sep 11, 2020
c3d048a
Ignore rustc_private items from std docs
tesuji Sep 10, 2020
439b766
replacing sub's that can wrap by saturating_sub's
ad-anssi Sep 11, 2020
f9059a4
add non-regression test for issue #76597
ad-anssi Sep 11, 2020
62068a5
repairing broken error message and rustfix application for the new test
ad-anssi Sep 11, 2020
56f5c7f
comments + add max_level_info so false works with debug_assertions on
guswynn Sep 11, 2020
0be66d7
just max_level_info
guswynn Sep 11, 2020
9500067
Use `is_unstable_const_fn` where appropriate
slightlyoutofphase Sep 12, 2020
0439556
Check basic constness before unstable constness
slightlyoutofphase Sep 12, 2020
4284aad
Fix formatting for tidy
slightlyoutofphase Sep 12, 2020
b1e481d
Simplify iter zip struct doc
pickfire Sep 12, 2020
73e0a56
Make all methods of `Duration` const
CDirkx Sep 4, 2020
869021e
Add mailmap entry
CDirkx Sep 12, 2020
9c13894
Fix `const-display.rs` XPATH queries (#1)
slightlyoutofphase Sep 12, 2020
8a1288b
Give functions unique names
slightlyoutofphase Sep 12, 2020
4f0047e
Add a comment on is_trivially_sized about obviously !Sized types
nox Sep 12, 2020
75f0f7a
Fix a typo
nox Sep 12, 2020
caf6c92
Clean up some language trait items comparisons
nox Sep 12, 2020
a7b092f
Download LLVM from CI to bootstrap
Mark-Simulacrum Sep 4, 2020
2e87a6e
Set link-shared if LLVM ThinLTO is enabled in config.rs
Mark-Simulacrum Sep 12, 2020
2eeb8f1
Remove Windows details from Unix and VmWorks symlink() docstrings
nicholasbishop Sep 12, 2020
365e79c
Rollup merge of #76306 - tmiasko:nrvo-debuginfo, r=ecstatic-morse
Dylan-DPC Sep 12, 2020
d674504
Rollup merge of #76335 - CDirkx:const-duration, r=ecstatic-morse
Dylan-DPC Sep 12, 2020
2beb32c
Rollup merge of #76349 - Mark-Simulacrum:dl-llvm, r=alexcrichton
Dylan-DPC Sep 12, 2020
fcf82df
Rollup merge of #76571 - lzutao:rustdoc-private-traits, r=jyn514
Dylan-DPC Sep 12, 2020
c480b71
Rollup merge of #76585 - Aaron1011:ignore-vert-plus, r=petrochenkov
Dylan-DPC Sep 12, 2020
8b583f8
Rollup merge of #76588 - guswynn:debug_logging, r=jyn514,Mark-Simulacrum
Dylan-DPC Sep 12, 2020
e38a60e
Rollup merge of #76598 - ad-anssi:diagnostic_errors_fix, r=estebank
Dylan-DPC Sep 12, 2020
32f4f63
Rollup merge of #76623 - slightlyoutofphase:master, r=jyn514
Dylan-DPC Sep 12, 2020
23f2587
Rollup merge of #76629 - pickfire:patch-4, r=jonas-schievink
Dylan-DPC Sep 12, 2020
177a2c8
Rollup merge of #76641 - nox:pointee-random-stuff, r=eddyb
Dylan-DPC Sep 12, 2020
a91dd7f
Rollup merge of #76646 - CDirkx:mailmap, r=Mark-Simulacrum
Dylan-DPC Sep 12, 2020
82d93d2
Rollup merge of #76651 - nicholasbishop:bishop-remove-windows-note, r…
Dylan-DPC Sep 12, 2020
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
3 changes: 3 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ Chris C Cerami <chrisccerami@users.noreply.github.com> Chris C Cerami <chrisccer
Chris Pressey <cpressey@gmail.com>
Chris Thorn <chris@thorn.co> Chris Thorn <thorn@thoughtbot.com>
Chris Vittal <christopher.vittal@gmail.com> Christopher Vittal <christopher.vittal@gmail.com>
Christiaan Dirkx <christiaan@dirkx.email> <christiaan@dirkx.com>
Christiaan Dirkx <christiaan@dirkx.email> CDirkx <christiaan@dirkx.com>
Christiaan Dirkx <christiaan@dirkx.email> CDirkx <christiaan@dirkx.email>
Christian Poveda <git@christianpoveda.xyz> <christianpoveda@protonmail.com>
Christian Poveda <git@christianpoveda.xyz> <cn.poveda.ruiz@gmail.com>
Christian Poveda <git@christianpoveda.xyz> <z1mvader@protonmail.com>
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ features = ['unprefixed_malloc_on_supported_platforms']
[features]
jemalloc = ['jemalloc-sys']
llvm = ['rustc_driver/llvm']
max_level_info = ['rustc_driver/max_level_info']
3 changes: 2 additions & 1 deletion compiler/rustc_driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ crate-type = ["dylib"]

[dependencies]
libc = "0.2"
tracing = { version = "0.1.18", features = ["release_max_level_info"] }
tracing = { version = "0.1.18" }
tracing-subscriber = { version = "0.2.10", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] }
rustc_middle = { path = "../rustc_middle" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
Expand Down Expand Up @@ -38,3 +38,4 @@ winapi = { version = "0.3", features = ["consoleapi", "debugapi", "processenv"]

[features]
llvm = ['rustc_interface/llvm']
max_level_info = ['tracing/max_level_info']
6 changes: 3 additions & 3 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,15 +959,15 @@ impl EmitterWriter {
'_',
line_offset + pos,
width_offset + depth,
code_offset + annotation.start_col - left,
(code_offset + annotation.start_col).saturating_sub(left),
style,
);
}
_ if self.teach => {
buffer.set_style_range(
line_offset,
code_offset + annotation.start_col - left,
code_offset + annotation.end_col - left,
(code_offset + annotation.start_col).saturating_sub(left),
(code_offset + annotation.end_col).saturating_sub(left),
style,
annotation.is_primary,
);
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2280,6 +2280,12 @@ impl<'tcx> TyS<'tcx> {
///
/// Returning true means the type is known to be sized. Returning
/// `false` means nothing -- could be sized, might not be.
///
/// Note that we could never rely on the fact that a type such as `[_]` is
/// trivially `!Sized` because we could be in a type environment with a
/// bound such as `[_]: Copy`. A function with such a bound obviously never
/// can be called, but that doesn't mean it shouldn't typecheck. This is why
/// this method doesn't return `Option<bool>`.
pub fn is_trivially_sized(&self, tcx: TyCtxt<'tcx>) -> bool {
match self.kind() {
ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_mir/src/transform/nrvo.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_hir::Mutability;
use rustc_index::bit_set::HybridBitSet;
use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
use rustc_middle::mir::visit::{MutVisitor, NonUseContext, PlaceContext, Visitor};
use rustc_middle::mir::{self, BasicBlock, Local, Location};
use rustc_middle::ty::TyCtxt;

Expand Down Expand Up @@ -196,9 +196,10 @@ impl MutVisitor<'tcx> for RenameToReturnPlace<'tcx> {
self.super_terminator(terminator, loc);
}

fn visit_local(&mut self, l: &mut Local, _: PlaceContext, _: Location) {
assert_ne!(*l, mir::RETURN_PLACE);
if *l == self.to_rename {
fn visit_local(&mut self, l: &mut Local, ctxt: PlaceContext, _: Location) {
if *l == mir::RETURN_PLACE {
assert_eq!(ctxt, PlaceContext::NonUse(NonUseContext::VarDebugInfo));
} else if *l == self.to_rename {
*l = mir::RETURN_PLACE;
}
}
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ pub fn tokenstream_probably_equal_for_proc_macro(
| token::CloseDelim(DelimToken::NoDelim)
// The pretty printer collapses many semicolons into one.
| token::Semi
// We don't preserve leading `|` tokens in patterns, so
// we ignore them entirely
| token::BinOp(token::BinOpToken::Or)
// We don't preserve trailing '+' tokens in trait bounds,
// so we ignore them entirely
| token::BinOp(token::BinOpToken::Plus)
// The pretty printer can turn `$crate` into `::crate_name`
| token::ModSep = token.kind {
return false;
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,13 @@ impl<'a> Parser<'a> {
Ok(t) => {
// Parsed successfully, therefore most probably the code only
// misses a separator.
let mut exp_span = self.sess.source_map().next_point(sp);
if self.sess.source_map().is_multiline(exp_span) {
exp_span = sp;
}
expect_err
.span_suggestion_short(
self.sess.source_map().next_point(sp),
exp_span,
&format!("missing `{}`", token_str),
token_str,
Applicability::MaybeIncorrect,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1507,12 +1507,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
// avoid inundating the user with unnecessary errors, but we now
// check upstream for type errors and don't add the obligations to
// begin with in those cases.
if self
.tcx
.lang_items()
.sized_trait()
.map_or(false, |sized_id| sized_id == trait_ref.def_id())
{
if self.tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) {
self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0282).emit();
return;
}
Expand Down
20 changes: 5 additions & 15 deletions compiler/rustc_traits/src/chalk/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,15 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
.map(|i| chalk_ir::AssocTypeId(i.def_id))
.collect();

let well_known = if self
.interner
.tcx
.lang_items()
.sized_trait()
.map(|t| def_id == t)
.unwrap_or(false)
{
let well_known = if self.interner.tcx.lang_items().sized_trait() == Some(def_id) {
Some(chalk_solve::rust_ir::WellKnownTrait::Sized)
} else if self.interner.tcx.lang_items().copy_trait().map(|t| def_id == t).unwrap_or(false)
{
} else if self.interner.tcx.lang_items().copy_trait() == Some(def_id) {
Some(chalk_solve::rust_ir::WellKnownTrait::Copy)
} else if self.interner.tcx.lang_items().clone_trait().map(|t| def_id == t).unwrap_or(false)
{
} else if self.interner.tcx.lang_items().clone_trait() == Some(def_id) {
Some(chalk_solve::rust_ir::WellKnownTrait::Clone)
} else if self.interner.tcx.lang_items().drop_trait().map(|t| def_id == t).unwrap_or(false)
{
} else if self.interner.tcx.lang_items().drop_trait() == Some(def_id) {
Some(chalk_solve::rust_ir::WellKnownTrait::Drop)
} else if self.interner.tcx.lang_items().fn_trait().map(|t| def_id == t).unwrap_or(false) {
} else if self.interner.tcx.lang_items().fn_trait() == Some(def_id) {
Some(chalk_solve::rust_ir::WellKnownTrait::Fn)
} else if self
.interner
Expand Down
25 changes: 23 additions & 2 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
# =============================================================================
[llvm]

# Whether to use Rust CI built LLVM instead of locally building it.
#
# Unless you're developing for a target where Rust CI doesn't build a compiler
# toolchain or changing LLVM locally, you probably want to set this to true.
#
# It's currently false by default due to being newly added; please file bugs if
# enabling this did not work for you on Linux (macOS and Windows support is
# coming soon).
#
# We also currently only support this when building LLVM for the build triple.
#
# Note that many of the LLVM options are not currently supported for
# downloading. Currently only the "assertions" option can be toggled.
#download-ci-llvm = false

# Indicates whether LLVM rebuild should be skipped when running bootstrap. If
# this is `false` then the compiler's LLVM will be rebuilt whenever the built
# version doesn't have the correct hash. If it is `true` then LLVM will never
Expand Down Expand Up @@ -322,13 +337,19 @@
# binary, otherwise they are omitted.
#
# Defaults to rust.debug value
#debug-assertions = false
#debug-assertions = debug

# Whether or not debug assertions are enabled for the standard library.
# Overrides the `debug-assertions` option, if defined.
#
# Defaults to rust.debug-assertions value
#debug-assertions-std = false
#debug-assertions-std = debug-assertions

# Whether or not to leave debug! and trace! calls in the rust binary.
# Overrides the `debug-assertions` option, if defined.
#
# Defaults to rust.debug-assertions value
#debug-logging = debug-assertions

# Debuginfo level for most of Rust code, corresponds to the `-C debuginfo=N` option of `rustc`.
# `0` - no debug info
Expand Down
7 changes: 2 additions & 5 deletions library/core/src/iter/adapters/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ use super::super::{

/// An iterator that iterates two other iterators simultaneously.
///
/// This `struct` is created by the [`zip`] method on [`Iterator`]. See its
/// documentation for more.
///
/// [`zip`]: trait.Iterator.html#method.zip
/// [`Iterator`]: trait.Iterator.html
/// This `struct` is created by [`Iterator::zip`]. See its documentation
/// for more.
#[derive(Clone)]
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
18 changes: 12 additions & 6 deletions library/core/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,8 @@ impl Duration {
/// ```
#[stable(feature = "duration_float", since = "1.38.0")]
#[inline]
pub fn from_secs_f64(secs: f64) -> Duration {
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn from_secs_f64(secs: f64) -> Duration {
const MAX_NANOS_F64: f64 = ((u64::MAX as u128 + 1) * (NANOS_PER_SEC as u128)) as f64;
let nanos = secs * (NANOS_PER_SEC as f64);
if !nanos.is_finite() {
Expand Down Expand Up @@ -727,7 +728,8 @@ impl Duration {
/// ```
#[stable(feature = "duration_float", since = "1.38.0")]
#[inline]
pub fn from_secs_f32(secs: f32) -> Duration {
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn from_secs_f32(secs: f32) -> Duration {
const MAX_NANOS_F32: f32 = ((u64::MAX as u128 + 1) * (NANOS_PER_SEC as u128)) as f32;
let nanos = secs * (NANOS_PER_SEC as f32);
if !nanos.is_finite() {
Expand Down Expand Up @@ -761,7 +763,8 @@ impl Duration {
/// ```
#[stable(feature = "duration_float", since = "1.38.0")]
#[inline]
pub fn mul_f64(self, rhs: f64) -> Duration {
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn mul_f64(self, rhs: f64) -> Duration {
Duration::from_secs_f64(rhs * self.as_secs_f64())
}

Expand All @@ -782,7 +785,8 @@ impl Duration {
/// ```
#[stable(feature = "duration_float", since = "1.38.0")]
#[inline]
pub fn mul_f32(self, rhs: f32) -> Duration {
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn mul_f32(self, rhs: f32) -> Duration {
Duration::from_secs_f32(rhs * self.as_secs_f32())
}

Expand All @@ -802,7 +806,8 @@ impl Duration {
/// ```
#[stable(feature = "duration_float", since = "1.38.0")]
#[inline]
pub fn div_f64(self, rhs: f64) -> Duration {
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn div_f64(self, rhs: f64) -> Duration {
Duration::from_secs_f64(self.as_secs_f64() / rhs)
}

Expand All @@ -824,7 +829,8 @@ impl Duration {
/// ```
#[stable(feature = "duration_float", since = "1.38.0")]
#[inline]
pub fn div_f32(self, rhs: f32) -> Duration {
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn div_f32(self, rhs: f32) -> Duration {
Duration::from_secs_f32(self.as_secs_f32() / rhs)
}

Expand Down
3 changes: 3 additions & 0 deletions library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
#![feature(core_private_diy_float)]
#![feature(debug_non_exhaustive)]
#![feature(dec2flt)]
#![feature(div_duration)]
#![feature(duration_consts_2)]
#![feature(duration_constants)]
#![feature(duration_saturating_ops)]
#![feature(duration_zero)]
#![feature(exact_size_is_empty)]
#![feature(fixed_size_array)]
#![feature(flt2dec)]
Expand Down
101 changes: 101 additions & 0 deletions library/core/tests/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,104 @@ fn debug_formatting_precision_high() {
assert_eq!(format!("{:.10?}", Duration::new(4, 001_000_000)), "4.0010000000s");
assert_eq!(format!("{:.20?}", Duration::new(4, 001_000_000)), "4.00100000000000000000s");
}

#[test]
fn duration_const() {
// test that the methods of `Duration` are usable in a const context

const DURATION: Duration = Duration::new(0, 123_456_789);

const SUB_SEC_MILLIS: u32 = DURATION.subsec_millis();
assert_eq!(SUB_SEC_MILLIS, 123);

const SUB_SEC_MICROS: u32 = DURATION.subsec_micros();
assert_eq!(SUB_SEC_MICROS, 123_456);

const SUB_SEC_NANOS: u32 = DURATION.subsec_nanos();
assert_eq!(SUB_SEC_NANOS, 123_456_789);

const ZERO: Duration = Duration::zero();
assert_eq!(ZERO, Duration::new(0, 0));

const IS_ZERO: bool = ZERO.is_zero();
assert!(IS_ZERO);

const ONE: Duration = Duration::new(1, 0);

const SECONDS: u64 = ONE.as_secs();
assert_eq!(SECONDS, 1);

const FROM_SECONDS: Duration = Duration::from_secs(1);
assert_eq!(FROM_SECONDS, ONE);

const SECONDS_F32: f32 = ONE.as_secs_f32();
assert_eq!(SECONDS_F32, 1.0);

const FROM_SECONDS_F32: Duration = Duration::from_secs_f32(1.0);
assert_eq!(FROM_SECONDS_F32, ONE);

const SECONDS_F64: f64 = ONE.as_secs_f64();
assert_eq!(SECONDS_F64, 1.0);

const FROM_SECONDS_F64: Duration = Duration::from_secs_f64(1.0);
assert_eq!(FROM_SECONDS_F64, ONE);

const MILLIS: u128 = ONE.as_millis();
assert_eq!(MILLIS, 1_000);

const FROM_MILLIS: Duration = Duration::from_millis(1_000);
assert_eq!(FROM_MILLIS, ONE);

const MICROS: u128 = ONE.as_micros();
assert_eq!(MICROS, 1_000_000);

const FROM_MICROS: Duration = Duration::from_micros(1_000_000);
assert_eq!(FROM_MICROS, ONE);

const NANOS: u128 = ONE.as_nanos();
assert_eq!(NANOS, 1_000_000_000);

const FROM_NANOS: Duration = Duration::from_nanos(1_000_000_000);
assert_eq!(FROM_NANOS, ONE);

const MAX: Duration = Duration::new(u64::MAX, 999_999_999);

const CHECKED_ADD: Option<Duration> = MAX.checked_add(ONE);
assert_eq!(CHECKED_ADD, None);

const CHECKED_SUB: Option<Duration> = ZERO.checked_sub(ONE);
assert_eq!(CHECKED_SUB, None);

const CHECKED_MUL: Option<Duration> = ONE.checked_mul(1);
assert_eq!(CHECKED_MUL, Some(ONE));

const MUL_F32: Duration = ONE.mul_f32(1.0);
assert_eq!(MUL_F32, ONE);

const MUL_F64: Duration = ONE.mul_f64(1.0);
assert_eq!(MUL_F64, ONE);

const CHECKED_DIV: Option<Duration> = ONE.checked_div(1);
assert_eq!(CHECKED_DIV, Some(ONE));

const DIV_F32: Duration = ONE.div_f32(1.0);
assert_eq!(DIV_F32, ONE);

const DIV_F64: Duration = ONE.div_f64(1.0);
assert_eq!(DIV_F64, ONE);

const DIV_DURATION_F32: f32 = ONE.div_duration_f32(ONE);
assert_eq!(DIV_DURATION_F32, 1.0);

const DIV_DURATION_F64: f64 = ONE.div_duration_f64(ONE);
assert_eq!(DIV_DURATION_F64, 1.0);

const SATURATING_ADD: Duration = MAX.saturating_add(ONE);
assert_eq!(SATURATING_ADD, MAX);

const SATURATING_SUB: Duration = ZERO.saturating_sub(ONE);
assert_eq!(SATURATING_SUB, ZERO);

const SATURATING_MUL: Duration = MAX.saturating_mul(2);
assert_eq!(SATURATING_MUL, MAX);
}
Loading