Skip to content

Commit a7bb2f6

Browse files
committed
Auto merge of rust-lang#116408 - matthiaskrgr:rollup-hmolg4m, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#115961 (Replace 'mutex' with 'lock' in RwLock documentation) - rust-lang#116146 (Clarify `arg` and `args` documentation) - rust-lang#116363 (Adapt `todo!` documentation to mention displaying custom values) - rust-lang#116365 (bootstrap: make copying linker binaries conditional) - rust-lang#116388 (rustdoc: fix & clean up handling of cross-crate higher-ranked parameters) - rust-lang#116393 (Emit feature gate *warning* for `auto` traits pre-expansion) - rust-lang#116395 (Mark myself as vacation or whatever) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4910642 + d494048 commit a7bb2f6

File tree

23 files changed

+172
-127
lines changed

23 files changed

+172
-127
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
603603
"exclusive range pattern syntax is experimental"
604604
);
605605
gate_all_legacy_dont_use!(try_blocks, "`try` blocks are unstable");
606+
gate_all_legacy_dont_use!(auto_traits, "`auto` traits are unstable");
606607

607608
visit::walk_crate(&mut visitor, krate);
608609
}

compiler/rustc_parse/src/parser/item.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,12 @@ impl<'a> Parser<'a> {
813813
fn parse_item_trait(&mut self, attrs: &mut AttrVec, lo: Span) -> PResult<'a, ItemInfo> {
814814
let unsafety = self.parse_unsafety(Case::Sensitive);
815815
// Parse optional `auto` prefix.
816-
let is_auto = if self.eat_keyword(kw::Auto) { IsAuto::Yes } else { IsAuto::No };
816+
let is_auto = if self.eat_keyword(kw::Auto) {
817+
self.sess.gated_spans.gate(sym::auto_traits, self.prev_token.span);
818+
IsAuto::Yes
819+
} else {
820+
IsAuto::No
821+
};
817822

818823
self.expect_keyword(kw::Trait)?;
819824
let ident = self.parse_ident()?;

library/core/src/macros/mod.rs

+24-10
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,8 @@ macro_rules! unreachable {
719719
/// The difference between `unimplemented!` and [`todo!`] is that while `todo!`
720720
/// conveys an intent of implementing the functionality later and the message is "not yet
721721
/// implemented", `unimplemented!` makes no such claims. Its message is "not implemented".
722-
/// Also some IDEs will mark `todo!`s.
722+
///
723+
/// Also, some IDEs will mark `todo!`s.
723724
///
724725
/// # Panics
725726
///
@@ -805,50 +806,63 @@ macro_rules! unimplemented {
805806
/// The difference between [`unimplemented!`] and `todo!` is that while `todo!` conveys
806807
/// an intent of implementing the functionality later and the message is "not yet
807808
/// implemented", `unimplemented!` makes no such claims. Its message is "not implemented".
808-
/// Also some IDEs will mark `todo!`s.
809+
///
810+
/// Also, some IDEs will mark `todo!`s.
809811
///
810812
/// # Panics
811813
///
812-
/// This will always [`panic!`].
814+
/// This will always [`panic!`] because `todo!` is just a shorthand for `panic!` with a
815+
/// fixed, specific message.
816+
///
817+
/// Like `panic!`, this macro has a second form for displaying custom values.
813818
///
814819
/// # Examples
815820
///
816821
/// Here's an example of some in-progress code. We have a trait `Foo`:
817822
///
818823
/// ```
819824
/// trait Foo {
820-
/// fn bar(&self);
825+
/// fn bar(&self) -> u8;
821826
/// fn baz(&self);
827+
/// fn qux(&self) -> Result<u64, ()>;
822828
/// }
823829
/// ```
824830
///
825831
/// We want to implement `Foo` on one of our types, but we also want to work on
826832
/// just `bar()` first. In order for our code to compile, we need to implement
827-
/// `baz()`, so we can use `todo!`:
833+
/// `baz()` and `qux()`, so we can use `todo!`:
828834
///
829835
/// ```
830836
/// # trait Foo {
831-
/// # fn bar(&self);
837+
/// # fn bar(&self) -> u8;
832838
/// # fn baz(&self);
839+
/// # fn qux(&self) -> Result<u64, ()>;
833840
/// # }
834841
/// struct MyStruct;
835842
///
836843
/// impl Foo for MyStruct {
837-
/// fn bar(&self) {
838-
/// // implementation goes here
844+
/// fn bar(&self) -> u8 {
845+
/// 1 + 1
839846
/// }
840847
///
841848
/// fn baz(&self) {
842-
/// // let's not worry about implementing baz() for now
849+
/// // Let's not worry about implementing baz() for now
843850
/// todo!();
844851
/// }
852+
///
853+
/// fn qux(&self) -> Result<u64, ()> {
854+
/// // We can add a message to todo! to display our omission.
855+
/// // This will display:
856+
/// // "thread 'main' panicked at 'not yet implemented: MyStruct is not yet quxable'".
857+
/// todo!("MyStruct is not yet quxable");
858+
/// }
845859
/// }
846860
///
847861
/// fn main() {
848862
/// let s = MyStruct;
849863
/// s.bar();
850864
///
851-
/// // we aren't even using baz(), so this is fine.
865+
/// // We aren't even using baz() or qux(), so this is fine.
852866
/// }
853867
/// ```
854868
#[macro_export]

library/std/src/process.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ impl Command {
607607
///
608608
/// Note that the argument is not passed through a shell, but given
609609
/// literally to the program. This means that shell syntax like quotes,
610-
/// escaped characters, word splitting, glob patterns, substitution, etc.
610+
/// escaped characters, word splitting, glob patterns, variable substitution, etc.
611611
/// have no effect.
612612
///
613613
/// # Examples
@@ -637,7 +637,7 @@ impl Command {
637637
///
638638
/// Note that the arguments are not passed through a shell, but given
639639
/// literally to the program. This means that shell syntax like quotes,
640-
/// escaped characters, word splitting, glob patterns, substitution, etc.
640+
/// escaped characters, word splitting, glob patterns, variable substitution, etc.
641641
/// have no effect.
642642
///
643643
/// # Examples

library/std/src/sync/rwlock.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ impl<T: ?Sized> RwLock<T> {
380380
///
381381
/// If the lock is poisoned, it will remain poisoned until this function is called. This allows
382382
/// recovering from a poisoned state and marking that it has recovered. For example, if the
383-
/// value is overwritten by a known-good value, then the mutex can be marked as un-poisoned. Or
383+
/// value is overwritten by a known-good value, then the lock can be marked as un-poisoned. Or
384384
/// possibly, the value could be inspected to determine if it is in a consistent state, and if
385385
/// so the poison is removed.
386386
///
@@ -397,7 +397,7 @@ impl<T: ?Sized> RwLock<T> {
397397
///
398398
/// let _ = thread::spawn(move || {
399399
/// let _lock = c_lock.write().unwrap();
400-
/// panic!(); // the mutex gets poisoned
400+
/// panic!(); // the lock gets poisoned
401401
/// }).join();
402402
///
403403
/// assert_eq!(lock.is_poisoned(), true);

src/bootstrap/compile.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,14 @@ impl Step for Std {
167167
.rustc_snapshot_sysroot()
168168
.join("lib")
169169
.join("rustlib")
170-
.join(&compiler.host.triple)
170+
.join(compiler.host.triple)
171171
.join("bin");
172-
let target_sysroot_bin =
173-
builder.sysroot_libdir(compiler, target).parent().unwrap().join("bin");
174-
t!(fs::create_dir_all(&target_sysroot_bin));
175-
builder.cp_r(&src_sysroot_bin, &target_sysroot_bin);
172+
if src_sysroot_bin.exists() {
173+
let target_sysroot_bin =
174+
builder.sysroot_libdir(compiler, target).parent().unwrap().join("bin");
175+
t!(fs::create_dir_all(&target_sysroot_bin));
176+
builder.cp_r(&src_sysroot_bin, &target_sysroot_bin);
177+
}
176178
}
177179

178180
let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "build");

src/librustdoc/clean/auto_trait.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@ where
551551
WherePredicate::RegionPredicate { lifetime, bounds } => {
552552
lifetime_to_bounds.entry(lifetime).or_default().extend(bounds);
553553
}
554-
WherePredicate::EqPredicate { lhs, rhs, bound_params } => {
555-
match *lhs {
554+
WherePredicate::EqPredicate { lhs, rhs } => {
555+
match lhs {
556556
Type::QPath(box QPathData {
557557
ref assoc,
558558
ref self_type,
@@ -590,14 +590,13 @@ where
590590
GenericArgs::AngleBracketed { ref mut bindings, .. } => {
591591
bindings.push(TypeBinding {
592592
assoc: assoc.clone(),
593-
kind: TypeBindingKind::Equality { term: *rhs },
593+
kind: TypeBindingKind::Equality { term: rhs },
594594
});
595595
}
596596
GenericArgs::Parenthesized { .. } => {
597597
existing_predicates.push(WherePredicate::EqPredicate {
598598
lhs: lhs.clone(),
599599
rhs,
600-
bound_params,
601600
});
602601
continue; // If something other than a Fn ends up
603602
// with parentheses, leave it alone

src/librustdoc/clean/inline.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ use rustc_span::hygiene::MacroKind;
1818
use rustc_span::symbol::{kw, sym, Symbol};
1919

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

240240
fn build_external_function<'tcx>(cx: &mut DocContext<'tcx>, did: DefId) -> Box<clean::Function> {
241241
let sig = cx.tcx.fn_sig(did).instantiate_identity();
242-
243-
let late_bound_regions = sig.bound_vars().into_iter().filter_map(|var| match var {
244-
ty::BoundVariableKind::Region(ty::BrNamed(_, name)) if name != kw::UnderscoreLifetime => {
245-
Some(clean::GenericParamDef::lifetime(name))
246-
}
247-
_ => None,
248-
});
249-
250242
let predicates = cx.tcx.explicit_predicates_of(did);
243+
251244
let (generics, decl) = clean::enter_impl_trait(cx, |cx| {
252245
// NOTE: generics need to be cleaned before the decl!
253246
let mut generics = clean_ty_generics(cx, cx.tcx.generics_of(did), predicates);
254247
// FIXME: This does not place parameters in source order (late-bound ones come last)
255-
generics.params.extend(late_bound_regions);
248+
generics.params.extend(clean_bound_vars(sig.bound_vars()));
256249
let decl = clean_fn_decl_from_did_and_sig(cx, Some(did), sig);
257250
(generics, decl)
258251
});

0 commit comments

Comments
 (0)