Skip to content

Commit

Permalink
Auto merge of #116408 - matthiaskrgr:rollup-hmolg4m, r=matthiaskrgr
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - #115961 (Replace 'mutex' with 'lock' in RwLock documentation)
 - #116146 (Clarify `arg` and `args` documentation)
 - #116363 (Adapt `todo!` documentation to mention displaying custom values)
 - #116365 (bootstrap: make copying linker binaries conditional)
 - #116388 (rustdoc: fix & clean up handling of cross-crate higher-ranked parameters)
 - #116393 (Emit feature gate *warning* for `auto` traits pre-expansion)
 - #116395 (Mark myself as vacation or whatever)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Oct 4, 2023
2 parents 4910642 + d494048 commit a7bb2f6
Show file tree
Hide file tree
Showing 23 changed files with 172 additions and 127 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
"exclusive range pattern syntax is experimental"
);
gate_all_legacy_dont_use!(try_blocks, "`try` blocks are unstable");
gate_all_legacy_dont_use!(auto_traits, "`auto` traits are unstable");

visit::walk_crate(&mut visitor, krate);
}
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,12 @@ impl<'a> Parser<'a> {
fn parse_item_trait(&mut self, attrs: &mut AttrVec, lo: Span) -> PResult<'a, ItemInfo> {
let unsafety = self.parse_unsafety(Case::Sensitive);
// Parse optional `auto` prefix.
let is_auto = if self.eat_keyword(kw::Auto) { IsAuto::Yes } else { IsAuto::No };
let is_auto = if self.eat_keyword(kw::Auto) {
self.sess.gated_spans.gate(sym::auto_traits, self.prev_token.span);
IsAuto::Yes
} else {
IsAuto::No
};

self.expect_keyword(kw::Trait)?;
let ident = self.parse_ident()?;
Expand Down
34 changes: 24 additions & 10 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,8 @@ macro_rules! unreachable {
/// The difference between `unimplemented!` and [`todo!`] is that while `todo!`
/// conveys an intent of implementing the functionality later and the message is "not yet
/// implemented", `unimplemented!` makes no such claims. Its message is "not implemented".
/// Also some IDEs will mark `todo!`s.
///
/// Also, some IDEs will mark `todo!`s.
///
/// # Panics
///
Expand Down Expand Up @@ -805,50 +806,63 @@ macro_rules! unimplemented {
/// The difference between [`unimplemented!`] and `todo!` is that while `todo!` conveys
/// an intent of implementing the functionality later and the message is "not yet
/// implemented", `unimplemented!` makes no such claims. Its message is "not implemented".
/// Also some IDEs will mark `todo!`s.
///
/// Also, some IDEs will mark `todo!`s.
///
/// # Panics
///
/// This will always [`panic!`].
/// This will always [`panic!`] because `todo!` is just a shorthand for `panic!` with a
/// fixed, specific message.
///
/// Like `panic!`, this macro has a second form for displaying custom values.
///
/// # Examples
///
/// Here's an example of some in-progress code. We have a trait `Foo`:
///
/// ```
/// trait Foo {
/// fn bar(&self);
/// fn bar(&self) -> u8;
/// fn baz(&self);
/// fn qux(&self) -> Result<u64, ()>;
/// }
/// ```
///
/// We want to implement `Foo` on one of our types, but we also want to work on
/// just `bar()` first. In order for our code to compile, we need to implement
/// `baz()`, so we can use `todo!`:
/// `baz()` and `qux()`, so we can use `todo!`:
///
/// ```
/// # trait Foo {
/// # fn bar(&self);
/// # fn bar(&self) -> u8;
/// # fn baz(&self);
/// # fn qux(&self) -> Result<u64, ()>;
/// # }
/// struct MyStruct;
///
/// impl Foo for MyStruct {
/// fn bar(&self) {
/// // implementation goes here
/// fn bar(&self) -> u8 {
/// 1 + 1
/// }
///
/// fn baz(&self) {
/// // let's not worry about implementing baz() for now
/// // Let's not worry about implementing baz() for now
/// todo!();
/// }
///
/// fn qux(&self) -> Result<u64, ()> {
/// // We can add a message to todo! to display our omission.
/// // This will display:
/// // "thread 'main' panicked at 'not yet implemented: MyStruct is not yet quxable'".
/// todo!("MyStruct is not yet quxable");
/// }
/// }
///
/// fn main() {
/// let s = MyStruct;
/// s.bar();
///
/// // we aren't even using baz(), so this is fine.
/// // We aren't even using baz() or qux(), so this is fine.
/// }
/// ```
#[macro_export]
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ impl Command {
///
/// Note that the argument is not passed through a shell, but given
/// literally to the program. This means that shell syntax like quotes,
/// escaped characters, word splitting, glob patterns, substitution, etc.
/// escaped characters, word splitting, glob patterns, variable substitution, etc.
/// have no effect.
///
/// # Examples
Expand Down Expand Up @@ -637,7 +637,7 @@ impl Command {
///
/// Note that the arguments are not passed through a shell, but given
/// literally to the program. This means that shell syntax like quotes,
/// escaped characters, word splitting, glob patterns, substitution, etc.
/// escaped characters, word splitting, glob patterns, variable substitution, etc.
/// have no effect.
///
/// # Examples
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ impl<T: ?Sized> RwLock<T> {
///
/// If the lock is poisoned, it will remain poisoned until this function is called. This allows
/// recovering from a poisoned state and marking that it has recovered. For example, if the
/// value is overwritten by a known-good value, then the mutex can be marked as un-poisoned. Or
/// value is overwritten by a known-good value, then the lock can be marked as un-poisoned. Or
/// possibly, the value could be inspected to determine if it is in a consistent state, and if
/// so the poison is removed.
///
Expand All @@ -397,7 +397,7 @@ impl<T: ?Sized> RwLock<T> {
///
/// let _ = thread::spawn(move || {
/// let _lock = c_lock.write().unwrap();
/// panic!(); // the mutex gets poisoned
/// panic!(); // the lock gets poisoned
/// }).join();
///
/// assert_eq!(lock.is_poisoned(), true);
Expand Down
12 changes: 7 additions & 5 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,14 @@ impl Step for Std {
.rustc_snapshot_sysroot()
.join("lib")
.join("rustlib")
.join(&compiler.host.triple)
.join(compiler.host.triple)
.join("bin");
let target_sysroot_bin =
builder.sysroot_libdir(compiler, target).parent().unwrap().join("bin");
t!(fs::create_dir_all(&target_sysroot_bin));
builder.cp_r(&src_sysroot_bin, &target_sysroot_bin);
if src_sysroot_bin.exists() {
let target_sysroot_bin =
builder.sysroot_libdir(compiler, target).parent().unwrap().join("bin");
t!(fs::create_dir_all(&target_sysroot_bin));
builder.cp_r(&src_sysroot_bin, &target_sysroot_bin);
}
}

let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "build");
Expand Down
7 changes: 3 additions & 4 deletions src/librustdoc/clean/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ where
WherePredicate::RegionPredicate { lifetime, bounds } => {
lifetime_to_bounds.entry(lifetime).or_default().extend(bounds);
}
WherePredicate::EqPredicate { lhs, rhs, bound_params } => {
match *lhs {
WherePredicate::EqPredicate { lhs, rhs } => {
match lhs {
Type::QPath(box QPathData {
ref assoc,
ref self_type,
Expand Down Expand Up @@ -590,14 +590,13 @@ where
GenericArgs::AngleBracketed { ref mut bindings, .. } => {
bindings.push(TypeBinding {
assoc: assoc.clone(),
kind: TypeBindingKind::Equality { term: *rhs },
kind: TypeBindingKind::Equality { term: rhs },
});
}
GenericArgs::Parenthesized { .. } => {
existing_predicates.push(WherePredicate::EqPredicate {
lhs: lhs.clone(),
rhs,
bound_params,
});
continue; // If something other than a Fn ends up
// with parentheses, leave it alone
Expand Down
17 changes: 5 additions & 12 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use rustc_span::hygiene::MacroKind;
use rustc_span::symbol::{kw, sym, Symbol};

use crate::clean::{
self, clean_fn_decl_from_did_and_sig, clean_generics, clean_impl_item, clean_middle_assoc_item,
clean_middle_field, clean_middle_ty, clean_trait_ref_with_bindings, clean_ty,
clean_ty_alias_inner_type, clean_ty_generics, clean_variant_def, utils, Attributes,
self, clean_bound_vars, clean_fn_decl_from_did_and_sig, clean_generics, clean_impl_item,
clean_middle_assoc_item, clean_middle_field, clean_middle_ty, clean_trait_ref_with_bindings,
clean_ty, clean_ty_alias_inner_type, clean_ty_generics, clean_variant_def, utils, Attributes,
AttributesExt, ImplKind, ItemId, Type,
};
use crate::core::DocContext;
Expand Down Expand Up @@ -239,20 +239,13 @@ pub(crate) fn build_external_trait(cx: &mut DocContext<'_>, did: DefId) -> clean

fn build_external_function<'tcx>(cx: &mut DocContext<'tcx>, did: DefId) -> Box<clean::Function> {
let sig = cx.tcx.fn_sig(did).instantiate_identity();

let late_bound_regions = sig.bound_vars().into_iter().filter_map(|var| match var {
ty::BoundVariableKind::Region(ty::BrNamed(_, name)) if name != kw::UnderscoreLifetime => {
Some(clean::GenericParamDef::lifetime(name))
}
_ => None,
});

let predicates = cx.tcx.explicit_predicates_of(did);

let (generics, decl) = clean::enter_impl_trait(cx, |cx| {
// NOTE: generics need to be cleaned before the decl!
let mut generics = clean_ty_generics(cx, cx.tcx.generics_of(did), predicates);
// FIXME: This does not place parameters in source order (late-bound ones come last)
generics.params.extend(late_bound_regions);
generics.params.extend(clean_bound_vars(sig.bound_vars()));
let decl = clean_fn_decl_from_did_and_sig(cx, Some(did), sig);
(generics, decl)
});
Expand Down
Loading

0 comments on commit a7bb2f6

Please sign in to comment.