]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #80434 - pietroalbini:tarball-temp-dir, r=Mark-Simulacrum
Dylan DPC [Mon, 28 Dec 2020 13:13:23 +0000 (14:13 +0100)]
Rollup merge of #80434 - pietroalbini:tarball-temp-dir, r=Mark-Simulacrum

bootstrap: put the component name in the tarball temp dir path

This should not matter right now, but if we ever parallelize rustbuild this will avoid tarball contents being merged together.

r? `@Mark-Simulacrum`

3 years agoRollup merge of #80411 - petrochenkov:nosymwith, r=matthewjasper
Dylan DPC [Mon, 28 Dec 2020 13:13:21 +0000 (14:13 +0100)]
Rollup merge of #80411 - petrochenkov:nosymwith, r=matthewjasper

rustc_span: Remove `Symbol::with`

A subset of https://github.com/rust-lang/rust/pull/79425 that is a pure refactoring.

3 years agoRollup merge of #80408 - bjorn3:sync_cg_clif-2020-12-27, r=bjorn3
Dylan DPC [Mon, 28 Dec 2020 13:13:19 +0000 (14:13 +0100)]
Rollup merge of #80408 - bjorn3:sync_cg_clif-2020-12-27, r=bjorn3

Sync rustc_codegen_cranelift

The highlight of this sync are two JIT mode improvements. The first is that it is now possible to use JIT mode when using `-Zcodegen-backend` instead of the custom driver using `-Cllvm-args=mode=jit`. The second one is a new JIT mode that lazily compiles functions when they are called the first time: https://github.com/bjorn3/rustc_codegen_cranelift/pull/1120

In addition this includes a few small runtime performance improvements and various fixes for rustc changes that didn't cause compilation to fail.

r? ``@ghost``

``@rustbot`` label +A-codegen +A-cranelift +T-compiler

3 years agoRollup merge of #80399 - jyn514:hir-id-cleanup, r=marmeladema
Dylan DPC [Mon, 28 Dec 2020 13:13:17 +0000 (14:13 +0100)]
Rollup merge of #80399 - jyn514:hir-id-cleanup, r=marmeladema

Remove FIXME in rustc_privacy

#71104 has been fixed.

r? ``@marmeladema`` if you have time, otherwise ``@petrochenkov``

3 years agoRollup merge of #80362 - jyn514:rustc-macros, r=ehuss
Dylan DPC [Mon, 28 Dec 2020 13:13:16 +0000 (14:13 +0100)]
Rollup merge of #80362 - jyn514:rustc-macros, r=ehuss

Document rustc_macros on nightly-rustc

Fixes https://github.com/rust-lang/rust/issues/80345.

![image](https://user-images.githubusercontent.com/23638587/103113442-b7ba2d00-4628-11eb-8a4d-c542f2d170e1.png)
![image](https://user-images.githubusercontent.com/23638587/103113448-bc7ee100-4628-11eb-8657-2d72e88de656.png)

r? ``@ehuss``

3 years agoRollup merge of #80353 - ssomers:btree_test_split_off, r=Mark-Simulacrum
Dylan DPC [Mon, 28 Dec 2020 13:13:14 +0000 (14:13 +0100)]
Rollup merge of #80353 - ssomers:btree_test_split_off, r=Mark-Simulacrum

BTreeMap: test split_off (and append) more thoroughly

Using DeterministicRng as a poor man's property based testing rig.
r? ``@Mark-Simulacrum``

3 years agoRollup merge of #80344 - matthiaskrgr:matches, r=Dylan-DPC
Dylan DPC [Mon, 28 Dec 2020 13:13:12 +0000 (14:13 +0100)]
Rollup merge of #80344 - matthiaskrgr:matches, r=Dylan-DPC

use matches!() macro in more places

3 years agoRollup merge of #80331 - jyn514:docs, r=varkor
Dylan DPC [Mon, 28 Dec 2020 13:13:10 +0000 (14:13 +0100)]
Rollup merge of #80331 - jyn514:docs, r=varkor

Add more comments to trait queries

This also adds back a comment that was mistakenly removed in
ac9dfc3e7785c9bba96ebac4fd51726189e1bf91.

3 years agoRollup merge of #80284 - ThePuzzlemaker:issue-80179-fix, r=varkor
Dylan DPC [Mon, 28 Dec 2020 13:13:08 +0000 (14:13 +0100)]
Rollup merge of #80284 - ThePuzzlemaker:issue-80179-fix, r=varkor

Suggest fn ptr rather than fn item and suggest to use `Fn` trait bounds rather than the unique closure type in E0121

Previously, using `_` as a return type in a function that returned a function/closure would provide a diagnostic that would cause a papercut. For example:
```rust
fn f() -> i32 { 0 }
fn fn_ptr() -> _ { f }
fn closure() -> _ { || 0 }
```
would result in this diagnostic:
```rust
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
 --> <anon>:2:16
  |
2 | fn fn_ptr() -> _ { f }
  |                ^
  |                |
  |                not allowed in type signatures
  |                help: replace with the correct return type: `fn() -> i32 {f}`

error[E0121]: the type placeholder `_` is not allowed within types on item signatures
 --> <anon>:3:17
  |
3 | fn closure() -> _ { || 0 }
  |                 ^
  |                 |
  |                 not allowed in type signatures
  |                 help: replace with the correct return type: `[closure@<anon>:3:21: 3:25]`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0121`.
```
As can be seen, it was suggested to use the function definition return type `fn() -> i32 { f }` which is not valid syntax as a return type. Additionally, closures cause a papercut as unique closure types (notated in this case as `[closure@<anon>:3:21: 3:25]`) are not valid syntax either.

Instead, this PR implements this version of the diagnostic (this example is for the same code featured above):
```rust
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
 --> <anon>:2:16
  |
2 | fn fn_ptr() -> _ { f }
  |                ^
  |                |
  |                not allowed in type signatures
  |                help: replace with the correct return type: `fn() -> i32`

error[E0121]: the type placeholder `_` is not allowed within types on item signatures
 --> <anon>:3:17
  |
3 | fn closure() -> _ { || 0 }
  |                 ^ not allowed in type signatures
  |
  = help: consider using an `Fn`, `FnMut`, or `FnOnce` trait bound
  = note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0121`.
```
As can be seen in this diagnostic, the papercut for returning a function item is fixed by suggesting the usage of a function pointer as the return type. As for closures, it's suggested to use an `Fn`, `FnMut`, or `FnOnce` trait bound (with further reading on closures and `Fn` traits in *The Book* for beginners). I did not implement a suggestion to use `impl Fn() -> i32` syntax as that was out-of-scope for my abilities at the moment, therefore someone in the future may want to implement that. Also, it's possible to use either `impl Trait` syntax, generics, or generics with a `where` clause, and some users may not want to use `impl Trait` syntax for their own reasons.

This PR fixes #80179.

3 years agoRollup merge of #79815 - XAMPPRocky:relnotes-1.49.0, r=Mark-Simulacrum
Dylan DPC [Mon, 28 Dec 2020 13:13:06 +0000 (14:13 +0100)]
Rollup merge of #79815 - XAMPPRocky:relnotes-1.49.0, r=Mark-Simulacrum

Update RELEASES.md for 1.49.0

### [Rendered](https://github.com/XAMPPRocky/rust/tree/relnotes-1.49.0/RELEASES.md)

r? ``@Mark-Simulacrum``
cc ``@rust-lang/release``

3 years agoRollup merge of #79662 - bjorn3:move_more_code_out_of_codegen_backend, r=oli-obk
Dylan DPC [Mon, 28 Dec 2020 13:12:59 +0000 (14:12 +0100)]
Rollup merge of #79662 - bjorn3:move_more_code_out_of_codegen_backend, r=oli-obk

Move some more code out of CodegenBackend::{codegen_crate,link}

Kind of a follow up to #77795

3 years agobootstrap: put the component name in the tarball temp dir path
Pietro Albini [Mon, 28 Dec 2020 11:51:58 +0000 (12:51 +0100)]
bootstrap: put the component name in the tarball temp dir path

This should not matter right now, but if we ever parallelize rustbuild
this will avoid tarball contents being merged together.

3 years agoAuto merge of #80397 - Mark-Simulacrum:fix-bare-tarball, r=pietroalbini
bors [Mon, 28 Dec 2020 08:29:02 +0000 (08:29 +0000)]
Auto merge of #80397 - Mark-Simulacrum:fix-bare-tarball, r=pietroalbini

Use package name for top-level directory in bare tarballs

This fixes a bug introduced by #79788.

r? `@pietroalbini`

3 years agoAuto merge of #80422 - RalfJung:weak-no-unsized-raw, r=Mark-Simulacrum
bors [Mon, 28 Dec 2020 00:00:43 +0000 (00:00 +0000)]
Auto merge of #80422 - RalfJung:weak-no-unsized-raw, r=Mark-Simulacrum

de-stabilize unsized raw ptr methods for Weak

`@Mark-Simulacrum` this is the patch re: https://github.com/rust-lang/rust/pull/80407.

I couldn't figure out the branch it needs to go on though, stable is still the old stable but beta already the new beta...?

3 years agode-stabilize unsized raw ptr methods for Weak
Ralf Jung [Sun, 27 Dec 2020 23:39:09 +0000 (00:39 +0100)]
de-stabilize unsized raw ptr methods for Weak

3 years agoAuto merge of #80181 - jyn514:intra-doc-primitives, r=Manishearth
bors [Sun, 27 Dec 2020 18:55:33 +0000 (18:55 +0000)]
Auto merge of #80181 - jyn514:intra-doc-primitives, r=Manishearth

Fix intra-doc links for non-path primitives

This does *not* currently work for associated items that are
auto-implemented by the compiler (e.g. `never::eq`), because they aren't
present in the source code. I plan to fix this in a follow-up PR.

Fixes https://github.com/rust-lang/rust/issues/63351 using the approach mentioned in https://github.com/rust-lang/rust/issues/63351#issuecomment-683352130.

r? `@Manishearth`

cc `@petrochenkov` - this makes `rustc_resolve::Res` public, is that ok? I'd just add an identical type alias in rustdoc if not, which seems a waste.

3 years agoAuto merge of #80315 - tmiasko:ignore-proc-macros, r=Mark-Simulacrum
bors [Sun, 27 Dec 2020 16:03:01 +0000 (16:03 +0000)]
Auto merge of #80315 - tmiasko:ignore-proc-macros, r=Mark-Simulacrum

Ignore proc-macros when assembling rustc libdir

Fixes #80294.

3 years agorustc_span: Remove `Symbol::with`
Vadim Petrochenkov [Sun, 27 Dec 2020 15:10:58 +0000 (18:10 +0300)]
rustc_span: Remove `Symbol::with`

3 years agoAuto merge of #79134 - ohadravid:nzint-div, r=dtolnay
bors [Sun, 27 Dec 2020 13:11:06 +0000 (13:11 +0000)]
Auto merge of #79134 - ohadravid:nzint-div, r=dtolnay

Add `impl Div<NonZeroU{0}> for u{0}` which cannot panic

Dividing an unsigned int by a `NonZeroUxx` requires a user to write (for example, in [this SO question](https://stackoverflow.com/questions/64855738/how-to-inform-the-optimizer-that-nonzerou32get-will-never-return-zero)):

```
pub fn safe_div(x: u32, y: std::num::NonZeroU32) -> u32 {
    x / y.get()
}
```

which generates a panicking-checked-div [assembly](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(fontScale:14,j:1,lang:rust,selection:(endColumn:2,endLineNumber:6,positionColumn:2,positionLineNumber:6,selectionStartColumn:2,selectionStartLineNumber:6,startColumn:2,startLineNumber:6),source:%27pub+fn+div(x:+u32,+y:+u32)+-%3E+u32+%7B%0A++++x+/+y%0A%7D%0Apub+fn+safe_div(x:+u32,+y:+std::num::NonZeroU32)+-%3E+u32+%7B%0A++++x+/+y.get()+//+an+unchecked+division+expected%0A%7D%27),l:%275%27,n:%270%27,o:%27Rust+source+%231%27,t:%270%27)),k:50,l:%274%27,n:%270%27,o:%27%27,s:0,t:%270%27),(g:!((h:compiler,i:(compiler:r1470,filters:(b:%270%27,binary:%271%27,commentOnly:%270%27,demangle:%270%27,directives:%270%27,execute:%271%27,intel:%270%27,libraryCode:%271%27,trim:%271%27),fontScale:14,j:1,lang:rust,libs:!(),options:%27-O%27,selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:%275%27,n:%270%27,o:%27rustc+1.47.0+(Editor+%231,+Compiler+%231)+Rust%27,t:%270%27)),k:50,l:%274%27,n:%270%27,o:%27%27,s:0,t:%270%27)),l:%272%27,n:%270%27,o:%27%27,t:%270%27)),version:4).
Avoiding the `panic` currently requires `unsafe` code.

This PR adds an `impl Div<NonZeroU{0}> for u{0}` (and `impl Rem<NonZeroU{0}> for u{0}`) which calls the `unchecked_div` (and `unchecked_rem`) intrinsic without any additional checks,
making the following code compile:

```
pub fn safe_div(x: u32, y: std::num::NonZeroU32) -> u32 {
    x / y
}

pub fn safe_rem(x: u32, y: std::num::NonZeroU32) -> u32 {
    x % y
}
```

The doc is set to match the regular div impl [docs](https://doc.rust-lang.org/beta/src/core/ops/arith.rs.html#460).

I've marked these as stable because (as I understand it) trait impls are automatically stable. I'm happy to change it to unstable if needed.

Following `@dtolnay` template from a similar issue:
this adds the following **stable** impls, which rely on dividing unsigned integers by nonzero integers being well defined and previously would have involved unsafe code to encode that knowledge:
```
impl Div<NonZeroU8> for u8 {
    type Output = u8;
}

impl Rem<NonZeroU8> for u8 {
    type Output = u8;
}
```
and equivalent for u16, u32, u64, u128, usize, but **not** for i8, i16, i32, i64, i128, isize (since -1/MIN is undefined).

r? `@dtolnay`

3 years agoBump nonzero_div feature to Rust 1.51
David Tolnay [Sun, 27 Dec 2020 11:17:30 +0000 (03:17 -0800)]
Bump nonzero_div feature to Rust 1.51

3 years agoAuto merge of #79642 - ijackson:default-theme-stab, r=jyn514
bors [Sun, 27 Dec 2020 09:55:51 +0000 (09:55 +0000)]
Auto merge of #79642 - ijackson:default-theme-stab, r=jyn514

rustdoc: stabilise --default-theme command line option

As discussed in #77213, this seems like it has bedded in and can be safely and usefully made stable.

(rustdoc already has other stable options that interact quite intimately with the rustdoc-supplied CSS, and also an option for supplying entirely different CSS, so exposing the theme names this way seems a very minor step.)

There is also a commit to do some minor grammar fixes to the help message.

3 years agoMerge commit 'dbee13661efa269cb4cd57bb4c6b99a19732b484' into sync_cg_clif-2020-12-27
bjorn3 [Sun, 27 Dec 2020 09:30:38 +0000 (10:30 +0100)]
Merge commit 'dbee13661efa269cb4cd57bb4c6b99a19732b484' into sync_cg_clif-2020-12-27

3 years agoAuto merge of #79135 - lcnr:the-paleogenesis-of-generic-germination, r=varkor
bors [Sun, 27 Dec 2020 07:05:56 +0000 (07:05 +0000)]
Auto merge of #79135 - lcnr:the-paleogenesis-of-generic-germination, r=varkor

stabilize `#![feature(min_const_generics)]` in 1.51

*A new Kind*
*A Sort long Prophesized*
*Once Fragile, now Eternal*

blocked on #79073.

# Stabilization report

This is the stabilization report for `#![feature(min_const_generics)]` (tracking issue #74878), a subset of `#![feature(const_generics)]` (tracking issue #44580), based on rust-lang/rfcs#2000.

The [version target](https://forge.rust-lang.org/#current-release-versions) is ~~1.50 (2020-12-31 => beta, 2021-02-11 => stable)~~ 1.51 (2021-02-111 => beta, 2021-03-25 => stable).

This report is a collaborative effort of `@varkor,` `@shepmaster` and `@lcnr.`

## Summary

It is currently possible to parameterize functions, type aliases, types, traits and implementations by types and lifetimes.
With `#![feature(min_const_generics)]`, it becomes possible, in addition, to parameterize these by constants.

This is done using the syntax `const IDENT: Type` in the parameter listing. Unlike full const generics, `min_const_generics` is limited to parameterization by integers, and constants of type `char` or `bool`.

We already use `#![feature(min_const_generics)]` on stable to implement many common traits for arrays. See [the documentation](https://doc.rust-lang.org/nightly/std/primitive.array.html) for specific examples.

Generic const arguments, for now, are not permitted to involve computations depending on generic parameters. This means that const parameters may only be instantiated using either:

1. const expressions that do not depend on any generic parameters, e.g. `{ foo() + 1 }`, where `foo` is a `const fn`
1. standalone const parameters, e.g. `{N}`

### Example

```rust
#![feature(min_const_generics)]

trait Foo<const N: usize> {
    fn method<const M: usize>(&mut self, arr: [[u8; M]; N]);
}

struct Bar<T, const N: usize> {
    inner: [T; N],
}

impl<const N: usize> Foo<N> for Bar<u8, N> {
    fn method<const M: usize>(&mut self, arr: [[u8; M]; N]) {
        for (elem, s) in self.inner.iter_mut().zip(arr.iter()) {
            for &x in s {
                *elem &= x;
            }
        }
    }
}

fn function<const N: u16>() -> u16 {
    // Const parameters can be used freely inside of functions.
    (N + 1) / 2 * N
}

fn main() {
    let mut bar = Bar { inner: [0xff; 3] };
    // This infers the value of `M` from the type of the function argument.
    bar.method([[0b11_00, 0b01_00], [0b00_11, 0b00_01], [0b11_00, 0b00_11]]);
    assert_eq!(bar.inner, [0b01_00, 0b00_01, 0b00_00]);

    // You can also explicitly specify the value of `N`.
    assert_eq!(function::<17>(), 153);
}
```

## Motivation

Rust has the built-in array type, which is parametric over a constant. Without const generics, this type can be quite cumbersome to use as it is not possible to generically implement a trait for arrays of different lengths. For example, this meant that, for a long time, the standard library only contained trait implementations for arrays up to a length of 32. This restriction has since been lifted through the use of const generics.

Const parameters allow users to naturally specify variants of a generic type which are more naturally parameterized by values, rather than by types. For example, using const generics, many of the uses of the crate [typenum](https://crates.io/crates/typenum) may now be replaced with const parameters, improving compilation time as well as code readability and diagnostics.

The subset described by `min_const_generics` is self-contained, but extensive enough to help with the most frequent issues: implementing traits for arrays and using arbitrarily-sized arrays inside of other types. Furthermore, it extends naturally to full `const_generics` once the remaining design and implementation questions have been resolved.

## In-depth feature description

### Declaring const parameters

*Const parameters* are allowed in all places where types and lifetimes are supported. They use the syntax `const IDENT: Type`. Currently, const parameters must be declared after lifetime and type parameters. Their scope is equal to the scope of other generic parameters. They live in the value namespace.

`Type` must be one of `u8`, `u16`, `u32`, `u64`, `u128`, `usize`, `i8`, `i16`, `i32`, `i64`, `i128`, `isize`, `char` and `bool`. This restriction is implemented in two places:

1. during name resolution, where we forbid generic parameters
1. during well-formedness checking, where we only allow the types listed above

The updated syntax of parameter listings is:

```
GenericParams:
    (OuterAttr* LifetimeParam),* (OuterAttr* TypeParam),* (OuterAttr* ConstParam),*

OuterAttr: '#[' ... ']'
LifetimeParam: ...
TypeParam: ...
ConstParam: 'const' IDENT ':' Type
```

Unlike type and lifetime parameters, const parameters of types can be used without being mentioned inside of a parameterized type because const parameters do not have issues concerning variance. This means that the following types are allowed:

```rust
struct Foo<const N: usize>;
enum Bar<const M: usize> { A, B }
```

### Const arguments

Const parameters are instantiated using *const arguments*. Any concrete const expression or const parameter as a standalone argument can be used. When applying an expression as const parameter, most expressions must be contained within a block, with two exceptions:

1. literals and single-segment path expressions
1. array lengths

This syntactic restriction is necessary to avoid ambiguity, or requiring infinite lookahead when parsing an expression as a generic argument.

In the cases where a generic argument could be resolved as either a type or const argument, we always interpret it as a type. This causes the following test to fail:

```rust
type N = u32;
struct Foo<const N: usize>;
fn foo<const N: usize>() -> Foo<N> { todo!() } // ERR
```

To circumvent this, the user may wrap the const parameter with braces, at which point it is unambiguously accepted.

```rust
type N = u32;
struct Foo<const N: usize>;
fn bar<const N: usize>() -> Foo<{ N }> { todo!() } // ok
```

Operations depending on generic parameters are **not** allowed, which is enforced during well-formedness checking. Allowing generic unevaluated constants would require a way to check if they would always evaluate successfully to prevent errors that are not caught at declaration time. This ability forms part of `#![feature(const_evaluatable_checked)]`, which is not yet being stabilised.

Since we are not yet stabilizing `#![feature(lazy_normalization_consts)]`, we must not supply the parent generics to anonymous constants except for repeat expressions. Doing so can cause cycle errors for arrays used in `where`-bounds. Not supplying the parent generics can however lead to ICEs occurring before well-formedness checking when trying to use a generic parameter. See #56445 for details.

Since we expect cases like this to occur more frequently once `min_const_generics` is stabilized, we have chosen to forbid generic parameters in anonymous constants during name resolution. While this changes the ICE in the situation above to an ordinary error, this is theoretically a breaking change, as early-bound lifetimes were previously permitted in repeat expressions but now are disallowed, causing the following snippet to break:

```rust
fn late_bound<'a>() {
    let _ = [0; {
        let _: &'a (); // ICE ==> ERR
        3
    }];
}

fn early_bound<'a>() where &'a (): Sized {
    let _ = [0; {
        let _: &'a (); // ok ==> ERR
        3
    }];
}
```

### Using const parameters

Const parameters can be used almost everywhere ordinary constants are allowed, except that they may not be used in the construction of consts, statics, functions, or types inside a function body and are subject to the generic argument restrictions mentioned above.

Expressions containing const parameters are eligible for promotion:

```rust
fn test<const N: usize>() -> &'static usize {
    &(3 + N)
}
```

### Symbol mangling

See the [Rust symbol name mangling RFC](https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html) for an overview. Generic const parameters take the form `K[type][value]` when the value is known, or `Kp` where the value is not known, where:
- `[type]` is any integral type, `bool`, or `char`.
- `[value]` is the unsigned hex value for integers, preceded by `n` when negative; is `0` or `1` for `bool`; is the hex value for `char`.

### Exhaustiveness checking

We do not check the exhaustiveness of impls, meaning that the following example does **not** compile:

```rust
struct Foo<const B: bool>;
trait Bar {}
impl Bar for Foo<true> {}
impl Bar for Foo<false> {}

fn needs_bar(_: impl Bar) {}
fn generic<const B: bool>() {
    let v = Foo::<B>;
    needs_bar(v);
}
```

### Type inference

The value of const parameters can be inferred during typeck. One interesting case is the length of generic arrays, which can also be inferred from patterns (implemented in #70562). Practical usage of this can be seen in #76825.

### Equality of constants

`#![feature(min_const_generics)]` only permits generic parameters to be used as standalone generic arguments. We compare two parameters to be equal if they are literally the same generic parameter.

### Associated constants

Associated constants can use const parameters without restriction, see https://github.com/rust-lang/rust/pull/79135#issuecomment-748299774 for more details.

## Future work

As this is a limited subset of rust-lang/rfcs#2000, there are quite a few extensions we will be looking into next.

### Lazy normalization of constants

Stabilizing `#![feature(lazy_normalization_consts)]` (tracking issue #72219) will remove some special cases that are currently necessary for `min_const_generics`, and unblocks operations on const parameters.

### Relaxing ordering requirements between const and type parameters

We currently restrict the order of generic parameters so that types must come before consts. We could relax this, as is currently done with `const_generics`. Without this it is not possible to use both type defaults and const parameters at the same time.

Unrestricting the order will require us to improve some diagnostics that expect there to be a strict order between type and const parameters.

### Allowing more parameter types

We would like to support const parameters of more types, especially`&str` and user-defined types. Both are blocked on [valtrees]. There are also open questions regarding the design of `structural_match` concerning the latter. Supporting generic const parameter types such as `struct Foo<T, const N: T>` will be a lot harder and is unlikely to be implemented in the near future.

### Default values of const parameters

We do not yet support default values for const parameters. There is work in progress to enable this on nightly (see https://github.com/rust-lang/rust/pull/75384).

### Generic const operations

With `#![feature(min_const_generics)]`, only concrete const expressions and parameters as standalone arguments are allowed in types and repeat expressions. However, supporting generic const operations, such as `N + 1` or `std::mem::size_of::<T>()` is highly desirable. This feature is in early development under `#![feature(const_evaluatable_checked)]`.

## Implementation history

Many people have contributed to the design and implementation of const generics over the last three years. See https://github.com/rust-lang/rust/issues/44580#issuecomment-728913127 for a summary. Once again thank you to everybody who helped out here!

[valtrees]: https://github.com/rust-lang/rust/issues/72396

---

r? `@varkor`

3 years agoAuto merge of #80400 - adlerd:hashclone, r=Mark-Simulacrum
bors [Sun, 27 Dec 2020 04:14:20 +0000 (04:14 +0000)]
Auto merge of #80400 - adlerd:hashclone, r=Mark-Simulacrum

Use `clone_from` from `hashbrown::{HashMap,HashSet}`.

This change updates the `std` hash collections to use `hashbrown`'s `clone_from`, which was itself added in #70052. Deriving `Clone` does not add a `clone_from` impl and uses the trait default, which calls `clone`.

Fixes #28481

3 years agoAuto merge of #80395 - ehuss:lint-docs-warn-missing, r=Mark-Simulacrum
bors [Sun, 27 Dec 2020 01:21:40 +0000 (01:21 +0000)]
Auto merge of #80395 - ehuss:lint-docs-warn-missing, r=Mark-Simulacrum

lint-docs: Warn on missing lint when documenting.

In #79522, I missed converting one of the errors to a warning, in the situation where a lint is missing.  This was unearthed by the renaming of overlapping-patterns (#78242).  This will still be validated during the test phase.

3 years agoUse the hashbrown::{HashMap,HashSet} `clone_from` impls.
David Adler [Sun, 27 Dec 2020 00:39:38 +0000 (19:39 -0500)]
Use the hashbrown::{HashMap,HashSet} `clone_from` impls.

3 years agoRemove FIXME in rustc_privacy
Joshua Nelson [Sun, 27 Dec 2020 00:34:10 +0000 (19:34 -0500)]
Remove FIXME in rustc_privacy

3 years agoAuto merge of #80396 - ehuss:fix-missing-deny, r=Mark-Simulacrum
bors [Sat, 26 Dec 2020 22:35:16 +0000 (22:35 +0000)]
Auto merge of #80396 - ehuss:fix-missing-deny, r=Mark-Simulacrum

Fix missing deny-by-default.md file.

I don't know why, but #80296 deleted this file.  Add it back so that the docs can be viewed directly with mdbook without it auto-generating the file.

3 years agoUse package name for top-level directory in bare tarballs
Mark Rousskov [Sat, 26 Dec 2020 22:15:20 +0000 (17:15 -0500)]
Use package name for top-level directory in bare tarballs

This fixes a bug introduced by #79788.

3 years agoFix missing deny-by-default.md file.
Eric Huss [Sat, 26 Dec 2020 21:53:10 +0000 (13:53 -0800)]
Fix missing deny-by-default.md file.

3 years agolint-docs: Warn on missing lint when documenting.
Eric Huss [Sat, 26 Dec 2020 21:48:09 +0000 (13:48 -0800)]
lint-docs: Warn on missing lint when documenting.

3 years agoAuto merge of #79045 - oli-obk:dont_rely_on_alloc_happening_for_soundness, r=TimDiekmann
bors [Sat, 26 Dec 2020 19:43:12 +0000 (19:43 +0000)]
Auto merge of #79045 - oli-obk:dont_rely_on_alloc_happening_for_soundness, r=TimDiekmann

Document that heap allocations are not guaranteed to happen, even if explicitly performed in the code

cc `@RalfJung`

3 years agoupdate tests
Bastian Kauschke [Tue, 17 Nov 2020 10:44:21 +0000 (11:44 +0100)]
update tests

3 years agoupdate error codes
Bastian Kauschke [Tue, 17 Nov 2020 10:42:53 +0000 (11:42 +0100)]
update error codes

3 years agodelete no longer relevant tests
Bastian Kauschke [Tue, 17 Nov 2020 10:42:16 +0000 (11:42 +0100)]
delete no longer relevant tests

3 years agostabilize min_const_generics
Bastian Kauschke [Tue, 17 Nov 2020 09:55:13 +0000 (10:55 +0100)]
stabilize min_const_generics

3 years agoDIrect invocations of `AllocRef::alloc` cannot get optimized away
oli [Sat, 26 Dec 2020 17:16:50 +0000 (17:16 +0000)]
DIrect invocations of `AllocRef::alloc` cannot get optimized away

3 years agoAdjust markdown text to be more like the rendered text
oli [Sat, 26 Dec 2020 17:14:49 +0000 (17:14 +0000)]
Adjust markdown text to be more like the rendered text

3 years agoUpdate library/core/src/alloc/mod.rs
Oli Scherer [Sat, 26 Dec 2020 17:06:04 +0000 (18:06 +0100)]
Update library/core/src/alloc/mod.rs

Co-authored-by: Ralf Jung <post@ralfj.de>
3 years agoUpdate library/core/src/alloc/global.rs
Oli Scherer [Sat, 26 Dec 2020 17:05:55 +0000 (18:05 +0100)]
Update library/core/src/alloc/global.rs

Co-authored-by: Ralf Jung <post@ralfj.de>
3 years agoAuto merge of #79520 - ssomers:btree_cleanup_1, r=Mark-Simulacrum
bors [Sat, 26 Dec 2020 16:47:33 +0000 (16:47 +0000)]
Auto merge of #79520 - ssomers:btree_cleanup_1, r=Mark-Simulacrum

BTreeMap: clean up access to MaybeUninit arrays

Stop exposing and using immutable access to `MaybeUninit` slices when we need and have exclusive access to the tree.

r? `@Mark-Simulacrum`

3 years agoAuto merge of #80354 - ssomers:btree_test_compact, r=Mark-Simulacrum
bors [Sat, 26 Dec 2020 13:46:16 +0000 (13:46 +0000)]
Auto merge of #80354 - ssomers:btree_test_compact, r=Mark-Simulacrum

BTreeMap: test full nodes a little more

r? `@Mark-Simulacrum`

3 years agoAuto merge of #80316 - ehuss:rustdoc-index, r=Mark-Simulacrum
bors [Sat, 26 Dec 2020 09:29:56 +0000 (09:29 +0000)]
Auto merge of #80316 - ehuss:rustdoc-index, r=Mark-Simulacrum

Include rustdoc in the compiler docs index.

This should help ensure that the index page at https://doc.rust-lang.org/nightly/nightly-rustc/ includes a link to the rustdoc docs as well.

Fixes #80307

3 years agoAuto merge of #80209 - erikdesjardins:ptrcmp, r=Mark-Simulacrum
bors [Sat, 26 Dec 2020 06:43:51 +0000 (06:43 +0000)]
Auto merge of #80209 - erikdesjardins:ptrcmp, r=Mark-Simulacrum

Remove pointer comparison from slice equality

This resurrects #71735.

Fixes #71602, helps with #80140.

r? `@Mark-Simulacrum`

3 years agoRemove pointer comparison from slice equality
bors [Sat, 26 Dec 2020 06:43:51 +0000 (06:43 +0000)]
Remove pointer comparison from slice equality

This resurrects #71735.

Fixes #71602, helps with #80140.

r? `@Mark-Simulacrum`

3 years agoAuto merge of #79022 - SpyrosRoum:stabilize-deque_range, r=m-ou-se
bors [Sat, 26 Dec 2020 03:50:16 +0000 (03:50 +0000)]
Auto merge of #79022 - SpyrosRoum:stabilize-deque_range, r=m-ou-se

stabilize deque_range

Make #74217 stable, stabilizing `VecDeque::range` and `VecDeque::range_mut`.
Pr: #74099

r? `@m-ou-se`

3 years agoAuto merge of #80246 - matthewjasper:projection-cycle-caching, r=Mark-Simulacrum
bors [Sat, 26 Dec 2020 00:11:30 +0000 (00:11 +0000)]
Auto merge of #80246 - matthewjasper:projection-cycle-caching, r=Mark-Simulacrum

Prevent caching normalization results with a cycle

When normalizing a projection which results in a cycle, we would cache the result of `project_type` without the nested obligations (because they're not needed for inference). This would result in the nested obligations only being handled once in fulfill, which would avoid the cycle error. `get_paranoid_cache_value_obligation` used to add an obligation that resulted in a cycle in this case previously, but was removed by #73905.

This PR makes the projection cache not cache the value of a projection if it was ever normalized in a cycle (except in a snapshot that's rolled back).

Fixes #79714.

r? `@nikomatsakis`

3 years agoAuto merge of #80366 - Mark-Simulacrum:bump-version, r=Mark-Simulacrum
bors [Fri, 25 Dec 2020 21:19:11 +0000 (21:19 +0000)]
Auto merge of #80366 - Mark-Simulacrum:bump-version, r=Mark-Simulacrum

Bump version to 1.51

r? `@Mark-Simulacrum`

3 years agoAuto merge of #80235 - RalfJung:validate-promoteds, r=oli-obk
bors [Fri, 25 Dec 2020 18:25:48 +0000 (18:25 +0000)]
Auto merge of #80235 - RalfJung:validate-promoteds, r=oli-obk

validate promoteds

Turn on const-value validation for promoteds. This is made possible now that https://github.com/rust-lang/rust/issues/67534 is resolved.

I don't think this is a breaking change. We don't promote any unsafe operation any more (since https://github.com/rust-lang/rust/pull/77526 landed). We *do* promote `const fn` calls under some circumstances (in `const`/`static` initializers), but union field access and similar operations are not allowed in `const fn`. So now is a perfect time to add this check. :D

r? `@oli-obk`
Fixes https://github.com/rust-lang/rust/issues/67465

3 years agoBump version to 1.51
Mark Rousskov [Fri, 25 Dec 2020 15:42:53 +0000 (10:42 -0500)]
Bump version to 1.51

3 years agoAuto merge of #80296 - wesleywiser:revert_missing_fragment_specifier_hard_error,...
bors [Fri, 25 Dec 2020 14:09:08 +0000 (14:09 +0000)]
Auto merge of #80296 - wesleywiser:revert_missing_fragment_specifier_hard_error, r=Mark-Simulacrum

Revert missing fragment specifier hard error

Closes #76605

Reopens #40107

r? `@Mark-Simulacrum`

3 years agoRustfmt
bjorn3 [Fri, 25 Dec 2020 11:48:19 +0000 (12:48 +0100)]
Rustfmt

3 years agoSet rust-analyzer importMergeBehaviour option to last
bjorn3 [Fri, 25 Dec 2020 11:47:03 +0000 (12:47 +0100)]
Set rust-analyzer importMergeBehaviour option to last

3 years agoMerge pull request #1120 from bjorn3/lazy_jit
bjorn3 [Fri, 25 Dec 2020 11:40:18 +0000 (12:40 +0100)]
Merge pull request #1120 from bjorn3/lazy_jit

Lazy compilation in jit mode

3 years agoAdd documentation
bjorn3 [Fri, 25 Dec 2020 11:13:11 +0000 (12:13 +0100)]
Add documentation

3 years agoAuto merge of #80226 - ThePuzzlemaker:issue-80004-fix, r=jyn514,petrochenkov
bors [Fri, 25 Dec 2020 11:16:53 +0000 (11:16 +0000)]
Auto merge of #80226 - ThePuzzlemaker:issue-80004-fix, r=jyn514,petrochenkov

Highlight edition-specific keywords correctly in code blocks, accounting for code block edition modifiers

Previously, edition-specific keywords (such as `async` and `await`) were not highlighted in code blocks, regardless of what edition was set. With this PR, this issue is fixed.

Now, the following behavior happens:
- When a code block is explicitly set to edition X, keywords from edition X are highlighted
- When a code block is explicitly set to a version that does not contain those keywords from edition X (e.g. edition Y), keywords from edition X are **not** highlighted
- When a code block has no explicit edition, keywords from the edition passed via `--edition` to rustdoc are highlighted

For example, a project set with `edition = "2015"` in its `Cargo.toml` would not highlight `async`/`await` unless the code block was set to `edition2018`. Additionally, a project set with `edition = "2018"` in its `Cargo.toml` *would* highlight `async`/`await` unless the code block was set to a version that did not contain those keywords (e.g. `edition2015`).

This PR fixes #80004.

r? `@jyn514`

3 years agoImplement lazy compilation in JIT mode
bjorn3 [Fri, 25 Dec 2020 10:41:48 +0000 (11:41 +0100)]
Implement lazy compilation in JIT mode

Lazy compilation has the potential to significantly improve the startup
time of a program. While functions have to be codegened when called, it
is expected that a significant amount of all code is only required when
an error occurs or only when the program is used in certain ways.

The basic approach is to first codegen a shim for each function. This
shim calls the `__cg_clif_jit` function of cg_clif with a pointer to the
`Instance` corresponding to the function for which it is a shim.
`__cg_clif_jit` function then codegens this function and uses the hot
code swapping support of SimpleJIT to redirect future calls to the
function to the real version. Finally it calls the newly codegened
function.

3 years agoMove finalize CodegenCx timer out of codegen mono items timer
bjorn3 [Fri, 25 Dec 2020 10:49:50 +0000 (11:49 +0100)]
Move finalize CodegenCx timer out of codegen mono items timer

3 years agoChange the way JIT mode is selected
bjorn3 [Fri, 25 Dec 2020 10:31:33 +0000 (11:31 +0100)]
Change the way JIT mode is selected

3 years agoUse PIC in JIT mode too
bjorn3 [Thu, 17 Dec 2020 18:31:38 +0000 (19:31 +0100)]
Use PIC in JIT mode too

3 years agoBTreeMap: declare exclusive access to arrays when copying from them
Stein Somers [Mon, 23 Nov 2020 13:41:53 +0000 (14:41 +0100)]
BTreeMap: declare exclusive access to arrays when copying from them

3 years agoAuto merge of #80187 - 0dvictor:nativelib, r=bjorn3
bors [Fri, 25 Dec 2020 08:17:21 +0000 (08:17 +0000)]
Auto merge of #80187 - 0dvictor:nativelib, r=bjorn3

Exclude unnecessary info from CodegenResults

`foreign_module` and `wasm_import_module` are not needed for linking, and hence can be removed from CodegenResults.

Fixes #77857

3 years agoAuto merge of #80364 - Dylan-DPC:rollup-0y96okz, r=Dylan-DPC
bors [Fri, 25 Dec 2020 05:23:24 +0000 (05:23 +0000)]
Auto merge of #80364 - Dylan-DPC:rollup-0y96okz, r=Dylan-DPC

Rollup of 11 pull requests

Successful merges:

 - #79213 (Stabilize `core::slice::fill`)
 - #79999 (Refactored verbose print into a function)
 - #80160 (Implemented a compiler diagnostic for move async mistake)
 - #80274 (Rename rustc_middle::lint::LintSource)
 - #80280 (Add installation commands to `x` tool README)
 - #80319 (Fix elided lifetimes shown as `'_` on async functions)
 - #80327 (Updated the match with the matches macro)
 - #80330 (Fix typo in simplify_try.rs)
 - #80340 (Don't unnecessarily override attrs for Module)
 - #80342 (Fix typo)
 - #80352 (BTreeMap: make test cases more explicit on failure)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #80352 - ssomers:btree_test_diagnostics, r=Mark-Simulacrum
Dylan DPC [Fri, 25 Dec 2020 02:39:51 +0000 (03:39 +0100)]
Rollup merge of #80352 - ssomers:btree_test_diagnostics, r=Mark-Simulacrum

BTreeMap: make test cases more explicit on failure

r? `@Mark-Simulacrum`

3 years agoRollup merge of #80342 - pierwill:patch-1, r=lcnr
Dylan DPC [Fri, 25 Dec 2020 02:39:49 +0000 (03:39 +0100)]
Rollup merge of #80342 - pierwill:patch-1, r=lcnr

Fix typo

3 years agoRollup merge of #80340 - jyn514:less-modules-attrs, r=GuillaumeGomez
Dylan DPC [Fri, 25 Dec 2020 02:39:48 +0000 (03:39 +0100)]
Rollup merge of #80340 - jyn514:less-modules-attrs, r=GuillaumeGomez

Don't unnecessarily override attrs for Module

They were never changed from the default, which you can get with `tcx.get_attrs()`.

3 years agoRollup merge of #80330 - eltociear:patch-2, r=lcnr
Dylan DPC [Fri, 25 Dec 2020 02:39:46 +0000 (03:39 +0100)]
Rollup merge of #80330 - eltociear:patch-2, r=lcnr

Fix typo in simplify_try.rs

assigment -> assignment

3 years agoRollup merge of #80327 - PankajChaudhary5:PankajChaudhary, r=GuillaumeGomez
Dylan DPC [Fri, 25 Dec 2020 02:39:43 +0000 (03:39 +0100)]
Rollup merge of #80327 - PankajChaudhary5:PankajChaudhary, r=GuillaumeGomez

Updated the match with the matches macro

r?````@GuillaumeGomez````

3 years agoRollup merge of #80319 - jyn514:async-lifetimes, r=tmandry
Dylan DPC [Fri, 25 Dec 2020 02:39:40 +0000 (03:39 +0100)]
Rollup merge of #80319 - jyn514:async-lifetimes, r=tmandry

Fix elided lifetimes shown as `'_` on async functions

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

r? `@tmandry` on the implementation, `@Darksonn` on the test cases.

3 years agoRollup merge of #80280 - pierwill:x-readme, r=Mark-Simulacrum
Dylan DPC [Fri, 25 Dec 2020 02:39:38 +0000 (03:39 +0100)]
Rollup merge of #80280 - pierwill:x-readme, r=Mark-Simulacrum

Add installation commands to `x` tool README

3 years agoRollup merge of #80274 - pierwill:lintlevelsource, r=petrochenkov
Dylan DPC [Fri, 25 Dec 2020 02:39:36 +0000 (03:39 +0100)]
Rollup merge of #80274 - pierwill:lintlevelsource, r=petrochenkov

Rename rustc_middle::lint::LintSource

Rename [`rustc_middle::lint::LintSource`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/lint/enum.LintSource.html) to `rustc_middle::lint::LintLevelSource`.

This enum represents the source of a *lint level*, not a lint. This should improve code readability.

Update: Also documents `rustc_middle::lint::LevelSource` to clarify.

3 years agoRollup merge of #80160 - diondokter:move_async_fix, r=davidtwco
Dylan DPC [Fri, 25 Dec 2020 02:39:35 +0000 (03:39 +0100)]
Rollup merge of #80160 - diondokter:move_async_fix, r=davidtwco

Implemented a compiler diagnostic for move async mistake

Fixes #79694

First time contributing, so I hope I'm doing everything right.
(If not, please correct me!)

This code performs a check when a move capture clause is parsed. The check is to detect if the user has reversed the async move keywords and to provide a diagnostic with a suggestion to fix it.

Checked code:
```rust
fn main() {
    move async { };
}
```

Previous output:
```txt
PS C:\Repos\move_async_test> cargo build
   Compiling move_async_test v0.1.0 (C:\Repos\move_async_test)
error: expected one of `|` or `||`, found keyword `async`
 --> src\main.rs:2:10
  |
2 |     move async { };
  |          ^^^^^ expected one of `|` or `||`

error: aborting due to previous error

error: could not compile `move_async_test`
```

New output:
```txt
PS C:\Repos\move_async_test> cargo +dev build
   Compiling move_async_test v0.1.0 (C:\Repos\move_async_test)
error: the order of `move` and `async` is incorrect
 --> src\main.rs:2:13
  |
2 |     let _ = move async { };
  |             ^^^^^^^^^^
  |
help: try switching the order
  |
2 |     let _ = async move { };
  |             ^^^^^^^^^^

error: aborting due to previous error

error: could not compile `move_async_test`
```

Is there a file/module where these kind of things are tested?
Would love some feedback ðŸ˜„

3 years agoRollup merge of #79999 - hencrice:yenlinc/79799, r=oli-obk
Dylan DPC [Fri, 25 Dec 2020 02:39:33 +0000 (03:39 +0100)]
Rollup merge of #79999 - hencrice:yenlinc/79799, r=oli-obk

Refactored verbose print into a function

Also handle Tuple and Array separately, which was not explicitly checked.

Fixes #79799.

3 years agoRollup merge of #79213 - yoshuawuyts:stabilize-slice-fill, r=m-ou-se
Dylan DPC [Fri, 25 Dec 2020 02:39:31 +0000 (03:39 +0100)]
Rollup merge of #79213 - yoshuawuyts:stabilize-slice-fill, r=m-ou-se

Stabilize `core::slice::fill`

Tracking issue https://github.com/rust-lang/rust/issues/70758

Stabilizes the `core::slice::fill` API in Rust 1.50, adding a `memset` doc alias so people coming from C/C++ looking for this operation can find it in the docs. This API hasn't seen any changes since we changed the signature in https://github.com/rust-lang/rust/pull/71165/, and it seems like the right time to propose stabilization. Thanks!

r? `@m-ou-se`

3 years agoAuto merge of #79762 - Swatinem:remap-doctest-coverage, r=Swatinem
bors [Fri, 25 Dec 2020 02:37:08 +0000 (02:37 +0000)]
Auto merge of #79762 - Swatinem:remap-doctest-coverage, r=Swatinem

Remap instrument-coverage line numbers in doctests

This uses the `SourceMap::doctest_offset_line` method to re-map line
numbers from doctests. Remapping columns is not yet done, and rustdoc
still does not output the correct filename when running doctests in a
workspace.

Part of #79417 although I dont consider that fixed until both filenames
and columns are mapped correctly.

r? `@richkadel`

I might jump on zulip the comming days. Still need to figure out how to properly write tests for this, and deal with other doctest issues in the meantime.

3 years agoDon't process `[]` and `()` in intra-doc links
Joshua Nelson [Thu, 24 Dec 2020 23:55:05 +0000 (18:55 -0500)]
Don't process `[]` and `()` in intra-doc links

These caused several false positives when documenting rustc, which means
there will likely be many more false positives in the rest of the
ecosystem.

3 years agoDocument rustc_macros on nightly-rustc
Joshua Nelson [Fri, 25 Dec 2020 01:23:54 +0000 (20:23 -0500)]
Document rustc_macros on nightly-rustc

3 years agoAuto merge of #79347 - ssomers:btree_split_pointer_provenance, r=Mark-Simulacrum
bors [Thu, 24 Dec 2020 21:49:15 +0000 (21:49 +0000)]
Auto merge of #79347 - ssomers:btree_split_pointer_provenance, r=Mark-Simulacrum

BTreeMap: respect pointer provenance rules in split_off

The test cases for `split_off` reported a few more violations (now that they support -Zmiri-track-raw-pointers). The functions `shift_kv` and `shift_edges` do not fix anything, I think, but if `move_kv` and `move_edges` exist, they deserve to live too.

r? `@Mark-Simulacrum`

3 years agorustdoc: Highlight edition-specific keywords correctly in code blocks, accounting...
ThePuzzlemaker [Sun, 20 Dec 2020 07:34:33 +0000 (01:34 -0600)]
rustdoc: Highlight edition-specific keywords correctly in code blocks, accounting for code block edition modifiers

This is a squash of these commits:
- Highlight edition-specific keywords correctly in code blocks,
accounting for code block edition modifiers
- Fix unit tests
- Revert changes to rustc_span::symbol to prepare for merge of #80272
- Use new Symbol::is_reserved API from #80272
- Remove unused import added by accident when merging

3 years agoAuto merge of #80322 - ehuss:update-cargo, r=ehuss
bors [Thu, 24 Dec 2020 18:12:15 +0000 (18:12 +0000)]
Auto merge of #80322 - ehuss:update-cargo, r=ehuss

Update cargo

10 commits in a3c2627fbc2f5391c65ba45ab53b81bf71fa323c..75d5d8cffe3464631f82dcd3c470b78dc1dda8bb
2020-12-14 17:21:26 +0000 to 2020-12-22 18:10:56 +0000
- Update git2 (rust-lang/cargo#9009)
- Stabilize RUSTC_WORKSPACE_WRAPPER (rust-lang/cargo#8976)
- Make cargo metadata and tree respect target (rust-lang/cargo#8987)
- Update git2 (rust-lang/cargo#8998)
- Revert rust-lang/cargo#8954 - changing rustdoc's cwd (rust-lang/cargo#8996)
- With debug HTTP mode log curl's version (rust-lang/cargo#8991)
- Reject ambiguous git dependency declaration. (rust-lang/cargo#8984)
- Fix tests not working with a different CARGO_TARGET_DIR. (rust-lang/cargo#8982)
- Add version to credential dependencies. (rust-lang/cargo#8983)
- Clarify FAQ entry wording about lockfiles (rust-lang/cargo#8978)

3 years agoBTreeMap: test full nodes a little more
Stein Somers [Wed, 18 Nov 2020 17:19:38 +0000 (18:19 +0100)]
BTreeMap: test full nodes a little more

3 years agoBTreeMap: test split_off (and append) more thoroughly
Stein Somers [Wed, 18 Nov 2020 17:19:38 +0000 (18:19 +0100)]
BTreeMap: test split_off (and append) more thoroughly

3 years agoAuto merge of #79742 - GuillaumeGomez:move-tooltips-messages-out-of-html, r=Nemo157
bors [Thu, 24 Dec 2020 15:22:28 +0000 (15:22 +0000)]
Auto merge of #79742 - GuillaumeGomez:move-tooltips-messages-out-of-html, r=Nemo157

Move tooltips messages out of html

First thing first: nothing in the output has changed. You still have the "i" on the left of code blocks examples when they have `ignore`, `compile_fail`, `should_panic` and `edition`. The behavior also remains the same: when you hover the "i", you have the corresponding message showing up.

So now, why this PR then? I realized recently that we were actually generating those messages into the HTML every time whereas all messages are the same (except for the edition ones, I'll come back to it later). So instead of generating more content, I simply moved it inside the CSS thanks to pseudo elements (`::before` and `::after`). The message is now inside `::after` and we use the `::before` to have the small triangle on the left of the message. So now, we have less HTML generated which is seems pretty nice.

So now, back to the `edition` change: the message is globally the same, but the "edition" itself can be different (2015 or 2018 currently, I expect 2021 to arrive not too far in the future). So the only difference for it is that I added a new attribute on the tooltip called `edition` which contains this information. Then, the `::after` uses it inside its `content` (you can get the content of an element's attribute by using `attr` and concat different strings by simply having them after the other).

Don't hesitate if a part of my explanations isn't clear.

r? `@jyn514`

3 years agoBTreeMap: make test cases more explicit on failure
Stein Somers [Wed, 18 Nov 2020 17:19:38 +0000 (18:19 +0100)]
BTreeMap: make test cases more explicit on failure

3 years agouse matches!() macro in more places
Matthias Krüger [Thu, 24 Dec 2020 01:55:21 +0000 (02:55 +0100)]
use matches!() macro in more places

3 years agoAuto merge of #80295 - GuillaumeGomez:beautify-rework, r=petrochenkov
bors [Thu, 24 Dec 2020 11:30:24 +0000 (11:30 +0000)]
Auto merge of #80295 - GuillaumeGomez:beautify-rework, r=petrochenkov

Rework beautify_doc_string so that it returns a Symbol instead of a String

This commit comes from https://github.com/rust-lang/rust/pull/80261, the goal here is to inspect the impact on performance of this change on its own.

The idea of rewriting `beautify_doc_string` is to not go through `String` if we don't need to update the doc comment to be able to keep the original `Symbol` and also to have better performance.

r? `@jyn514`

3 years agoBTreeMap: avoid implicit use of node length in flight
Stein Somers [Mon, 23 Nov 2020 13:41:53 +0000 (14:41 +0100)]
BTreeMap: avoid implicit use of node length in flight

3 years agoAuto merge of #77692 - PankajChaudhary5:issue-76630, r=davidtwco
bors [Thu, 24 Dec 2020 07:32:19 +0000 (07:32 +0000)]
Auto merge of #77692 - PankajChaudhary5:issue-76630, r=davidtwco

Added better error message for shared borrow treated as unique for purposes of lifetimes

Part of Issue #76630

r? `@jyn514`

3 years agoAuto merge of #80249 - calebcartwright:update-rustfmt, r=Mark-Simulacrum
bors [Thu, 24 Dec 2020 04:41:11 +0000 (04:41 +0000)]
Auto merge of #80249 - calebcartwright:update-rustfmt, r=Mark-Simulacrum

update rustfmt to v1.4.30

Contains fixes for a few reported bugs on current nightly (1.4.29)

Notes in: https://github.com/rust-lang/rustfmt/releases/tag/v1.4.30

3 years agoAuto merge of #79589 - tgnottingham:shared_dep_graph, r=michaelwoerister
bors [Thu, 24 Dec 2020 01:06:36 +0000 (01:06 +0000)]
Auto merge of #79589 - tgnottingham:shared_dep_graph, r=michaelwoerister

rustc_query_system: reduce dependency graph memory usage

This change implements, at a high level, two space optimizations to the dependency graph.

The first optimization is sharing graph data with the previous dependency graph. Whenever we intern a node, we know whether that node is new (not in the previous graph) or not, and if not, the color of the node in the previous graph.

Red and green nodes have their `DepNode` present in the previous graph, so for that piece of node data, we can just store the index of the node in the previous graph rather than duplicate the `DepNode`. Green nodes additionally have the the same result `Fingerprint`, so we can avoid duplicating that too. Finally, we distinguish between "light" and "dark" green nodes, where the latter are nodes that were marked green because all of their dependencies were marked green. These nodes can additionally share edges with the previous graph, because we know that their set of dependencies is the same (technically, light green and red nodes can have the same dependencies too, but we don't try to figure out whether or not that's the case).

Also, some effort is made to pack data tightly, and to avoid storing `DepNode`s as map keys more than once.

The second optimization is storing edges in a more compact representation, as in the `SerializedDepGraph`, that is, in a single vector, rather than one `EdgesVec` per node. An `EdgesVec` is a `SmallVec` with an inline buffer for 8 elements. Each `EdgesVec` is, at minimum, 40 bytes, and has a per-node overhead of up to 40 bytes. In the ideal case of exactly 8 edges, then 32 bytes are used for edges, and the overhead is 8 bytes. But most of the time, the overhead is higher.

In contrast, using a single vector to store all edges, and having each node specify its start and end elements as 4 byte indices into the vector has a constant overhead of 8 bytes--the best case scenario for the per-node `EdgesVec` approach.

The downside of this approach is that `EdgesVec`s built up during query execution have to be copied into the vector, whereas before, we could just take ownership over them. However, we mostly make up for this because the single vector representation enables a more efficient implementation of `DepGraph::serialize`.

3 years agoAuto merge of #79521 - ssomers:btree_cleanup_2, r=Mark-Simulacrum
bors [Wed, 23 Dec 2020 21:43:28 +0000 (21:43 +0000)]
Auto merge of #79521 - ssomers:btree_cleanup_2, r=Mark-Simulacrum

BTreeMap: relax the explicit borrow rule to make code shorter and safer

Expressions like `.reborrow_mut().into_len_mut()` are annoyingly long, and kind of dangerous for the reason `reborrow_mut()` is unsafe. By relaxing the single rule, we no longer have to make an exception for functions with a `borrow` name and functions like `as_leaf_mut`. This is largely restoring the declaration style of the btree::node API about a year ago, but with more explanation and consistency.

r? `@Mark-Simulacrum`

3 years agoFix typo
pierwill [Wed, 23 Dec 2020 21:08:15 +0000 (13:08 -0800)]
Fix typo

3 years agoDon't unnecessarily override attrs for Module
Joshua Nelson [Wed, 23 Dec 2020 20:05:06 +0000 (15:05 -0500)]
Don't unnecessarily override attrs for Module

They were never changed from the default, which you can get with
`tcx.get_attrs()`.

3 years agoAdd libz-sys to rustc-workspace-hack.
Eric Huss [Wed, 23 Dec 2020 20:18:15 +0000 (12:18 -0800)]
Add libz-sys to rustc-workspace-hack.

https://github.com/alexcrichton/curl-rust/pull/351 changed
curl-rust to no longer enable the default features of libz-sys.
Because rustfmt includes rustc-workspace-hack with the
rustc-workspace-hack/all-static feature (sometimes), it ends up building
libz-sys without the default features. This causes a duplicate
with other packages (like rls) which enable the default
features.

3 years agoUpdate RELEASES.md
XAMPPRocky [Wed, 23 Dec 2020 19:56:17 +0000 (19:56 +0000)]
Update RELEASES.md

3 years agoUpdate HTML DOM attribute "edition" to "data-edition"
Guillaume Gomez [Wed, 23 Dec 2020 19:27:12 +0000 (20:27 +0100)]
Update HTML DOM attribute "edition" to "data-edition"

3 years agoFixed formatting
Yenlin Chen [Wed, 23 Dec 2020 19:10:59 +0000 (19:10 +0000)]
Fixed formatting

3 years agoAddressed feedbacks
Yenlin Chen [Wed, 23 Dec 2020 18:55:37 +0000 (18:55 +0000)]
Addressed feedbacks

Also updated the mir-opt test output files.

3 years agoAuto merge of #79788 - pietroalbini:bootstrap-tarball, r=Mark-Simulacrum
bors [Wed, 23 Dec 2020 18:50:01 +0000 (18:50 +0000)]
Auto merge of #79788 - pietroalbini:bootstrap-tarball, r=Mark-Simulacrum

Refactor dist tarballs generation

Before this PR, each tarball we ship as part of a release was generated by manually creating the directory structure and invoking `rust-installer generate`. This means each tarball was slightly different, adding new ones meant copy-pasting the code generating another tarball and removing the useless parts, and more importantly refactoring how tarballs are generated is extremely time-consuming.

This PR introduces a new abstraction in rustbuild, `Tarball`. The `Tarball` struct provides a trivial API to generate simple tarballs, and can get out of the way when more complex tarballs have to generate. For example, the whole code to generate the `build-manifest` tarball is now the following:

```rust
let tarball = Tarball::new(builder, "build-manifest", &self.target.triple);
tarball.add_file(&build_manifest, "bin", 0o755);
tarball.generate()
```

One notable change between the old tarballs and the new ones is that the "overlay" (README.md, COPYRIGHT, LICENSE-APACHE and LICENSE-MIT) is now available in every produced tarball, while before each tarball inconsistently had or didn't have those files. Tarballs that need a different overlay have a way to change which files to include (with the `set_overlay` method):

```rust
let mut tarball = Tarball::new(builder, "rustfmt", &target.triple);
tarball.set_overlay(OverlayKind::Rustfmt);
tarball.add_file(rustfmt, "bin", 0o755);
tarball.add_file(cargofmt, "bin", 0o755);
tarball.add_legal_and_readme_to("share/doc/rustfmt");
Some(tarball.generate())
```

The PR should be reviewed commit-by-commit, as each commit migrated a separate tarball to use `Tarball`. During development i made sure every tarball can still be generated, and for the most compex tarballs I manually ensured the list of files between the old and new tarballs did not have unexpected changes.

r? `@Mark-Simulacrum`

3 years agobootstrap: convert reproducible-artifacts to use Tarball
Pietro Albini [Wed, 23 Dec 2020 18:40:45 +0000 (19:40 +0100)]
bootstrap: convert reproducible-artifacts to use Tarball