Commit graph

137086 commits

Author SHA1 Message Date
Jonas Schievink
3ed8a3769a
Rollup merge of #79884 - Digital-Chaos:replace-magic, r=m-ou-se
Replace magic numbers with existing constants

Replaced magic numbers in `library/core/src/time.rs` with predefined constants.
2021-01-24 22:09:51 +01:00
Jonas Schievink
13b88c21d0
Rollup merge of #79174 - taiki-e:std-future, r=Mark-Simulacrum
Make std::future a re-export of core::future

After 1a764a7ef5, there are no `std::future`-specific items (except for `cfg(bootstrap)` items removed in 93eed402ad). So, instead of defining `std` own module, we can re-export the `core::future` directly.
2021-01-24 22:09:49 +01:00
Jonas Schievink
d9c177f777
Rollup merge of #78578 - oli-obk:const_mut_refs, r=RalfJung
Permit mutable references in all const contexts

fixes #71212

cc `@rust-lang/wg-const-eval` `@christianpoveda`
2021-01-24 22:09:48 +01:00
Jonas Schievink
5a1f2ecdd7
Rollup merge of #75180 - KodrAus:feat/error-by-ref, r=m-ou-se
Implement Error for &(impl Error)

Opening this up just to see what it breaks. It's unfortunate that `&(impl Error)` doesn't actually implement `Error`. If this direct approach doesn't work out then I'll try something different, like an `Error::by_ref` method.

**EDIT:** This is a super low-priority experiment so feel free to cancel it for more important crater runs! 🙂

-----

# Stabilization Report

## Why?

We've been working for the last few years to try "fix" the `Error` trait, which is probably one of the most fundamental in the whole standard library. One of its issues is that we commonly expect you to work with abstract errors through `dyn Trait`, but references and smart pointers over `dyn Trait` don't actually implement the `Error` trait. If you have a `&dyn Error` or a `Box<dyn Error>` you simply can't pass it to a method that wants a `impl Error`.

## What does this do?

This stabilizes the following trait impl:

```rust
impl<'a, T: Error + ?Sized + 'static> Error for &'a T;
```

This means that `&dyn Error` will now satisfy a `impl Error` bound.

It doesn't do anything with `Box<dyn Error>` directly. We discussed how we could do `Box<dyn Error>` in the thread here (and elsewhere in the past), but it seems like we need something like lattice-based specialization or a sprinkling of snowflake compiler magic to make that work. Having said that, with this new impl you _can_ now get a `impl Error` from a `Box<dyn Error>`  by dereferencing it.

## What breaks?

A crater run revealed a few crates broke with something like the following:

```rust
// where e: &'short &'long dyn Error
err.source()
```

previously we'd auto-deref that `&'short &'long dyn Error` to return a `Option<&'long dyn Error>` from `source`, but now will call directly on `&'short impl Error`, so will return a `Option<&'short dyn Error>`. The fix is to manually deref:

```rust
// where e: &'short &'long dyn Error
(*err).source()
```

In the recent Libs meeting we considered this acceptable breakage.
2021-01-24 22:09:45 +01:00
bors
1d0d76f8dd Auto merge of #81337 - petrochenkov:kvcollect, r=Aaron1011
parser: Collect tokens for values in key-value attributes

Fixes #81208 which happens when we parse the attribute value for the second time with an overridden span to synthesize tokens.

It also may be faster to collect tokens instead of re-synthesizing them.
2021-01-24 20:09:18 +00:00
Joakim Åkerblom
1d03648e67 Fix spelling in documentation for error E0207
I have trouble parsing the the wording "type parameter parameter".
2021-01-24 20:31:42 +01:00
Vadim Petrochenkov
bd07165690 parser: Collect tokens for values in key-value attributes 2021-01-24 17:11:56 +03:00
Mara Bos
a730970dff Only call span.rust_2021() when necessary. 2021-01-24 14:19:05 +01:00
bors
9a9477fada Auto merge of #81250 - sivadeilra:remove_xp_compat, r=joshtriplett,m-ou-se
Remove delay-binding for Win XP and Vista

The minimum supported Windows version is now Windows 7. Windows XP
and Windows Vista are no longer supported; both are already broken, and
require extra steps to use.

This commit removes the delayed-binding support for Windows API
functions that are present on all supported Windows targets. This has
several benefits: Removes needless complexity. Removes a load and
dynamic call on hot paths in mutex acquire / release. This may have
performance benefits.

* "Drop official support for Windows XP"
  https://github.com/rust-lang/compiler-team/issues/378

* "Firefox has ended support for Windows XP and Vista"
  https://support.mozilla.org/en-US/kb/end-support-windows-xp-and-vista
2021-01-24 12:34:08 +00:00
Dániel Buga
f8416faaaf Clean up dominators_given_rpo 2021-01-24 13:32:18 +01:00
bors
72c7b70267 Auto merge of #80838 - nagisa:nagisa/stack-probe-type, r=cuviper
Target stack-probe support configurable finely

This adds capability to configure the target's stack probe support in a
more precise manner than just on/off. In particular now we allow
choosing between always inline-asm, always call or either one of those
depending on the LLVM version.

Note that this removes the ability to turn off the generation of the
stack-probe attribute. This is valid to replace it with inline-asm for all targets because
`probe-stack="inline-asm"` will not generate any machine code on targets
that do not currently support stack probes. This makes support for stack
probes on targets that don't have any right now automatic with LLVM
upgrades in the future.

(This is valid to do based on the fact that clang unconditionally sets
this attribute when `-fstack-clash-protection` is used, AFAICT)

cc #77885
r? `@cuviper`
2021-01-24 09:44:42 +00:00
Lukas Kalbertodt
8a18fb0f73
Stabilize Seek::stream_position & change feature of Seek::stream_len 2021-01-24 10:14:24 +01:00
bors
85e355ea9b Auto merge of #80919 - cjgillot:defkey-span, r=oli-obk
Generate metadata by iterating on DefId instead of traversing the HIR tree 1/N

Sample from #80347.
2021-01-24 06:51:17 +00:00
Rune Tynan
c37c421354
fmt 2021-01-23 23:17:31 -05:00
Rune Tynan
351b2acd14
Make bad shlex parsing a pretty error 2021-01-23 23:03:01 -05:00
bors
446cbc9db0 Auto merge of #80594 - bjorn3:abi_refactor3, r=petrochenkov
Various ABI refactorings

This includes changes to the rust abi and various refactorings that will hopefully make it easier to use the abi handling infrastructure of rustc in cg_clif. There are several refactorings that I haven't done. I am opening this draft PR to check that I haven't broken any non x86_64 architectures.

r? `@ghost`
2021-01-24 02:59:14 +00:00
est31
14aa12fcc2 Replace version_check dependency with own version parsing code
This gives compiler maintainers a better degree of control
over how the version gets parsed and is a good way to ensure
that there are no changes of behaviour in the future.

Also, issue a warning if the version is invalid instead of erroring
so that we stay forwards compatible with possible future changes
of the versioning scheme.

Last, this improves the present test a little.
2021-01-24 01:56:54 +01:00
bors
26c2d1f408 Auto merge of #79811 - Aaron1011:expn-data-disambig, r=petrochenkov
Add disambiugator to ExpnData

I still need to write a bunch of comments. Opening to see how bad the perf impact is.

cc https://github.com/rust-lang/rust/issues/79560
2021-01-24 00:10:20 +00:00
bors
1279b3b923 Auto merge of #81304 - jonas-schievink:rollup-d9kuugm, r=jonas-schievink
Rollup of 15 pull requests

Successful merges:

 - #79841 (More clear documentation for NonNull<T>)
 - #81072 (PlaceRef::ty: use method call syntax)
 - #81130 (Edit rustc_middle::dep_graph module documentation)
 - #81170 (Avoid hash_slice in VecDeque's Hash implementation)
 - #81243 (mir: Improve size_of handling when arg is unsized)
 - #81245 (Update cargo)
 - #81249 (Lower closure prototype after its body.)
 - #81252 (Add more self-profile info to rustc_resolve)
 - #81275 (Fix <unknown> queries and add more timing info to render_html)
 - #81281 (Inline methods of Path and OsString)
 - #81283 (Note library tracking issue template in tracking issue template.)
 - #81285 (Remove special casing of rustdoc in rustc_lint)
 - #81288 (rustdoc: Fix visibility of trait and impl items)
 - #81298 (replace RefCell with Cell in FnCtxt)
 - #81301 (Fix small typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-23 21:13:14 +00:00
LeSeulArtichaut
20a460e1cf Fix rendering of stabilization version for trait implementors 2021-01-23 22:02:06 +01:00
Aaron Hill
3540f9396a
Add disambiugator to ExpnData
Due to macro expansion, its possible to end up with two distinct
`ExpnId`s that have the same `ExpnData` contents. This violates the
contract of `HashStable`, since two unequal `ExpnId`s will end up with
equal `Fingerprint`s.

This commit adds a `disambiguator` field to `ExpnData`, which is used to
force two otherwise-equivalent `ExpnData`s to be distinct.
2021-01-23 15:41:17 -05:00
Jonas Schievink
ebeb6b8b26
Rollup merge of #81301 - davidgu:patch-1, r=jonas-schievink
Fix small typo

Fractional part of `12.34e56` seems to be incorrectly stated as '45' and not '34'
2021-01-23 20:16:19 +01:00
Jonas Schievink
be3723c488
Rollup merge of #81298 - lcnr:big-money-big-prices, r=oli-obk
replace RefCell with Cell in FnCtxt

small cleanup
2021-01-23 20:16:17 +01:00
Jonas Schievink
64cf8c2e78
Rollup merge of #81288 - camelid:fix-trait-item-vis, r=jyn514
rustdoc: Fix visibility of trait and impl items

Fixes #81274.

r? `@jyn514`
2021-01-23 20:16:16 +01:00
Jonas Schievink
81b0c3e7c2
Rollup merge of #81283 - m-ou-se:tracking-issue-note, r=Mark-Simulacrum
Note library tracking issue template in tracking issue template.
2021-01-23 20:16:14 +01:00
Jonas Schievink
44c668cfca
Rollup merge of #81281 - a1phyr:inline_path, r=dtolnay
Inline methods of Path and OsString

These methods are not generic, and therefore aren't candidates for cross-crate inlining without an `#[inline]` attribute.
2021-01-23 20:16:12 +01:00
Jonas Schievink
81647c627a
Rollup merge of #81275 - jyn514:time-render, r=wesleywiser
Fix <unknown> queries and add more timing info to render_html

Closes https://github.com/rust-lang/rust/issues/81251.

##  Fix `<unknown>` queries

This happened because `alloc_query_strings` was never called.

##  Add more timing info to render_html

This still has some issues I'm not sure how to work out:

- `create_renderer` and `renderer_after_krate` aren't shown by default.
  I want something like `verbose_generic_activity_with_arg`, but it doesn't exist.

I'm also not sure how to show activities that aren't on by default - I
tried `-Z self-profile -Z self-profile-args=all`, but it didn't show up.

r? `@wesleywiser`
2021-01-23 20:16:10 +01:00
Jonas Schievink
7038bb1eb2
Rollup merge of #81252 - jyn514:resolve-timing, r=petrochenkov
Add more self-profile info to rustc_resolve

The idea is to help me find out where the time is being spent in compiling the docs for `windows-rs`: https://github.com/microsoft/windows-rs/issues/420#issuecomment-764991646
2021-01-23 20:16:09 +01:00
Jonas Schievink
fcf11296f6
Rollup merge of #81249 - cjgillot:issue-79537, r=oli-obk
Lower closure prototype after its body.

Fixes #79537.

r? `@Mark-Simulacrum`
2021-01-23 20:16:07 +01:00
Jonas Schievink
c4830daf1f
Rollup merge of #81245 - ehuss:update-cargo, r=ehuss
Update cargo

5 commits in a73e5b7d567c3036b296fc6b33ed52c5edcd882e..783bc43c660bf39c1e562c8c429b32078ad3099b
2021-01-12 23:45:39 +0000 to 2021-01-20 19:02:26 +0000
- Fix some issues with `cargo doc` and the new feature resolver. (rust-lang/cargo#9077)
- Implement support for rust-version field in project metadata (rust-lang/cargo#8037)
- Fix a bug in Cargo's cyclic dep graph detection (rust-lang/cargo#9075)
- Typo correction: artifcats -&gt; artifacts (rust-lang/cargo#9081)
- Remove stray backtick from doc (rust-lang/cargo#9079)
2021-01-23 20:16:05 +01:00
Jonas Schievink
3a3470bf04
Rollup merge of #81243 - osa1:fix_80742_2, r=RalfJung
mir: Improve size_of handling when arg is unsized

As discussed on Zulip with `@RalfJung.`
2021-01-23 20:16:04 +01:00
Jonas Schievink
05a95a4372
Rollup merge of #81170 - xfix:vecdeque-bug-fix, r=sfackler
Avoid hash_slice in VecDeque's Hash implementation

Fixes #80303.
2021-01-23 20:16:02 +01:00
Jonas Schievink
57d655368b
Rollup merge of #81130 - pierwill:edit-depnode, r=jyn514
Edit rustc_middle::dep_graph module documentation

This is similar to work approved and then closed in https://github.com/rust-lang/rust/pull/80325 due to a bad rebase.
2021-01-23 20:16:00 +01:00
Jonas Schievink
3382771dfd
Rollup merge of #81072 - RalfJung:place-ref-ty, r=oli-obk
PlaceRef::ty: use method call syntax
2021-01-23 20:15:59 +01:00
Jonas Schievink
7635462fe8
Rollup merge of #79841 - fintelia:patch-6, r=kennytm
More clear documentation for NonNull<T>

Rephrase and hopefully clarify the discussion of covariance in `NonNull<T>` documentation.

I'm very much not an expert so someone should definitely double check the correctness of what I'm saying. At the same time, the new language makes more sense to me, so hopefully it also is more logical to others whose knowledge of covariance basically begins and ends with the [Rustonomicon chapter](https://doc.rust-lang.org/nomicon/subtyping.html).

Related to #48929.
2021-01-23 20:15:54 +01:00
Arpad Borsos
9b1d27d440 Add option to control doctest run directory
This option will allow splitting the compile-time from the run-time
directory of doctest invocations and is one step to solve
https://github.com/rust-lang/cargo/issues/8993#issuecomment-760088944
2021-01-23 18:52:51 +01:00
David
2f5ce8e802
Fix small typo 2021-01-23 12:31:40 -05:00
LeSeulArtichaut
1129e86780 Cleanup render_stability_since_raw to remove code duplication 2021-01-23 18:05:59 +01:00
bjorn3
fa12fdbc29 Fix review comments 2021-01-23 17:55:39 +01:00
oli
03c6364160 Move test to mir-opt so we actually see that no inlining is happening 2021-01-23 16:51:23 +00:00
oli
209889ddc1 Leave some notes for future changes to the MIR opt level of mir inlining 2021-01-23 16:51:23 +00:00
oli
f238148214 Allow libcore to be built with MIR inlining
Inlining caused new lints to get emitted, so we silence those lints now that we actually can.
2021-01-23 16:51:23 +00:00
oli
0491e74dd9 Make sure that const prop does not produce unsilenceable lints after inlining 2021-01-23 16:51:23 +00:00
oli
b8727e2d60 Prevent query cycles during inlining 2021-01-23 16:51:22 +00:00
Joshua Nelson
3b8f1b7883 Make -Z time-passes less noisy
- Add the module name to `pre_AST_expansion_passes` and don't make it a
  verbose event (since it normally doesn't take very long, and it's
  emitted many times)
- Don't make the following rustdoc events verbose; they're emitted many times.
  + build_extern_trait_impl
  + build_local_trait_impl
  + build_primitive_trait_impl
  + get_auto_trait_impls
  + get_blanket_trait_impls
- Remove `get_auto_trait_and_blanket_synthetic_impls`; it's wholly
  covered by get_{auto,blanket}_trait_impls and not very useful.
2021-01-23 11:44:46 -05:00
Joshua Nelson
ca72f9ed70 Calculate self-profile strings in Compiler::enter instead in codegen
This avoids each tool having to separately find and call
`self_profile_alloc_strings`.

- Don't compute the global context if it hasn't yet been computed

  This avoids giving extraneous errors about unresolved names if an error
  occurs during parsing.
2021-01-23 11:42:15 -05:00
Joshua Nelson
1d1010f1af Add more timing info to render_html
- Show `create_renderer` and `renderer_after_crate` by default
- Don't rewrite `extra_verbose_generic_activity`
2021-01-23 11:42:11 -05:00
bors
4d0dd02ee0 Auto merge of #80579 - RalfJung:no-fallible-promotion, r=oli-obk
avoid promoting division, modulo and indexing operations that could fail

For division, `x / y` will still be promoted if `y` is a non-zero integer literal; however, `1/(1+1)` will not be promoted any more.

While at it, also see if we can reject promoting floating-point arithmetic (which are [complicated](https://github.com/rust-lang/unsafe-code-guidelines/issues/237) so maybe we should not promote them).

This will need a crater run to see if there's code out there that relies on these things being promoted.

If we can land this, promoteds in `fn`/`const fn` cannot fail to evaluate any more, which should let us do some simplifications in codegen/Miri!

Cc https://github.com/rust-lang/rfcs/pull/3027
Fixes https://github.com/rust-lang/rust/issues/61821
r? `@oli-obk`
2021-01-23 13:19:04 +00:00
Camille GILLOT
97ee7c7e5a Allow to query the HIR crate node. 2021-01-23 13:58:09 +01:00
Camille GILLOT
89360931f2 Fix proc macro crate encoding. 2021-01-23 13:57:43 +01:00