Auto merge of #44233 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 10 pull requests - Successful merges: #44192, #44199, #44202, #44203, #44205, #44207, #44209, #44223, #44230, #44231 - Failed merges:
This commit is contained in:
commit
45d31e7310
12 changed files with 235 additions and 91 deletions
|
@ -3,7 +3,7 @@ Version 1.20.0 (2017-08-31)
|
|||
|
||||
Language
|
||||
--------
|
||||
- [Associated constants in traits is now stabilised.][42809]
|
||||
- [Associated constants are now stabilised.][42809]
|
||||
- [A lot of macro bugs are now fixed.][42913]
|
||||
|
||||
Compiler
|
||||
|
@ -77,7 +77,7 @@ Stabilized APIs
|
|||
- [`slice::sort_unstable_by_key`]
|
||||
- [`slice::sort_unstable_by`]
|
||||
- [`slice::sort_unstable`]
|
||||
- [`ste::from_boxed_utf8_unchecked`]
|
||||
- [`str::from_boxed_utf8_unchecked`]
|
||||
- [`str::as_bytes_mut`]
|
||||
- [`str::as_bytes_mut`]
|
||||
- [`str::from_utf8_mut`]
|
||||
|
|
|
@ -757,7 +757,7 @@ impl Step for Src {
|
|||
"src/libprofiler_builtins",
|
||||
];
|
||||
let std_src_dirs_exclude = [
|
||||
"src/compiler-rt/test",
|
||||
"src/libcompiler_builtins/compiler-rt/test",
|
||||
"src/jemalloc/test/unit",
|
||||
];
|
||||
|
||||
|
|
|
@ -407,6 +407,7 @@ impl Step for Openssl {
|
|||
"i686-unknown-freebsd" => "BSD-x86-elf",
|
||||
"i686-unknown-linux-gnu" => "linux-elf",
|
||||
"i686-unknown-linux-musl" => "linux-elf",
|
||||
"i686-unknown-netbsd" => "BSD-x86-elf",
|
||||
"mips-unknown-linux-gnu" => "linux-mips32",
|
||||
"mips64-unknown-linux-gnuabi64" => "linux64-mips64",
|
||||
"mips64el-unknown-linux-gnuabi64" => "linux64-mips64",
|
||||
|
|
|
@ -593,7 +593,7 @@ macro_rules! profq_key {
|
|||
macro_rules! define_maps {
|
||||
(<$tcx:tt>
|
||||
$($(#[$attr:meta])*
|
||||
[$($modifiers:tt)*] $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
|
||||
[$($modifiers:tt)*] fn $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
|
||||
define_map_struct! {
|
||||
tcx: $tcx,
|
||||
input: ($(([$($modifiers)*] [$($attr)*] [$name]))*)
|
||||
|
@ -954,12 +954,12 @@ macro_rules! define_provider_struct {
|
|||
// the driver creates (using several `rustc_*` crates).
|
||||
define_maps! { <'tcx>
|
||||
/// Records the type of every item.
|
||||
[] type_of: TypeOfItem(DefId) -> Ty<'tcx>,
|
||||
[] fn type_of: TypeOfItem(DefId) -> Ty<'tcx>,
|
||||
|
||||
/// Maps from the def-id of an item (trait/struct/enum/fn) to its
|
||||
/// associated generics and predicates.
|
||||
[] generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics,
|
||||
[] predicates_of: PredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
|
||||
[] fn generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics,
|
||||
[] fn predicates_of: PredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
|
||||
|
||||
/// Maps from the def-id of a trait to the list of
|
||||
/// super-predicates. This is a subset of the full list of
|
||||
|
@ -967,145 +967,146 @@ define_maps! { <'tcx>
|
|||
/// evaluate them even during type conversion, often before the
|
||||
/// full predicates are available (note that supertraits have
|
||||
/// additional acyclicity requirements).
|
||||
[] super_predicates_of: SuperPredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
|
||||
[] fn super_predicates_of: SuperPredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
|
||||
|
||||
/// To avoid cycles within the predicates of a single item we compute
|
||||
/// per-type-parameter predicates for resolving `T::AssocTy`.
|
||||
[] type_param_predicates: type_param_predicates((DefId, DefId))
|
||||
[] fn type_param_predicates: type_param_predicates((DefId, DefId))
|
||||
-> ty::GenericPredicates<'tcx>,
|
||||
|
||||
[] trait_def: TraitDefOfItem(DefId) -> &'tcx ty::TraitDef,
|
||||
[] adt_def: AdtDefOfItem(DefId) -> &'tcx ty::AdtDef,
|
||||
[] adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
|
||||
[] adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
|
||||
[] adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
|
||||
[] fn trait_def: TraitDefOfItem(DefId) -> &'tcx ty::TraitDef,
|
||||
[] fn adt_def: AdtDefOfItem(DefId) -> &'tcx ty::AdtDef,
|
||||
[] fn adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
|
||||
[] fn adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
|
||||
[] fn adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
|
||||
|
||||
/// True if this is a const fn
|
||||
[] is_const_fn: IsConstFn(DefId) -> bool,
|
||||
[] fn is_const_fn: IsConstFn(DefId) -> bool,
|
||||
|
||||
/// True if this is a foreign item (i.e., linked via `extern { ... }`).
|
||||
[] is_foreign_item: IsForeignItem(DefId) -> bool,
|
||||
[] fn is_foreign_item: IsForeignItem(DefId) -> bool,
|
||||
|
||||
/// True if this is a default impl (aka impl Foo for ..)
|
||||
[] is_default_impl: IsDefaultImpl(DefId) -> bool,
|
||||
[] fn is_default_impl: IsDefaultImpl(DefId) -> bool,
|
||||
|
||||
/// Get a map with the variance of every item; use `item_variance`
|
||||
/// instead.
|
||||
[] crate_variances: crate_variances(CrateNum) -> Rc<ty::CrateVariancesMap>,
|
||||
[] fn crate_variances: crate_variances(CrateNum) -> Rc<ty::CrateVariancesMap>,
|
||||
|
||||
/// Maps from def-id of a type or region parameter to its
|
||||
/// (inferred) variance.
|
||||
[] variances_of: ItemVariances(DefId) -> Rc<Vec<ty::Variance>>,
|
||||
[] fn variances_of: ItemVariances(DefId) -> Rc<Vec<ty::Variance>>,
|
||||
|
||||
/// Maps from an impl/trait def-id to a list of the def-ids of its items
|
||||
[] associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
|
||||
[] fn associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
|
||||
|
||||
/// Maps from a trait item to the trait item "descriptor"
|
||||
[] associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
|
||||
[] fn associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
|
||||
|
||||
[] impl_trait_ref: ImplTraitRef(DefId) -> Option<ty::TraitRef<'tcx>>,
|
||||
[] impl_polarity: ImplPolarity(DefId) -> hir::ImplPolarity,
|
||||
[] fn impl_trait_ref: ImplTraitRef(DefId) -> Option<ty::TraitRef<'tcx>>,
|
||||
[] fn impl_polarity: ImplPolarity(DefId) -> hir::ImplPolarity,
|
||||
|
||||
/// Maps a DefId of a type to a list of its inherent impls.
|
||||
/// Contains implementations of methods that are inherent to a type.
|
||||
/// Methods in these implementations don't need to be exported.
|
||||
[] inherent_impls: InherentImpls(DefId) -> Rc<Vec<DefId>>,
|
||||
[] fn inherent_impls: InherentImpls(DefId) -> Rc<Vec<DefId>>,
|
||||
|
||||
/// Set of all the def-ids in this crate that have MIR associated with
|
||||
/// them. This includes all the body owners, but also things like struct
|
||||
/// constructors.
|
||||
[] mir_keys: mir_keys(CrateNum) -> Rc<DefIdSet>,
|
||||
[] fn mir_keys: mir_keys(CrateNum) -> Rc<DefIdSet>,
|
||||
|
||||
/// Maps DefId's that have an associated Mir to the result
|
||||
/// of the MIR qualify_consts pass. The actual meaning of
|
||||
/// the value isn't known except to the pass itself.
|
||||
[] mir_const_qualif: MirConstQualif(DefId) -> u8,
|
||||
[] fn mir_const_qualif: MirConstQualif(DefId) -> u8,
|
||||
|
||||
/// Fetch the MIR for a given def-id up till the point where it is
|
||||
/// ready for const evaluation.
|
||||
///
|
||||
/// See the README for the `mir` module for details.
|
||||
[] mir_const: MirConst(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
|
||||
[] fn mir_const: MirConst(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
|
||||
|
||||
[] mir_validated: MirValidated(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
|
||||
[] fn mir_validated: MirValidated(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
|
||||
|
||||
/// MIR after our optimization passes have run. This is MIR that is ready
|
||||
/// for trans. This is also the only query that can fetch non-local MIR, at present.
|
||||
[] optimized_mir: MirOptimized(DefId) -> &'tcx mir::Mir<'tcx>,
|
||||
[] fn optimized_mir: MirOptimized(DefId) -> &'tcx mir::Mir<'tcx>,
|
||||
|
||||
/// Type of each closure. The def ID is the ID of the
|
||||
/// expression defining the closure.
|
||||
[] closure_kind: ClosureKind(DefId) -> ty::ClosureKind,
|
||||
[] fn closure_kind: ClosureKind(DefId) -> ty::ClosureKind,
|
||||
|
||||
/// The signature of functions and closures.
|
||||
[] fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
|
||||
[] fn fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
|
||||
|
||||
/// Records the signature of each generator. The def ID is the ID of the
|
||||
/// expression defining the closure.
|
||||
[] generator_sig: GenSignature(DefId) -> Option<ty::PolyGenSig<'tcx>>,
|
||||
[] fn generator_sig: GenSignature(DefId) -> Option<ty::PolyGenSig<'tcx>>,
|
||||
|
||||
/// Caches CoerceUnsized kinds for impls on custom types.
|
||||
[] coerce_unsized_info: CoerceUnsizedInfo(DefId)
|
||||
[] fn coerce_unsized_info: CoerceUnsizedInfo(DefId)
|
||||
-> ty::adjustment::CoerceUnsizedInfo,
|
||||
|
||||
[] typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
|
||||
[] fn typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
|
||||
|
||||
[] typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
|
||||
[] fn typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
|
||||
|
||||
[] has_typeck_tables: HasTypeckTables(DefId) -> bool,
|
||||
[] fn has_typeck_tables: HasTypeckTables(DefId) -> bool,
|
||||
|
||||
[] coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
|
||||
[] fn coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
|
||||
|
||||
[] borrowck: BorrowCheck(DefId) -> (),
|
||||
[] fn borrowck: BorrowCheck(DefId) -> (),
|
||||
// FIXME: shouldn't this return a `Result<(), BorrowckErrors>` instead?
|
||||
[] mir_borrowck: MirBorrowCheck(DefId) -> (),
|
||||
[] fn mir_borrowck: MirBorrowCheck(DefId) -> (),
|
||||
|
||||
/// Gets a complete map from all types to their inherent impls.
|
||||
/// Not meant to be used directly outside of coherence.
|
||||
/// (Defined only for LOCAL_CRATE)
|
||||
[] crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
|
||||
[] fn crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
|
||||
|
||||
/// Checks all types in the krate for overlap in their inherent impls. Reports errors.
|
||||
/// Not meant to be used directly outside of coherence.
|
||||
/// (Defined only for LOCAL_CRATE)
|
||||
[] crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum) -> (),
|
||||
[] fn crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum) -> (),
|
||||
|
||||
/// Results of evaluating const items or constants embedded in
|
||||
/// other items (such as enum variant explicit discriminants).
|
||||
[] const_eval: const_eval_dep_node(ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>)
|
||||
[] fn const_eval: const_eval_dep_node(ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>)
|
||||
-> const_val::EvalResult<'tcx>,
|
||||
|
||||
/// Performs the privacy check and computes "access levels".
|
||||
[] privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Rc<AccessLevels>,
|
||||
[] fn privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Rc<AccessLevels>,
|
||||
|
||||
[] reachable_set: reachability_dep_node(CrateNum) -> Rc<NodeSet>,
|
||||
[] fn reachable_set: reachability_dep_node(CrateNum) -> Rc<NodeSet>,
|
||||
|
||||
/// Per-function `RegionMaps`. The `DefId` should be the owner-def-id for the fn body;
|
||||
/// in the case of closures or "inline" expressions, this will be redirected to the enclosing
|
||||
/// fn item.
|
||||
[] region_maps: RegionMaps(DefId) -> Rc<RegionMaps>,
|
||||
[] fn region_maps: RegionMaps(DefId) -> Rc<RegionMaps>,
|
||||
|
||||
[] mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
|
||||
[] fn mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
|
||||
|
||||
[] def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
|
||||
[] symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
|
||||
[] fn def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
|
||||
[] fn symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
|
||||
|
||||
[] describe_def: DescribeDef(DefId) -> Option<Def>,
|
||||
[] def_span: DefSpan(DefId) -> Span,
|
||||
[] stability: Stability(DefId) -> Option<attr::Stability>,
|
||||
[] deprecation: Deprecation(DefId) -> Option<attr::Deprecation>,
|
||||
[] item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>,
|
||||
[] fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
|
||||
[] impl_parent: ImplParent(DefId) -> Option<DefId>,
|
||||
[] trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
|
||||
[] is_exported_symbol: IsExportedSymbol(DefId) -> bool,
|
||||
[] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
|
||||
[] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
|
||||
[] is_mir_available: IsMirAvailable(DefId) -> bool,
|
||||
[] fn describe_def: DescribeDef(DefId) -> Option<Def>,
|
||||
[] fn def_span: DefSpan(DefId) -> Span,
|
||||
[] fn stability: Stability(DefId) -> Option<attr::Stability>,
|
||||
[] fn deprecation: Deprecation(DefId) -> Option<attr::Deprecation>,
|
||||
[] fn item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>,
|
||||
[] fn fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
|
||||
[] fn impl_parent: ImplParent(DefId) -> Option<DefId>,
|
||||
[] fn trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
|
||||
[] fn is_exported_symbol: IsExportedSymbol(DefId) -> bool,
|
||||
[] fn item_body_nested_bodies: ItemBodyNestedBodies(DefId)
|
||||
-> Rc<BTreeMap<hir::BodyId, hir::Body>>,
|
||||
[] fn const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
|
||||
[] fn is_mir_available: IsMirAvailable(DefId) -> bool,
|
||||
|
||||
[] trait_impls_of: TraitImpls(DefId) -> Rc<ty::trait_def::TraitImpls>,
|
||||
[] specialization_graph_of: SpecializationGraph(DefId) -> Rc<specialization_graph::Graph>,
|
||||
[] is_object_safe: ObjectSafety(DefId) -> bool,
|
||||
[] fn trait_impls_of: TraitImpls(DefId) -> Rc<ty::trait_def::TraitImpls>,
|
||||
[] fn specialization_graph_of: SpecializationGraph(DefId) -> Rc<specialization_graph::Graph>,
|
||||
[] fn is_object_safe: ObjectSafety(DefId) -> bool,
|
||||
|
||||
// Get the ParameterEnvironment for a given item; this environment
|
||||
// will be in "user-facing" mode, meaning that it is suitabe for
|
||||
|
@ -1113,32 +1114,32 @@ define_maps! { <'tcx>
|
|||
// associated types. This is almost always what you want,
|
||||
// unless you are doing MIR optimizations, in which case you
|
||||
// might want to use `reveal_all()` method to change modes.
|
||||
[] param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
|
||||
[] fn param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
|
||||
|
||||
// Trait selection queries. These are best used by invoking `ty.moves_by_default()`,
|
||||
// `ty.is_copy()`, etc, since that will prune the environment where possible.
|
||||
[] is_copy_raw: is_copy_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
|
||||
[] is_sized_raw: is_sized_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
|
||||
[] is_freeze_raw: is_freeze_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
|
||||
[] needs_drop_raw: needs_drop_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
|
||||
[] layout_raw: layout_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
|
||||
[] fn is_copy_raw: is_copy_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
|
||||
[] fn is_sized_raw: is_sized_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
|
||||
[] fn is_freeze_raw: is_freeze_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
|
||||
[] fn needs_drop_raw: needs_drop_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
|
||||
[] fn layout_raw: layout_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
|
||||
-> Result<&'tcx Layout, LayoutError<'tcx>>,
|
||||
|
||||
[] dylib_dependency_formats: DylibDepFormats(DefId)
|
||||
[] fn dylib_dependency_formats: DylibDepFormats(DefId)
|
||||
-> Rc<Vec<(CrateNum, LinkagePreference)>>,
|
||||
|
||||
[] is_allocator: IsAllocator(DefId) -> bool,
|
||||
[] is_panic_runtime: IsPanicRuntime(DefId) -> bool,
|
||||
[] is_compiler_builtins: IsCompilerBuiltins(DefId) -> bool,
|
||||
[] has_global_allocator: HasGlobalAllocator(DefId) -> bool,
|
||||
[] fn is_allocator: IsAllocator(DefId) -> bool,
|
||||
[] fn is_panic_runtime: IsPanicRuntime(DefId) -> bool,
|
||||
[] fn is_compiler_builtins: IsCompilerBuiltins(DefId) -> bool,
|
||||
[] fn has_global_allocator: HasGlobalAllocator(DefId) -> bool,
|
||||
|
||||
[] extern_crate: ExternCrate(DefId) -> Rc<Option<ExternCrate>>,
|
||||
[] fn extern_crate: ExternCrate(DefId) -> Rc<Option<ExternCrate>>,
|
||||
|
||||
[] lint_levels: lint_levels(CrateNum) -> Rc<lint::LintLevelMap>,
|
||||
[] fn lint_levels: lint_levels(CrateNum) -> Rc<lint::LintLevelMap>,
|
||||
|
||||
[] specializes: specializes_node((DefId, DefId)) -> bool,
|
||||
[] in_scope_traits: InScopeTraits(HirId) -> Option<Rc<Vec<TraitCandidate>>>,
|
||||
[] module_exports: ModuleExports(HirId) -> Option<Rc<Vec<Export>>>,
|
||||
[] fn specializes: specializes_node((DefId, DefId)) -> bool,
|
||||
[] fn in_scope_traits: InScopeTraits(HirId) -> Option<Rc<Vec<TraitCandidate>>>,
|
||||
[] fn module_exports: ModuleExports(HirId) -> Option<Rc<Vec<Export>>>,
|
||||
}
|
||||
|
||||
fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {
|
||||
|
|
|
@ -447,6 +447,7 @@ impl<'b, 'a, 'tcx> TypeVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'b
|
|||
ty::TyProjection(ref proj) => Some(proj.item_def_id),
|
||||
ty::TyFnDef(def_id, ..) |
|
||||
ty::TyClosure(def_id, ..) |
|
||||
ty::TyGenerator(def_id, ..) |
|
||||
ty::TyAnon(def_id, _) => Some(def_id),
|
||||
_ => None
|
||||
};
|
||||
|
|
|
@ -658,11 +658,13 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
|
|||
|
||||
.toggle-wrapper {
|
||||
position: relative;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.toggle-wrapper.collapsed {
|
||||
height: 1em;
|
||||
height: 25px;
|
||||
transition: height .2s;
|
||||
margin-bottom: .6em;
|
||||
}
|
||||
|
||||
.collapse-toggle > .inner {
|
||||
|
@ -704,14 +706,16 @@ span.since {
|
|||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.variant + .toggle-wrapper > a {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.sub-variant, .sub-variant > h3 {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
.toggle-label {
|
||||
display: inline-block;
|
||||
margin-left: 4px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.enum > .toggle-wrapper + .docblock, .struct > .toggle-wrapper + .docblock {
|
||||
margin-left: 30px;
|
||||
margin-bottom: 20px;
|
||||
|
|
|
@ -767,7 +767,7 @@ impl hash::Hash for SocketAddrV6 {
|
|||
///
|
||||
/// let stream = TcpStream::connect(("127.0.0.1", 443));
|
||||
/// // or
|
||||
/// let stream = TcpStream::connect("127.0.0.1.443");
|
||||
/// let stream = TcpStream::connect("127.0.0.1:443");
|
||||
/// // or
|
||||
/// let stream = TcpStream::connect((Ipv4Addr::new(127, 0, 0, 1), 443));
|
||||
/// ```
|
||||
|
|
|
@ -111,15 +111,18 @@ impl TcpStream {
|
|||
/// `addr` is an address of the remote host. Anything which implements
|
||||
/// [`ToSocketAddrs`] trait can be supplied for the address; see this trait
|
||||
/// documentation for concrete examples.
|
||||
/// In case [`ToSocketAddrs::to_socket_addrs()`] returns more than one entry,
|
||||
/// then the first valid and reachable address is used.
|
||||
///
|
||||
/// If `addr` yields multiple addresses, `connect` will be attempted with
|
||||
/// each of the addresses until a connection is successful. If none of
|
||||
/// the addresses result in a successful connection, the error returned from
|
||||
/// the last connection attempt (the last address) is returned.
|
||||
///
|
||||
/// [`ToSocketAddrs`]: ../../std/net/trait.ToSocketAddrs.html
|
||||
/// [`ToSocketAddrs::to_socket_addrs()`]:
|
||||
/// ../../std/net/trait.ToSocketAddrs.html#tymethod.to_socket_addrs
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Open a TCP connection to `127.0.0.1:8080`:
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::net::TcpStream;
|
||||
///
|
||||
|
@ -129,6 +132,23 @@ impl TcpStream {
|
|||
/// println!("Couldn't connect to server...");
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Open a TCP connection to `127.0.0.1:8080`. If the connection fails, open
|
||||
/// a TCP connection to `127.0.0.1:8081`:
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::net::{SocketAddr, TcpStream};
|
||||
///
|
||||
/// let addrs = [
|
||||
/// SocketAddr::from(([127, 0, 0, 1], 8080)),
|
||||
/// SocketAddr::from(([127, 0, 0, 1], 8081)),
|
||||
/// ];
|
||||
/// if let Ok(stream) = TcpStream::connect(&addrs[..]) {
|
||||
/// println!("Connected to the server!");
|
||||
/// } else {
|
||||
/// println!("Couldn't connect to server...");
|
||||
/// }
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn connect<A: ToSocketAddrs>(addr: A) -> io::Result<TcpStream> {
|
||||
super::each_addr(addr, net_imp::TcpStream::connect).map(TcpStream)
|
||||
|
@ -557,16 +577,36 @@ impl TcpListener {
|
|||
/// The address type can be any implementor of [`ToSocketAddrs`] trait. See
|
||||
/// its documentation for concrete examples.
|
||||
///
|
||||
/// If `addr` yields multiple addresses, `bind` will be attempted with
|
||||
/// each of the addresses until one succeeds and returns the listener. If
|
||||
/// none of the addresses succeed in creating a listener, the error returned
|
||||
/// from the last attempt (the last address) is returned.
|
||||
///
|
||||
/// [`local_addr`]: #method.local_addr
|
||||
/// [`ToSocketAddrs`]: ../../std/net/trait.ToSocketAddrs.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Create a TCP listener bound to `127.0.0.1:80`:
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::net::TcpListener;
|
||||
///
|
||||
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
|
||||
/// ```
|
||||
///
|
||||
/// Create a TCP listener bound to `127.0.0.1:80`. If that fails, create a
|
||||
/// TCP listener bound to `127.0.0.1:443`:
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::net::{SocketAddr, TcpListener};
|
||||
///
|
||||
/// let addrs = [
|
||||
/// SocketAddr::from(([127, 0, 0, 1], 80)),
|
||||
/// SocketAddr::from(([127, 0, 0, 1], 443)),
|
||||
/// ];
|
||||
/// let listener = TcpListener::bind(&addrs[..]).unwrap();
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn bind<A: ToSocketAddrs>(addr: A) -> io::Result<TcpListener> {
|
||||
super::each_addr(addr, net_imp::TcpListener::bind).map(TcpListener)
|
||||
|
|
|
@ -69,14 +69,34 @@ impl UdpSocket {
|
|||
/// The address type can be any implementor of [`ToSocketAddrs`] trait. See
|
||||
/// its documentation for concrete examples.
|
||||
///
|
||||
/// If `addr` yields multiple addresses, `bind` will be attempted with
|
||||
/// each of the addresses until one succeeds and returns the socket. If none
|
||||
/// of the addresses succeed in creating a socket, the error returned from
|
||||
/// the last attempt (the last address) is returned.
|
||||
///
|
||||
/// [`ToSocketAddrs`]: ../../std/net/trait.ToSocketAddrs.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Create a UDP socket bound to `127.0.0.1:3400`:
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::net::UdpSocket;
|
||||
///
|
||||
/// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address");
|
||||
/// let socket = UdpSocket::bind("127.0.0.1:3400").expect("couldn't bind to address");
|
||||
/// ```
|
||||
///
|
||||
/// Create a UDP socket bound to `127.0.0.1:3400`. If the socket cannot be
|
||||
/// bound to that address, create a UDP socket bound to `127.0.0.1:3401`:
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::net::{SocketAddr, UdpSocket};
|
||||
///
|
||||
/// let addrs = [
|
||||
/// SocketAddr::from(([127, 0, 0, 1], 3400)),
|
||||
/// SocketAddr::from(([127, 0, 0, 1], 3401)),
|
||||
/// ];
|
||||
/// let socket = UdpSocket::bind(&addrs[..]).expect("couldn't bind to address");
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn bind<A: ToSocketAddrs>(addr: A) -> io::Result<UdpSocket> {
|
||||
|
@ -130,6 +150,9 @@ impl UdpSocket {
|
|||
/// Address type can be any implementor of [`ToSocketAddrs`] trait. See its
|
||||
/// documentation for concrete examples.
|
||||
///
|
||||
/// It is possible for `addr` to yield multiple addresses, but `send_to`
|
||||
/// will only send data to the first address yielded by `addr`.
|
||||
///
|
||||
/// This will return an error when the IP version of the local socket
|
||||
/// does not match that returned from [`ToSocketAddrs`].
|
||||
///
|
||||
|
@ -562,14 +585,37 @@ impl UdpSocket {
|
|||
/// `recv` syscalls to be used to send data and also applies filters to only
|
||||
/// receive data from the specified address.
|
||||
///
|
||||
/// If `addr` yields multiple addresses, `connect` will be attempted with
|
||||
/// each of the addresses until a connection is successful. If none of
|
||||
/// the addresses are able to be connected, the error returned from the
|
||||
/// last connection attempt (the last address) is returned.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Create a UDP socket bound to `127.0.0.1:3400` and connect the socket to
|
||||
/// `127.0.0.1:8080`:
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::net::UdpSocket;
|
||||
///
|
||||
/// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address");
|
||||
/// let socket = UdpSocket::bind("127.0.0.1:3400").expect("couldn't bind to address");
|
||||
/// socket.connect("127.0.0.1:8080").expect("connect function failed");
|
||||
/// ```
|
||||
///
|
||||
/// Create a UDP socket bound to `127.0.0.1:3400` and connect the socket to
|
||||
/// `127.0.0.1:8080`. If that connection fails, then the UDP socket will
|
||||
/// connect to `127.0.0.1:8081`:
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::net::{SocketAddr, UdpSocket};
|
||||
///
|
||||
/// let socket = UdpSocket::bind("127.0.0.1:3400").expect("couldn't bind to address");
|
||||
/// let connect_addrs = [
|
||||
/// SocketAddr::from(([127, 0, 0, 1], 8080)),
|
||||
/// SocketAddr::from(([127, 0, 0, 1], 8081)),
|
||||
/// ];
|
||||
/// socket.connect(&connect_addrs[..]).expect("connect function failed");
|
||||
/// ```
|
||||
#[stable(feature = "net2_mutators", since = "1.9.0")]
|
||||
pub fn connect<A: ToSocketAddrs>(&self, addr: A) -> io::Result<()> {
|
||||
super::each_addr(addr, |addr| self.0.connect(addr))
|
||||
|
|
|
@ -115,6 +115,12 @@ impl Symbol {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a str> for Symbol {
|
||||
fn from(string: &'a str) -> Symbol {
|
||||
Symbol::intern(string)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Symbol {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}({})", self, self.0)
|
||||
|
|
24
src/test/run-pass/generator/auxiliary/xcrate-reachable.rs
Normal file
24
src/test/run-pass/generator/auxiliary/xcrate-reachable.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(conservative_impl_trait, generators, generator_trait)]
|
||||
|
||||
use std::ops::Generator;
|
||||
|
||||
fn msg() -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn foo() -> impl Generator<Yield=(), Return=u32> {
|
||||
|| {
|
||||
yield;
|
||||
return msg();
|
||||
}
|
||||
}
|
21
src/test/run-pass/generator/xcrate-reachable.rs
Normal file
21
src/test/run-pass/generator/xcrate-reachable.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:xcrate-reachable.rs
|
||||
|
||||
#![feature(conservative_impl_trait, generator_trait)]
|
||||
|
||||
extern crate xcrate_reachable as foo;
|
||||
|
||||
use std::ops::Generator;
|
||||
|
||||
fn main() {
|
||||
foo::foo().resume();
|
||||
}
|
Loading…
Reference in a new issue