Commit Graph

136449 Commits

Author SHA1 Message Date
Yuki Okushi
5c0f5b69c2
Rollup merge of #79502 - Julian-Wollersberger:from_char_for_u64, r=withoutboats
Implement From<char> for u64 and u128.

With this PR you can write
```
let u = u64::from('👤');
let u = u128::from('👤');
```

Previously, you could already write `as` conversions ([Playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cee18febe28e69024357d099f07ca081)):
```
// Lossless conversions
dbg!('👤' as u32);    // Prints 128100
dbg!('👤' as u64);    // Prints 128100
dbg!('👤' as u128);   // Prints 128100

// truncates, thus no `From` impls.
dbg!('👤' as u8);     // Prints 100
dbg!('👤' as u16);    // Prints 62564

// These `From` impls already exist.
dbg!(u32::from('👤'));               // Prints 128100
dbg!(u64::from(u32::from('👤')));    // Prints 128100
```

The idea is from ``@gendx`` who opened [this Internals thread](https://internals.rust-lang.org/t/implement-from-char-for-u64/13454), and ``@withoutboats`` responded that someone should open a PR for it.
Some people mentioned `From<char>` impls for `f32` and `f64`, but that doesn't seem correct to me, so I didn't include them here.

I don't know what the feature should be named. Must it be registered somewhere, like unstable features?

r? ``@withoutboats``
2021-01-10 16:55:53 +09:00
Eric Seppanen
eef95871a4 fix broken link in PartialEq doc
PartialEq doc was attempting to link to [`Eq`] but instead we got a link
to `eq`. Disambiguate with "trait@Eq".
2021-01-09 22:40:48 -08:00
bors
7a193921a0 Auto merge of #77862 - danielhenrymantilla:rustdoc/fix-macros_2_0-paths, r=jyn514,petrochenkov
Rustdoc: Fix macros 2.0 and built-in derives being shown at the wrong path

Fixes #74355

  - ~~waiting on author + draft PR since my code ought to be cleaned up _w.r.t._ the way I avoid the `.unwrap()`s:~~

      - ~~dummy items may avoid the first `?`,~~

      - ~~but within the module traversal some tests did fail (hence the second `?`), meaning the crate did not possess the exact path of the containing module (`extern` / `impl` blocks maybe? I'll look into that).~~

r? `@jyn514`
2021-01-10 05:15:01 +00:00
Jeremy Fitzhardinge
67978d56c1 Fix --pretty=expanded with --remap-path-prefix
Per https://github.com/rust-lang/rust/issues/80832, using
--pretty=expanded and --remap-path-prefix results in an ICE.

This is becasue the session source files table is stored in remapped
form, whereas --pretty-expanded looks up unremapped files. This remaps
the path prefixes before lookup.
2021-01-09 18:55:50 -08:00
bors
7cf205610e Auto merge of #80831 - jyn514:no-inline, r=Mark-Simulacrum
Don't mark `force_query_with_job` as `inline(always)`

It's rather large, and using `inline(always)` forces it to be recompiled
in each calling crate. Hopefully this change will help with #65031. I intentionally only removed inline from `force_query_with_job` because the other functions are tiny and I wanted to measure this change on its own.

This may conflict with https://github.com/rust-lang/rust/issues/78780. I am not sure if it will hurt or help.

cc `@cjgillot`
2021-01-10 01:08:41 +00:00
bors
f30733adb9 Auto merge of #80441 - petrochenkov:kwtok, r=Aaron1011
ast: Remove some indirection layers from values in key-value attributes

Trying to address some perf regressions from https://github.com/rust-lang/rust/pull/78837#issuecomment-745380762.
2021-01-09 22:19:46 +00:00
Caio
3ee1a9caea Bless profile targets 2021-01-09 18:15:54 -03:00
Camelid
befd153098
Add comment to Vec::truncate explaining > vs >=
Hopefully this will prevent people from continuing to ask about this
over and over again :)

See [this Zulip discussion][1] for more.

[1]: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Vec.3A.3Atruncate.20implementation
2021-01-09 12:35:47 -08:00
Aaron Hill
3ed6caae60
Synthesize a TokenStream for StmtKind::Empty
Fixes #80760
2021-01-09 14:54:14 -05:00
bors
6184f23950 Auto merge of #80830 - Aaron1011:capture-token-empty-stack, r=petrochenkov
Use an empty `TokenCursorFrame` stack when capturing tokens

We will never need to pop  past our starting frame during token
capturing. Using an empty stack allows us to avoid pointless heap
allocations/deallocations.
2021-01-09 19:33:23 +00:00
Mara Bos
b293bbaba0 Don't set builtin_name for builtin macro implementations.
This used to be necessary for `is_builtin` in the past, but is no longer required.

Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2021-01-09 20:26:57 +01:00
Vadim Petrochenkov
71cd6f42a6 ast: Remove some indirection layers from values in key-value attributes 2021-01-09 21:50:39 +03:00
Mara Bos
0aad91b990 Formatting. 2021-01-09 19:50:12 +01:00
Mara Bos
d651fa78ce Allow #[rustc_builtin_macro = "name"].
This makes it possible to have both std::panic and core::panic as a
builtin macro, by using different builtin macro names for each.

Also removes SyntaxExtension::is_derive_copy, as the macro name (e.g.
sym::Copy) is now tracked and provides that information directly.
2021-01-09 19:50:06 +01:00
bors
d0beb70a65 Auto merge of #80563 - petrochenkov:expattronmac, r=Aaron1011
resolve/expand: Improve attribute expansion on macro definitions and calls

- Do not forget to visit attributes on macro definitions and calls in couple of places.
- Remove some weird special treatment of macro definition items, which is probably left from old times when macro definitions were treated more like macro calls.

Fixes https://github.com/rust-lang/rust/issues/80540
2021-01-09 16:46:54 +00:00
Simonas Kazlauskas
15ade4d504 Support download-ci-llvm on NixOS
In particular, the CI built `libLLVM-*.so` needs to have `libz.so`
RPATHed so that binaries like `llvm-config` work at all.
2021-01-09 18:29:25 +02:00
Vadim Petrochenkov
d81c1946c6 resolve/expand: Improve attribute expansion on macro definitions and calls 2021-01-09 18:43:01 +03:00
Guillaume Gomez
34d128a263 Replace under-used ImplPolarity enum with a boolean 2021-01-09 14:59:37 +01:00
bors
ef589490a7 Auto merge of #80808 - CAD97:patch-3, r=nagisa
Fix typo in Step trait

... I don't know how this major typo happened, whoops 🙃

`@bors` rollup=always
(comment only change)
2021-01-09 13:56:15 +00:00
Julian Wollersberger
e8cb72c503 Update the stabilisation version. 2021-01-09 12:31:30 +01:00
bors
46c35c76fe Auto merge of #80797 - pietroalbini:fix-relative-install, r=Mark-Simulacrum
Fix x.py install not working with relative prefix

The code powering `./x.py install` did not handle relative paths well: the installation script is executed inside a temporary directory, so all the relative paths specified in `config.toml` and in the `DESTDIR` environment variable were relative to that temporary directory. The original code fixed the problem for `config.toml` paths by canonicalizing the prefix, but breaking `DESTDIR`. https://github.com/rust-lang/rust/pull/80240 fixed the `DESTDIR` problem, but also regressed `config.toml` paths (#80683).

This PR refactors the installation code to generate paths that *in my understanding* are correct, adding comments in the meantime to explain what each step does. There was no documentation on why choices were made before, so my understanding could actually be wrong.

Regardless, executed `./x.py install` with various combinations of `config.toml` and `DESTDIR` paths, and everything seems to work according to my understanding. Still, I'd love if `@vext01` and `@yshui` could test these changes.

r? `@Mark-Simulacrum`
`@rustbot` modify labels: beta-nominated T-infra
2021-01-09 11:06:46 +00:00
bors
1f9dc9a182 Auto merge of #80755 - sunfishcode:path-cleanup/copy, r=nagisa
Optimize away some path lookups in the generic `fs::copy` implementation

This also eliminates a use of a `Path` convenience function, in support
of #80741, refactoring `std::path` to focus on pure data structures and
algorithms.
2021-01-09 07:48:53 +00:00
12101111
5de06800c7 Don't build in-tree llvm-libunwind if system-llvm-libunwind is enable 2021-01-09 12:50:08 +08:00
bors
c87ef0a2fc Auto merge of #80749 - as-com:target-cpu-actually-native, r=nagisa
Make target-cpu=native detect individual features

This PR makes target-cpu=native check for and enable/disable individual features instead of detecting and targeting a CPU by name. This brings the flag's behavior more in line with clang and gcc and ensures that the host actually supports each feature that we are compiling for.

This should resolve issues with miscompilations on e.g. "Haswell" Pentiums and Celerons that lack support for AVX, and also enable support for `aes` on Broadwell processors that support it. It should also resolve issues with failing to detect feature support in newer CPUs that aren't yet known by LLVM (see: #80633).

Fixes #54688
Fixes #48464
Fixes #38218
2021-01-09 04:36:24 +00:00
Joshua Nelson
0215b3a456 Don't mark force_query_with_job as inline(always)
It's rather large, and using `inline(always)` forces it to be recompiled
in each calling crate.
2021-01-08 18:38:33 -05:00
Aaron Hill
7b36408b5f
Use an empty TokenCursorFrame stack when capturing tokens
We will never need to pop  past our starting frame during token
capturing. Using an empty stack allows us to avoid pointless heap
allocations/deallocations.
2021-01-08 18:16:20 -05:00
Joshua Nelson
f7d261c3b1 Get rid of DepConstructor
This removes fully 235 unused functions.
2021-01-08 18:12:42 -05:00
Guillaume Gomez
3338bdb23d Add doc comment explaining what the second Array's field is about 2021-01-08 22:43:53 +01:00
Aaron Hill
20979aad77
Change wording of note 2021-01-08 14:57:35 -05:00
Aaron Hill
de90afc72e
Explain method-call move errors in loops
PR #73708 added a more detailed explanation of move errors that occur
due to a call to a method that takes `self`. This PR extends that logic
to work when a move error occurs due to a method call in the previous
iteration of a loop.
2021-01-08 14:37:07 -05:00
Noah
92d3537abb
Add wasi-exec-model cg option for emitting wasi reactors 2021-01-08 13:09:40 -06:00
Stein Somers
26b94626a1 BTreeMap: tougher checks on most uses of copy_nonoverlapping 2021-01-08 19:58:05 +01:00
bors
26438b4738 Auto merge of #78452 - cjgillot:ddk-struct, r=Mark-Simulacrum
Access query (DepKind) metadata through fields

This refactors the access to query definition metadata (attributes such as eval always, anon, has_params) and loading/forcing functions to generate a number of structs, instead of matching on the DepKind enum. This makes access to the fields cheaper to compile. Using a struct means that finding the metadata for a given query is just an offset away; previously the match may have been compiled to a jump table but likely not completely inlined as we expect here.

A previous attempt explored a similar strategy, but using trait objects in #78314 that proved less effective, likely due to higher overheads due to forcing dynamic calls and poorer cache utilization (all metadata is fairly densely packed with this PR).
2021-01-08 18:16:00 +00:00
Camille GILLOT
0f334c3642 Check is_anon outside of can_reconstruct_query_key. 2021-01-08 18:03:27 +01:00
Camille GILLOT
5fcc537d18 Make DepConstructor a module. 2021-01-08 18:02:04 +01:00
Camille GILLOT
921b284167 Make force_from_dep_node a function pointer. 2021-01-08 18:01:50 +01:00
Camille GILLOT
bee1fbb67e Make try_load_from_on_disk_cache a function pointer. 2021-01-08 17:59:27 +01:00
Camille GILLOT
438c430c76 Make can_reconstruct_query_key a function pointer. 2021-01-08 17:57:25 +01:00
Camille GILLOT
5027f1c6ea Use a field for has_params. 2021-01-08 17:55:46 +01:00
Camille GILLOT
d8c87ac080 Use a field for is_eval_always. 2021-01-08 17:53:38 +01:00
Camille GILLOT
24f0b957e7 Use a field for is_anon. 2021-01-08 17:51:53 +01:00
Andrew Sun
80ca198212 Check if the pointer is null/string is not utf8 2021-01-08 11:50:21 -05:00
Camille GILLOT
016ea6b319 Use a side-table of consts instead of matching on the DepKind enum. 2021-01-08 17:48:02 +01:00
Camille GILLOT
d1220fdedf Simplify DepNodeParams. 2021-01-08 17:29:49 +01:00
Camille GILLOT
79a57625f5 Move DepNodeExt outside of the macro. 2021-01-08 17:29:48 +01:00
bors
ddf2cc7f8e Auto merge of #76896 - spastorino:codegen-inline-fns2, r=davidtwco,wesleywiser
Do not make local copies of inline fns in debug mode

r? `@wesleywiser`

cc `@rust-lang/wg-incr-comp`

If this is correct it supersedes https://github.com/rust-lang/rust/pull/76889

Related to #54089
2021-01-08 15:21:45 +00:00
bors
937f629535 Auto merge of #80653 - jryans:doc-deref-recursive, r=jyn514,GuillaumeGomez
Recursively document methods via `Deref` traits

This changes `rustdoc` to recursively follow `Deref` targets so that methods from all levels are added to the rendered output. This implementation displays the methods from all levels in the expanded state with separate sections for each level.

![image](https://user-images.githubusercontent.com/279572/103482863-46723b00-4ddb-11eb-972b-c463351a425c.png)

Fixes https://github.com/rust-lang/rust/issues/26207
Fixes https://github.com/rust-lang/rust/issues/53038
Fixes https://github.com/rust-lang/rust/issues/71640

r? `@jyn514`
2021-01-08 12:34:20 +00:00
bors
3d8608a863 Auto merge of #80535 - JohnTitor:improve-use-diag, r=estebank
Add a note for `*` and `{}` usage on `use`

Closes #80333
2021-01-08 09:51:26 +00:00
Yuki Okushi
d063745023 Add a note for * and {} usage on use 2021-01-08 17:36:14 +09:00
J. Ryan Stinnett
ea946071dd Combine several push_str calls 2021-01-08 07:15:03 +00:00