Commit graph

110 commits

Author SHA1 Message Date
Ralf Jung
82f4a1a9b9 get rid of ConstPropUnsupported; use ZST marker structs instead 2020-03-22 12:16:24 +01:00
Peter Todd
f722964d00
Minor: note why we can rely on Any trait for safety 2020-01-28 20:53:45 -05:00
Mazdak Farrokhzad
e8819b62b4
Rollup merge of #68342 - lcnr:type_name_docs, r=Dylan-DPC
improve type_name_of_val docs

suggested by @Globidev in https://github.com/rust-lang/rust/issues/66359#issuecomment-575016612
2020-01-18 19:36:08 +01:00
lcnr/Bastian Kauschke
6b7f3e50df improve type_name_of_val docs 2020-01-18 14:43:08 +01:00
Mark Rousskov
a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
Mark Rousskov
6878913096 Document why Any is not an unsafe trait 2019-12-22 08:12:55 -05:00
Lzu Tao
c93198f90e use _val to ignore parameter of any::type_name_of_val 2019-12-21 16:48:35 +00:00
Mark Rousskov
82184440ec Propagate cfg bootstrap 2019-12-18 12:16:19 -05:00
lcnr/Bastian Kauschke
e28153e7a6 fix doc comment 2019-12-15 12:59:02 +01:00
Oliver Scherer
5e17e39881 Require stable/unstable annotations for the constness of all stable functions with a const modifier 2019-12-13 11:27:02 +01:00
Mikotochan
26e5fd4c96
Minor documentation fix
Fixed the documentation for any as is a trait rather than a type.
2019-11-29 20:47:16 +02:00
Mazdak Farrokhzad
0ae4a19cf3
Rollup merge of #65961 - lcnr:typename_of, r=Dylan-DPC
add fn type_name_of_val

This function is often useful during testing and mirrors `align_of_val` and `size_of_val`.

# Example

Showing the default type of integers.

```rust
let x = 7;
println!("per default, integers have the type: {}", std::any::type_name_of_val(&x));
```

To my knowledge this can currently not be done without defining a function similar to `type_name_of_val`.
2019-11-23 02:22:44 +01:00
lcnr/Bastian Kauschke
985e66362f add fn any::type_name_of_val 2019-11-19 10:18:53 +01:00
Oliver Scherer
954fc71962 Halloween... time to get rid of 👻 2019-11-06 11:04:42 +01:00
Oliver Scherer
02f9167f94 Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
Lzu Tao
940d48ed60 add example for type_name 2019-10-16 16:54:04 +00:00
Cerberuser
0510bbfb35
Added code element
Co-Authored-By: Jonas Schievink <jonasschievink@gmail.com>
2019-10-13 19:03:21 +07:00
Cerberuser
cfda050c01
Add dyn to Any documentation
I noticed that in documentation to `Any` trait the old trait object syntax is used, which could be confusing for newcomers, since we generally recommend using `dyn Trait` instead of just `Trait`. This PR changes the documentation comment, so that it uses `&dyn Any`, `&mut dyn Any` and `Box<dyn Any>`, correspondingly.
2019-10-13 18:48:07 +07:00
Lzu Tao
6c1b447f2e Remove unneeded fn main blocks from docs 2019-10-01 11:55:46 +00:00
Alexander Regueiro
b0006dff10 A few cosmetic improvements to code & comments in liballoc and libcore 2019-09-06 16:02:25 +01:00
Mark Rousskov
2601c86487 Handle cfg(bootstrap) throughout 2019-08-14 05:39:53 -04:00
TankhouseAle
4a3d41d334
Add the necessary changes to any.rs
Specifically the `#[rustc_const_unstable(feature = "const_type_name")]` attribute, as well as marking the actual function as `const`.
2019-07-29 23:02:29 -04:00
Steven Fackler
91fa898975 Stabilize the type_name intrinsic in core::any
Closes rust-lang/rfcs#1428
2019-07-24 21:35:49 -07:00
Mazdak Farrokhzad
dbfbadeac4 libcore: deny more... 2019-04-19 01:37:12 +02:00
Taiki Endo
360432f1e8 libcore => 2018 2019-04-18 14:47:35 +09:00
Alexander Regueiro
b87363e763 tests: doc comments 2019-02-10 23:42:32 +00:00
Simon Sapin
fb5d3c1f37 Stabilize Any::get_type_id and rename to type_id
FCP: https://github.com/rust-lang/rust/issues/27745#issuecomment-373906749
2019-01-22 14:25:27 +01:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Alexander Regueiro
ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
0xrgb
7c9bcc5266
Update any.rs documentation using keyword dyn 2018-11-19 15:59:21 +09:00
ljedrz
8646a17143 Enforce #![deny(bare_trait_objects)] in src/libcore 2018-07-25 10:21:41 +09:00
Ethan McCue
6f223cfc07
Any docs preposition change
This changes the docs referring to where a user should be wary of depending on "Any" trait impls from warning about relying on them "outside" of their code to warning about relying on them "inside" of their code.
2018-07-03 13:13:49 -07:00
Jeremy Fitzhardinge
87c3d7bee5 Fix up Any doc examples
Make the Any+Send+Sync examples use the right trait bounds, and fix a small whitespace issue.
2018-05-31 13:27:08 -07:00
Jeremy Fitzhardinge
72433e179d Add implementations for Any + Send + Sync
Implement `is`, `downcast_ref`, `downcast_mut` and `Debug` for
`Any + Send + Sync`.
2018-05-31 13:27:08 -07:00
Mark Simulacrum
33f5ceee1f stage0 cfg cleanup 2018-02-20 08:52:33 -07:00
Badel2
196fad0d00 Turn type_id into a constant intrinsic
Add rustc_const_unstable attribute for `any::TypeId::of`

Add test for `const fn TypeId::of`
2018-02-01 23:03:19 +01:00
Stjepan Glavina
d6da1d9b46 Various fixes to wording consistency in the docs 2017-03-22 17:19:52 +01:00
bors
55013cddef Auto merge of #38981 - sdleffler:patch-1, r=alexcrichton
Add PartialOrd, Ord derivations to TypeId

I want to be able to sort a `Vec` of types which contain `TypeId`s, so an `Ord` derivation would be very useful to me. `Hash` and `PartialEq`/`Eq` already exist, so the missing `PartialOrd` and `Ord` derivations feel like an oversight to me.
2017-02-14 04:29:26 +00:00
Sean Leffler
b08ab1e20d Add warning about varying hashes/orderings 2017-01-17 13:56:46 -08:00
Stjepan Glavina
d5c3becf00 Change to_owned to to_string in docs
We should teach conversion from `str` to `String` using `to_string`
rather than the legacy `to_owned`.
2017-01-13 01:57:48 +01:00
Sean Leffler
6365c4307a Add PartialOrd, Ord derivations to TypeId
I want to be able to sort a `Vec` of types which contain `TypeId`s, so an `Ord` derivation would be very useful to me. `Hash` already exists, so the missing `PartialOrd` and `Ord` derivations feel like an oversight to me.
2017-01-10 18:19:01 -08:00
Jethro Beekman
a29b503033 Add stable example to TypeId 2016-10-17 17:49:07 -07:00
Nick Cameron
14c62f91b7 Deprecate Reflect
[tracking issue](https://github.com/rust-lang/rust/issues/27749)
2016-10-12 08:40:22 +13:00
Andrew Paseltiner
2b10df7f24
Replace unnecessary uses of TraitObject with casts 2016-08-26 06:37:36 -04:00
Jeffrey Seyfried
e2ad3be178 Use #[prelude_import] in libcore. 2016-08-24 22:12:23 +00:00
Guillaume Gomez
4c3cff6c65 Improve std::any module doc 2016-07-10 19:41:50 +02:00
Aleksey Kladov
7abdbd4483 docs: simplify wording 2016-06-07 20:46:11 +03:00
Alex Crichton
73db76015e doc: Fix a bunch of broken links
A few categories:

* Links into compiler docs were just all removed as we're not generating
  compiler docs.
* Move up one more level to forcibly go to std docs to fix inlined documentation
  across the facade crates.
2016-03-08 13:44:14 -08:00
Steven Fackler
5d2275d53e Implement Any for unsized types
This is a bit weird since unsized types can't be used in trait objects,
but Any is *also* used as pure marker trait since Reflect isn't stable.
There are many cases (e.g. TypeMap) where all you need is a TypeId.
2016-01-14 23:02:32 -08:00
Jake Goulding
b8366b171a Correct reference to Box<Any> in Any docs 2015-12-11 18:44:11 -05:00