Skip to content

Rollup of 9 pull requests #76650

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 33 commits into from
Closed
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fcf1571
Add Atomic*::from_mut.
m-ou-se Jul 19, 2020
09fff5f
Disable Atomic*::from_mut when alignment is wrong.
m-ou-se Aug 13, 2020
7cc2569
Add tracking issue number for atomic_from_mut.
m-ou-se Sep 5, 2020
15b660f
Merge remote-tracking branch 'origin/master' into atomic-from-mut
m-ou-se Sep 6, 2020
528f100
Disable Atomic{U128,I128}::from_mut on x86_64.
m-ou-se Sep 6, 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
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
20e2b6b
Rollup merge of #74532 - fusion-engineering-forks:atomic-from-mut, r=…
Dylan-DPC Sep 12, 2020
46feb58
Rollup merge of #76571 - lzutao:rustdoc-private-traits, r=jyn514
Dylan-DPC Sep 12, 2020
e15c3aa
Rollup merge of #76585 - Aaron1011:ignore-vert-plus, r=petrochenkov
Dylan-DPC Sep 12, 2020
9c9c642
Rollup merge of #76588 - guswynn:debug_logging, r=jyn514,Mark-Simulacrum
Dylan-DPC Sep 12, 2020
d53086a
Rollup merge of #76598 - ad-anssi:diagnostic_errors_fix, r=estebank
Dylan-DPC Sep 12, 2020
c369622
Rollup merge of #76623 - slightlyoutofphase:master, r=jyn514
Dylan-DPC Sep 12, 2020
bf89f27
Rollup merge of #76629 - pickfire:patch-4, r=jonas-schievink
Dylan-DPC Sep 12, 2020
e2d99c1
Rollup merge of #76641 - nox:pointee-random-stuff, r=eddyb
Dylan-DPC Sep 12, 2020
55643ee
Rollup merge of #76646 - CDirkx:mailmap, r=Mark-Simulacrum
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
@@ -55,6 +55,9 @@ Chris C Cerami <[email protected]> Chris C Cerami <chrisccer
Chris Pressey <[email protected]>
Chris Thorn <[email protected]> Chris Thorn <[email protected]>
Chris Vittal <[email protected]> Christopher Vittal <[email protected]>
Christiaan Dirkx <[email protected]> <[email protected]>
Christiaan Dirkx <[email protected]> CDirkx <[email protected]>
Christiaan Dirkx <[email protected]> CDirkx <[email protected]>
Christian Poveda <[email protected]> <[email protected]>
Christian Poveda <[email protected]> <[email protected]>
Christian Poveda <[email protected]> <[email protected]>
1 change: 1 addition & 0 deletions compiler/rustc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
@@ -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" }
@@ -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
@@ -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,
);
6 changes: 6 additions & 0 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
@@ -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(_))
6 changes: 6 additions & 0 deletions compiler/rustc_parse/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 5 additions & 1 deletion compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
Original file line number Diff line number Diff line change
@@ -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;
}
20 changes: 5 additions & 15 deletions compiler/rustc_traits/src/chalk/db.rs
Original file line number Diff line number Diff line change
@@ -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
10 changes: 8 additions & 2 deletions config.toml.example
Original file line number Diff line number Diff line change
@@ -322,13 +322,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
7 changes: 2 additions & 5 deletions library/core/src/iter/adapters/zip.rs
Original file line number Diff line number Diff line change
@@ -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")]
98 changes: 97 additions & 1 deletion library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
@@ -110,6 +110,7 @@ use self::Ordering::*;
use crate::cell::UnsafeCell;
use crate::fmt;
use crate::intrinsics;
use crate::mem::align_of;

use crate::hint::spin_loop;

@@ -327,6 +328,27 @@ impl AtomicBool {
unsafe { &mut *(self.v.get() as *mut bool) }
}

/// Get atomic access to a `&mut bool`.
///
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut)]
/// use std::sync::atomic::{AtomicBool, Ordering};
///
/// let mut some_bool = true;
/// let a = AtomicBool::from_mut(&mut some_bool);
/// a.store(false, Ordering::Relaxed);
/// assert_eq!(some_bool, false);
/// ```
#[inline]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
pub fn from_mut(v: &mut bool) -> &Self {
// SAFETY: the mutable reference guarantees unique ownership, and
// alignment of both `bool` and `Self` is 1.
unsafe { &*(v as *mut bool as *mut Self) }
}

/// Consumes the atomic and returns the contained value.
///
/// This is safe because passing `self` by value guarantees that no other threads are
@@ -820,6 +842,30 @@ impl<T> AtomicPtr<T> {
unsafe { &mut *self.p.get() }
}

/// Get atomic access to a pointer.
///
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut)]
/// use std::sync::atomic::{AtomicPtr, Ordering};
///
/// let mut some_ptr = &mut 123 as *mut i32;
/// let a = AtomicPtr::from_mut(&mut some_ptr);
/// a.store(&mut 456, Ordering::Relaxed);
/// assert_eq!(unsafe { *some_ptr }, 456);
/// ```
#[inline]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
pub fn from_mut(v: &mut *mut T) -> &Self {
let [] = [(); align_of::<Self>() - align_of::<*mut T>()];
// SAFETY:
// - the mutable reference guarantees unique ownership.
// - the alignment of `*mut T` and `Self` is the same on all platforms
// supported by rust, as verified above.
unsafe { &*(v as *mut *mut T as *mut Self) }
}

/// Consumes the atomic and returns the contained value.
///
/// This is safe because passing `self` by value guarantees that no other threads are
@@ -1104,6 +1150,12 @@ impl<T> From<*mut T> for AtomicPtr<T> {
}
}

macro_rules! if_not_8_bit {
(u8, $($tt:tt)*) => { "" };
(i8, $($tt:tt)*) => { "" };
($_:ident, $($tt:tt)*) => { $($tt)* };
}

#[cfg(target_has_atomic_load_store = "8")]
macro_rules! atomic_int {
($cfg_cas:meta,
@@ -1115,7 +1167,8 @@ macro_rules! atomic_int {
$stable_nand:meta,
$const_stable:meta,
$stable_init_const:meta,
$s_int_type:expr, $int_ref:expr,
$(from_mut: cfg($from_mut_cfg:meta),)?
$s_int_type:literal, $int_ref:expr,
$extra_feature:expr,
$min_fn:ident, $max_fn:ident,
$align:expr,
@@ -1226,6 +1279,45 @@ assert_eq!(some_var.load(Ordering::SeqCst), 5);
}
}

doc_comment! {
concat!("Get atomic access to a `&mut ", stringify!($int_type), "`.

",
if_not_8_bit! {
$int_type,
concat!(
"**Note:** This function is only available on targets where `",
stringify!($int_type), "` has an alignment of ", $align, " bytes."
)
},
"

# Examples

```
#![feature(atomic_from_mut)]
", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};

let mut some_int = 123;
let a = ", stringify!($atomic_type), "::from_mut(&mut some_int);
a.store(100, Ordering::Relaxed);
assert_eq!(some_int, 100);
```
"),
#[inline]
$(#[cfg($from_mut_cfg)])?
#[unstable(feature = "atomic_from_mut", issue = "76314")]
pub fn from_mut(v: &mut $int_type) -> &Self {
let [] = [(); align_of::<Self>() - align_of::<$int_type>()];
// SAFETY:
// - the mutable reference guarantees unique ownership.
// - the alignment of `$int_type` and `Self` is the
// same on all platforms enabled by `$from_mut_cfg`
// as verified above.
unsafe { &*(v as *mut $int_type as *mut Self) }
}
}

doc_comment! {
concat!("Consumes the atomic and returns the contained value.

@@ -1984,6 +2076,7 @@ atomic_int! {
stable(feature = "integer_atomics_stable", since = "1.34.0"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
from_mut: cfg(not(target_arch = "x86")),
"i64", "../../../std/primitive.i64.html",
"",
atomic_min, atomic_max,
@@ -2002,6 +2095,7 @@ atomic_int! {
stable(feature = "integer_atomics_stable", since = "1.34.0"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
from_mut: cfg(not(target_arch = "x86")),
"u64", "../../../std/primitive.u64.html",
"",
atomic_umin, atomic_umax,
@@ -2020,6 +2114,7 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
from_mut: cfg(not(target_arch = "x86_64")),
"i128", "../../../std/primitive.i128.html",
"#![feature(integer_atomics)]\n\n",
atomic_min, atomic_max,
@@ -2038,6 +2133,7 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
from_mut: cfg(not(target_arch = "x86_64")),
"u128", "../../../std/primitive.u128.html",
"#![feature(integer_atomics)]\n\n",
atomic_umin, atomic_umax,
6 changes: 6 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
@@ -100,6 +100,7 @@ pub struct Config {
pub rust_codegen_units_std: Option<u32>,
pub rust_debug_assertions: bool,
pub rust_debug_assertions_std: bool,
pub rust_debug_logging: bool,
pub rust_debuginfo_level_rustc: u32,
pub rust_debuginfo_level_std: u32,
pub rust_debuginfo_level_tools: u32,
@@ -379,6 +380,7 @@ struct Rust {
codegen_units_std: Option<u32>,
debug_assertions: Option<bool>,
debug_assertions_std: Option<bool>,
debug_logging: Option<bool>,
debuginfo_level: Option<u32>,
debuginfo_level_rustc: Option<u32>,
debuginfo_level_std: Option<u32>,
@@ -587,6 +589,7 @@ impl Config {
let mut debug = None;
let mut debug_assertions = None;
let mut debug_assertions_std = None;
let mut debug_logging = None;
let mut debuginfo_level = None;
let mut debuginfo_level_rustc = None;
let mut debuginfo_level_std = None;
@@ -630,6 +633,7 @@ impl Config {
debug = rust.debug;
debug_assertions = rust.debug_assertions;
debug_assertions_std = rust.debug_assertions_std;
debug_logging = rust.debug_logging;
debuginfo_level = rust.debuginfo_level;
debuginfo_level_rustc = rust.debuginfo_level_rustc;
debuginfo_level_std = rust.debuginfo_level_std;
@@ -733,6 +737,8 @@ impl Config {
config.rust_debug_assertions_std =
debug_assertions_std.unwrap_or(config.rust_debug_assertions);

config.rust_debug_logging = debug_logging.unwrap_or(config.rust_debug_assertions);

let with_defaults = |debuginfo_level_specific: Option<u32>| {
debuginfo_level_specific.or(debuginfo_level).unwrap_or(if debug == Some(true) {
1
10 changes: 10 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
@@ -541,6 +541,16 @@ impl Build {
if self.config.llvm_enabled() {
features.push_str(" llvm");
}

// If debug logging is on, then we want the default for tracing:
// https://github.com/tokio-rs/tracing/blob/3dd5c03d907afdf2c39444a29931833335171554/tracing/src/level_filters.rs#L26
// which is everything (including debug/trace/etc.)
// if its unset, if debug_assertions is on, then debug_logging will also be on
// as well as tracing *ignoring* this feature when debug_assertions is on
if !self.config.rust_debug_logging {
features.push_str(" max_level_info");
}

features
}

19 changes: 10 additions & 9 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
@@ -337,18 +337,13 @@ pub fn build_impl(
// reachable in rustdoc generated documentation
if !did.is_local() {
if let Some(traitref) = associated_trait {
if !cx.renderinfo.borrow().access_levels.is_public(traitref.def_id) {
let did = traitref.def_id;
if !cx.renderinfo.borrow().access_levels.is_public(did) {
return;
}
}

// Skip foreign unstable traits from lists of trait implementations and
// such. This helps prevent dependencies of the standard library, for
// example, from getting documented as "traits `u32` implements" which
// isn't really too helpful.
if let Some(trait_did) = associated_trait {
if let Some(stab) = cx.tcx.lookup_stability(trait_did.def_id) {
if stab.level.is_unstable() {
if let Some(stab) = tcx.lookup_stability(did) {
if stab.level.is_unstable() && stab.feature == sym::rustc_private {
return;
}
}
@@ -372,6 +367,12 @@ pub fn build_impl(
if !cx.renderinfo.borrow().access_levels.is_public(did) {
return;
}

if let Some(stab) = tcx.lookup_stability(did) {
if stab.level.is_unstable() && stab.feature == sym::rustc_private {
return;
}
}
}
}

14 changes: 8 additions & 6 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ use rustc_middle::middle::stability;
use rustc_middle::ty::fold::TypeFolder;
use rustc_middle::ty::subst::InternalSubsts;
use rustc_middle::ty::{self, AdtKind, Lift, Ty, TyCtxt};
use rustc_mir::const_eval::is_min_const_fn;
use rustc_mir::const_eval::{is_const_fn, is_min_const_fn, is_unstable_const_fn};
use rustc_span::hygiene::MacroKind;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{self, Pos};
@@ -839,7 +839,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
let mut where_predicates =
where_predicates.into_iter().flat_map(|p| p.clean(cx)).collect::<Vec<_>>();

// Type parameters and have a Sized bound by default unless removed with
// Type parameters have a Sized bound by default unless removed with
// ?Sized. Scan through the predicates and mark any type parameter with
// a Sized bound, removing the bounds as we find them.
//
@@ -900,7 +900,9 @@ impl Clean<Item> for doctree::Function<'_> {
enter_impl_trait(cx, || (self.generics.clean(cx), (self.decl, self.body).clean(cx)));

let did = cx.tcx.hir().local_def_id(self.id);
let constness = if is_min_const_fn(cx.tcx, did.to_def_id()) {
let constness = if is_const_fn(cx.tcx, did.to_def_id())
&& !is_unstable_const_fn(cx.tcx, did.to_def_id()).is_some()
{
hir::Constness::Const
} else {
hir::Constness::NotConst
@@ -1108,7 +1110,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(body)) => {
let mut m = (sig, &self.generics, body, None).clean(cx);
if m.header.constness == hir::Constness::Const
&& !is_min_const_fn(cx.tcx, local_did.to_def_id())
&& is_unstable_const_fn(cx.tcx, local_did.to_def_id()).is_some()
{
m.header.constness = hir::Constness::NotConst;
}
@@ -1121,7 +1123,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
let (all_types, ret_types) = get_all_types(&generics, &decl, cx);
let mut t = TyMethod { header: sig.header, decl, generics, all_types, ret_types };
if t.header.constness == hir::Constness::Const
&& !is_min_const_fn(cx.tcx, local_did.to_def_id())
&& is_unstable_const_fn(cx.tcx, local_did.to_def_id()).is_some()
{
t.header.constness = hir::Constness::NotConst;
}
@@ -1154,7 +1156,7 @@ impl Clean<Item> for hir::ImplItem<'_> {
hir::ImplItemKind::Fn(ref sig, body) => {
let mut m = (sig, &self.generics, body, Some(self.defaultness)).clean(cx);
if m.header.constness == hir::Constness::Const
&& !is_min_const_fn(cx.tcx, local_did.to_def_id())
&& is_unstable_const_fn(cx.tcx, local_did.to_def_id()).is_some()
{
m.header.constness = hir::Constness::NotConst;
}
13 changes: 13 additions & 0 deletions src/test/rustdoc/auxiliary/real_gimli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// aux-build:realcore.rs

#![crate_name = "real_gimli"]
#![feature(staged_api, extremely_unstable)]
#![unstable(feature = "rustc_private", issue = "none")]

extern crate realcore;

#[unstable(feature = "rustc_private", issue = "none")]
pub struct EndianSlice;

#[unstable(feature = "rustc_private", issue = "none")]
impl realcore::Deref for EndianSlice {}
15 changes: 15 additions & 0 deletions src/test/rustdoc/auxiliary/realcore.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![crate_name = "realcore"]
#![feature(staged_api)]
#![unstable(feature = "extremely_unstable", issue = "none")]

#[unstable(feature = "extremely_unstable_foo", issue = "none")]
pub struct Foo {}

#[unstable(feature = "extremely_unstable_foo", issue = "none")]
pub trait Join {}

#[unstable(feature = "extremely_unstable_foo", issue = "none")]
impl Join for Foo {}

#[stable(feature = "faked_deref", since = "1.47.0")]
pub trait Deref {}
6 changes: 3 additions & 3 deletions src/test/rustdoc/const-display.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
#[rustc_const_unstable(feature="foo", issue = "none")]
pub const unsafe fn foo() -> u32 { 42 }

// @has 'foo/fn.foo2.html' '//pre' 'pub fn foo2() -> u32'
// @has 'foo/fn.foo2.html' '//pre' 'pub const fn foo2() -> u32'
#[unstable(feature = "humans", issue = "none")]
pub const fn foo2() -> u32 { 42 }

@@ -21,7 +21,7 @@ pub const fn foo2() -> u32 { 42 }
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
pub const fn bar2() -> u32 { 42 }

// @has 'foo/fn.foo2_gated.html' '//pre' 'pub unsafe fn foo2_gated() -> u32'
// @has 'foo/fn.foo2_gated.html' '//pre' 'pub const unsafe fn foo2_gated() -> u32'
#[unstable(feature = "foo2", issue = "none")]
pub const unsafe fn foo2_gated() -> u32 { 42 }

@@ -30,7 +30,7 @@ pub const unsafe fn foo2_gated() -> u32 { 42 }
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
pub const unsafe fn bar2_gated() -> u32 { 42 }

// @has 'foo/fn.bar_not_gated.html' '//pre' 'pub unsafe fn bar_not_gated() -> u32'
// @has 'foo/fn.bar_not_gated.html' '//pre' 'pub const unsafe fn bar_not_gated() -> u32'
pub const unsafe fn bar_not_gated() -> u32 { 42 }

pub struct Foo;
18 changes: 18 additions & 0 deletions src/test/rustdoc/issue-75588.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// ignore-tidy-linelength
// aux-build:realcore.rs
// aux-build:real_gimli.rs

// Ensure unstably exported traits have their Implementors sections.

#![crate_name = "foo"]
#![feature(extremely_unstable_foo)]

extern crate realcore;
extern crate real_gimli;

// issue #74672
// @!has foo/trait.Deref.html '//*[@id="impl-Deref-for-EndianSlice"]//code' 'impl Deref for EndianSlice'
pub use realcore::Deref;

// @has foo/trait.Join.html '//*[@id="impl-Join-for-Foo"]//code' 'impl Join for Foo'
pub use realcore::Join;
18 changes: 18 additions & 0 deletions src/test/rustdoc/issue-76501.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![feature(const_fn)]

// @has 'issue_76501/fn.bloop.html' '//pre' 'pub const fn bloop() -> i32'
/// A useless function that always returns 1.
pub const fn bloop() -> i32 {
1
}

/// A struct.
pub struct Struct {}

impl Struct {
// @has 'issue_76501/struct.Struct.html' '//*[@class="method"]' 'pub const fn blurp() -> i32'
/// A useless function that always returns 1.
pub const fn blurp() -> i32 {
1
}
}
11 changes: 11 additions & 0 deletions src/test/ui/issue-76597.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// run-rustfix

#![allow(dead_code)]
#![allow(unused_variables)]
fn f(
x: u8,
y: u8,
) {}
//~^^ ERROR: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`

fn main() {}
11 changes: 11 additions & 0 deletions src/test/ui/issue-76597.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// run-rustfix

#![allow(dead_code)]
#![allow(unused_variables)]
fn f(
x: u8
y: u8,
) {}
//~^^ ERROR: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`

fn main() {}
13 changes: 13 additions & 0 deletions src/test/ui/issue-76597.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`
--> $DIR/issue-76597.rs:7:38
|
LL | ... x: u8
| -
| |
| expected one of 7 possible tokens
| help: missing `,`
LL | ... y: u8,
| ^ unexpected token

error: aborting due to previous error

16 changes: 16 additions & 0 deletions src/test/ui/proc-macro/issue-76182-leading-vert-pat.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// check-pass
// aux-build:test-macros.rs
// compile-flags: -Z span-debug
//
// Regression test for issue #76182
// Tests that we properly handle patterns with a leading vert

#![no_std] // Don't load unnecessary hygiene information from std
extern crate std;

extern crate test_macros;

#[test_macros::print_attr]
fn main() {
match () { | () => () }
}
62 changes: 62 additions & 0 deletions src/test/ui/proc-macro/issue-76182-leading-vert-pat.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
PRINT-ATTR INPUT (DISPLAY): fn main() { match() { | () => () } }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "fn",
span: $DIR/issue-76182-leading-vert-pat.rs:14:1: 14:3 (#0),
},
Ident {
ident: "main",
span: $DIR/issue-76182-leading-vert-pat.rs:14:4: 14:8 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: $DIR/issue-76182-leading-vert-pat.rs:14:8: 14:10 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "match",
span: $DIR/issue-76182-leading-vert-pat.rs:15:5: 15:10 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: $DIR/issue-76182-leading-vert-pat.rs:15:11: 15:13 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Punct {
ch: '|',
spacing: Alone,
span: $DIR/issue-76182-leading-vert-pat.rs:15:16: 15:17 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: $DIR/issue-76182-leading-vert-pat.rs:15:18: 15:20 (#0),
},
Punct {
ch: '=',
spacing: Joint,
span: $DIR/issue-76182-leading-vert-pat.rs:15:21: 15:23 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/issue-76182-leading-vert-pat.rs:15:21: 15:23 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: $DIR/issue-76182-leading-vert-pat.rs:15:24: 15:26 (#0),
},
],
span: $DIR/issue-76182-leading-vert-pat.rs:15:14: 15:28 (#0),
},
],
span: $DIR/issue-76182-leading-vert-pat.rs:14:11: 16:2 (#0),
},
]
14 changes: 14 additions & 0 deletions src/test/ui/proc-macro/trailing-plus.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// check-pass
// aux-build:test-macros.rs
// compile-flags: -Z span-debug

#![no_std] // Don't load unnecessary hygiene information from std
extern crate std;

extern crate test_macros;

#[test_macros::print_attr]
fn foo<T>() where T: Copy + {
}

fn main() {}
57 changes: 57 additions & 0 deletions src/test/ui/proc-macro/trailing-plus.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
PRINT-ATTR INPUT (DISPLAY): fn foo < T > () where T : Copy + { }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "fn",
span: $DIR/trailing-plus.rs:11:1: 11:3 (#0),
},
Ident {
ident: "foo",
span: $DIR/trailing-plus.rs:11:4: 11:7 (#0),
},
Punct {
ch: '<',
spacing: Alone,
span: $DIR/trailing-plus.rs:11:7: 11:8 (#0),
},
Ident {
ident: "T",
span: $DIR/trailing-plus.rs:11:8: 11:9 (#0),
},
Punct {
ch: '>',
spacing: Alone,
span: $DIR/trailing-plus.rs:11:9: 11:10 (#0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: $DIR/trailing-plus.rs:11:10: 11:12 (#0),
},
Ident {
ident: "where",
span: $DIR/trailing-plus.rs:11:13: 11:18 (#0),
},
Ident {
ident: "T",
span: $DIR/trailing-plus.rs:11:19: 11:20 (#0),
},
Punct {
ch: ':',
spacing: Alone,
span: $DIR/trailing-plus.rs:11:20: 11:21 (#0),
},
Ident {
ident: "Copy",
span: $DIR/trailing-plus.rs:11:22: 11:26 (#0),
},
Punct {
ch: '+',
spacing: Alone,
span: $DIR/trailing-plus.rs:11:27: 11:28 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [],
span: $DIR/trailing-plus.rs:11:29: 12:2 (#0),
},
]
10 changes: 10 additions & 0 deletions src/tools/linkchecker/main.rs
Original file line number Diff line number Diff line change
@@ -142,6 +142,16 @@ fn is_exception(file: &Path, link: &str) -> bool {
if let Some(entry) = LINKCHECK_EXCEPTIONS.iter().find(|&(f, _)| file.ends_with(f)) {
entry.1.contains(&link)
} else {
// FIXME(#63351): Concat trait in alloc/slice reexported in primitive page
//
// NOTE: This cannot be added to `LINKCHECK_EXCEPTIONS` because the resolved path
// calculated in `check` function is outside `build/<triple>/doc` dir.
// So the `strip_prefix` method just returns the old absolute broken path.
if file.ends_with("std/primitive.slice.html") {
if link.ends_with("std/primitive.slice.html") {
return true;
}
}
false
}
}