]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #95530 - notriddle:notriddle/private-kw-prim, r=jsha
Matthias Krüger [Fri, 1 Apr 2022 04:59:45 +0000 (06:59 +0200)]
Rollup merge of #95530 - notriddle:notriddle/private-kw-prim, r=jsha

rustdoc: do not show primitives and keywords as private

Fixes this:

![image](https://user-images.githubusercontent.com/1593513/161102430-f1f0301e-3e7f-453f-9c0a-bc87a12b893d.png)

2 years agoRollup merge of #95388 - RalfJung:rust-val-limit, r=oli-obk
Matthias Krüger [Fri, 1 Apr 2022 04:59:44 +0000 (06:59 +0200)]
Rollup merge of #95388 - RalfJung:rust-val-limit, r=oli-obk

interpret: make isize::MAX the limit for dynamic value sizes

We are currently enforcing `data_layout.obj_size_bound()` as the maximal dynamic size of a Rust value (including for `size_of_val_raw`), but that does not match the docs.

In particular, Miri currently falsely says that this code has UB:
```rust
#![feature(layout_for_ptr)]
fn main() {
    let size = isize::MAX as usize;
    // Creating a raw slice of size isize::MAX and asking for its size is okay.
    let s = std::ptr::slice_from_raw_parts(1usize as *const u8, size);
    assert_eq!(size, unsafe { std::mem::size_of_val_raw(s) });
}
```

2 years agoRollup merge of #95344 - jyn514:better-debug-output, r=camelid
Matthias Krüger [Fri, 1 Apr 2022 04:59:43 +0000 (06:59 +0200)]
Rollup merge of #95344 - jyn514:better-debug-output, r=camelid

Make `impl Debug for rustdoc::clean::Item` easier to read

Before:

```
Item { name: Some("Send"), attrs: Attributes { doc_strings: [DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:15:1: 15:60 (#0), parent_module: None, doc: " Types that can be transferred across thread boundaries.", kind: SugaredDoc, indent: 1 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:16:1: 16:4 (#0), parent_module: None, doc: "", kind: SugaredDoc, indent: 0 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:17:1: 17:78 (#0), parent_module: None, doc: " This trait is automatically implemented when the compiler determines it's", kind: SugaredDoc, indent: 1 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:18:1: 18:17 (#0), parent_module: None, doc: " appropriate.", kind: SugaredDoc, indent: 1 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:19:1: 19:4 (#0), parent_module: None, doc: "", kind: SugaredDoc, indent: 0 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:20:1: 20:70 (#0), parent_module: None, doc: " An example of a non-`Send` type is the reference-counting pointer", kind: SugaredDoc, indent: 1 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:21:1: 21:85 (#0), parent_module: None, doc: " [`rc::Rc`][`Rc`]. If two threads attempt to clone [`Rc`]s that point to the same", kind: SugaredDoc, indent: 1 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:22:1: 22:81 (#0), parent_module: None, doc: " reference-counted value, they might try to update the reference count at the", kind: SugaredDoc, indent: 1 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:23:1: 23:83 (#0), parent_module: None, doc: " same time, which is [undefined behavior][ub] because [`Rc`] doesn't use atomic", kind: SugaredDoc, indent: 1 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:24:1: 24:84 (#0), parent_module: None, doc: " operations. Its cousin [`sync::Arc`][arc] does use atomic operations (incurring", kind: SugaredDoc, indent: 1 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:25:1: 25:39 (#0), parent_module: None, doc: " some overhead) and thus is `Send`.", kind: SugaredDoc, indent: 1 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:26:1: 26:4 (#0), parent_module: None, doc: "", kind: SugaredDoc, indent: 0 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:27:1: 27:74 (#0), parent_module: None, doc: " See [the Nomicon](../../nomicon/send-and-sync.html) for more details.", kind: SugaredDoc, indent: 1 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:28:1: 28:4 (#0), parent_module: None, doc: "", kind: SugaredDoc, indent: 0 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:29:1: 29:40 (#0), parent_module: None, doc: " [`Rc`]: ../../std/rc/struct.Rc.html", kind: SugaredDoc, indent: 1 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:30:1: 30:42 (#0), parent_module: None, doc: " [arc]: ../../std/sync/struct.Arc.html", kind: SugaredDoc, indent: 1 }, DocFragment { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:31:1: 31:61 (#0), parent_module: None, doc: " [ub]: ../../reference/behavior-considered-undefined.html", kind: SugaredDoc, indent: 1 }], other_attrs: [Attribute { kind: Normal(AttrItem { path: Path { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:32:3: 32:9 (#0), segments: [PathSegment { ident: stable#0, id: NodeId(33577), args: None }], tokens: None }, args: Delimited(DelimSpan { open: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:32:9: 32:10 (#0), close: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:32:44: 32:45 (#0) }, Parenthesis, TokenStream([(Token(Token { kind: Ident("feature", false), span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:32:10: 32:17 (#0) }), Alone), (Token(Token { kind: Eq, span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:32:18: 32:19 (#0) }), Alone), (Token(Token { kind: Literal(Lit { kind: Str, symbol: "rust1", suffix: None }), span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:32:20: 32:27 (#0) }), Joint), (Token(Token { kind: Comma, span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:32:27: 32:28 (#0) }), Alone), (Token(Token { kind: Ident("since", false), span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:32:29: 32:34 (#0) }), Alone), (Token(Token { kind: Eq, span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:32:35: 32:36 (#0) }), Alone), (Token(Token { kind: Literal(Lit { kind: Str, symbol: "1.0.0", suffix: None }), span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:32:37: 32:44 (#0) }), Alone)])), tokens: None }, None), id: AttrId(48), style: Outer, span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:32:1: 32:46 (#0) }, Attribute { kind: Normal(AttrItem { path: Path { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:33:23: 33:44 (#0), segments: [PathSegment { ident: rustc_diagnostic_item#0, id: NodeId(33578), args: None }], tokens: None }, args: Eq(/rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:33:45: 33:46 (#0), Token { kind: Literal(Lit { kind: Str, symbol: "Send", suffix: None }), span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:33:47: 33:53 (#0) }), tokens: None }, None), id: AttrId(49), style: Outer, span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:33:23: 33:53 (#0) }, Attribute { kind: Normal(AttrItem { path: Path { span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:34:3: 34:25 (#0), segments: [PathSegment { ident: rustc_on_unimplemented#0, id: NodeId(33580), args: None }], tokens: None }, args: Delimited(DelimSpan { open: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:34:25: 34:26 (#0), close: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:37:1: 37:2 (#0) }, Parenthesis, TokenStream([(Token(Token { kind: Ident("message", false), span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:35:5: 35:12 (#0) }), Alone), (Token(Token { kind: Eq, span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:35:13: 35:14 (#0) }), Alone), (Token(Token { kind: Literal(Lit { kind: Str, symbol: "`{Self}` cannot be sent between threads safely", suffix: None }), span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:35:15: 35:63 (#0) }), Joint), (Token(Token { kind: Comma, span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:35:63: 35:64 (#0) }), Alone), (Token(Token { kind: Ident("label", false), span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:36:5: 36:10 (#0) }), Alone), (Token(Token { kind: Eq, span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:36:11: 36:12 (#0) }), Alone), (Token(Token { kind: Literal(Lit { kind: Str, symbol: "`{Self}` cannot be sent between threads safely", suffix: None }), span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:36:13: 36:61 (#0) }), Alone)])), tokens: None }, None), id: AttrId(50), style: Outer, span: /rustc/37b55c8a0cafdb60b9168da34f904acc70157df8/library/core/src/marker.rs:34:1: 37:3 (#0) }] }, visibility: Public, kind: TraitItem(Trait { unsafety: Unsafe, items: [], generics: Generics { params: [], where_predicates: [] }, bounds: [], is_auto: true }), def_id: DefId(DefId(2:3027 ~ core[7f4a]::marker::Send)), cfg: None }
```

After:

```
Item { name: Some("Send"), visibility: Public, def_id: DefId(DefId(2:3027 ~ core[7f4a]::marker::Send)), kind: Trait, docs: "Types that can be transferred across thread boundaries.\n\nThis trait is automatically implemented when the compiler determines it's\nappropriate.\n\nAn example of a non-`Send` type is the reference-counting pointer\n[`rc::Rc`][`Rc`]. If two threads attempt to clone [`Rc`]s that point to the same\nreference-counted value, they might try to update the reference count at the\nsame time, which is [undefined behavior][ub] because [`Rc`] doesn't use atomic\noperations. Its cousin [`sync::Arc`][arc] does use atomic operations (incurring\nsome overhead) and thus is `Send`.\n\nSee [the Nomicon](../../nomicon/send-and-sync.html) for more details.\n\n[`Rc`]: ../../std/rc/struct.Rc.html\n[arc]: ../../std/sync/struct.Arc.html\n[ub]: ../../reference/behavior-considered-undefined.html" }
```

The previous output is still present if you really want it for some reason by using `{:#?}` instead of `{:?}`.

r? `@camelid`

2 years agoRollup merge of #95293 - compiler-errors:braces, r=davidtwco
Matthias Krüger [Fri, 1 Apr 2022 04:59:42 +0000 (06:59 +0200)]
Rollup merge of #95293 - compiler-errors:braces, r=davidtwco

suggest wrapping single-expr blocks in square brackets

Suggests a fix in cases like:

```diff
- const A: [i32; 1] = { 1 };

+ const A: [i32; 1] = [ 1 ];
                      ^   ^
```

Also edit the message for the same suggestion in the parser (e.g. `{ 1, 2 }`).

Fixes #95289

2 years agoRollup merge of #95260 - compiler-errors:fn, r=davidtwco
Matthias Krüger [Fri, 1 Apr 2022 04:59:41 +0000 (06:59 +0200)]
Rollup merge of #95260 - compiler-errors:fn, r=davidtwco

Better suggestions for `Fn`-family trait selection errors

1. Suppress suggestions to add `std::ops::Fn{,Mut,Once}` bounds when a type already implements `Fn{,Mut,Once}`
2. Add a note that points out that a type does in fact implement `Fn{,Mut,Once}`, but the arguments vary (either by number or by actual arguments)
3. Add a note that points out that a type does in fact implement `Fn{,Mut,Once}`, but not the right one (e.g. implements `FnMut`, but `Fn` is required).

Fixes #95147

2 years agoRollup merge of #95032 - m-ou-se:std-features, r=yaahc
Matthias Krüger [Fri, 1 Apr 2022 04:59:40 +0000 (06:59 +0200)]
Rollup merge of #95032 - m-ou-se:std-features, r=yaahc

Clean up, categorize and sort unstable features in std.

2 years agoadd notes about alignment-altering reallocs to Allocator docs
Autumn [Thu, 31 Mar 2022 23:13:19 +0000 (16:13 -0700)]
add notes about alignment-altering reallocs to Allocator docs

2 years agoAdd error message suggestion for missing noreturn in naked function
jam1garner [Thu, 31 Mar 2022 22:14:01 +0000 (18:14 -0400)]
Add error message suggestion for missing noreturn in naked function

2 years agoFix feature name of stable parts of strict_provenance
David Tolnay [Thu, 31 Mar 2022 19:46:30 +0000 (12:46 -0700)]
Fix feature name of stable parts of strict_provenance

2 years agoAdjust MaybeUninit feature names to avoid changing unstable one
David Tolnay [Thu, 31 Mar 2022 19:04:14 +0000 (12:04 -0700)]
Adjust MaybeUninit feature names to avoid changing unstable one

2 years agoAdjust feature names that disagree on const stabilization version
David Tolnay [Sun, 27 Mar 2022 02:43:11 +0000 (19:43 -0700)]
Adjust feature names that disagree on const stabilization version

2 years agoHandle rustc_const_stable attribute in library feature collector
David Tolnay [Sun, 27 Mar 2022 02:20:36 +0000 (19:20 -0700)]
Handle rustc_const_stable attribute in library feature collector

2 years agoAuto merge of #95526 - Dylan-DPC:rollup-0ikl5l5, r=Dylan-DPC
bors [Thu, 31 Mar 2022 17:45:26 +0000 (17:45 +0000)]
Auto merge of #95526 - Dylan-DPC:rollup-0ikl5l5, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #91416 (Specialize infinite-type "insert some indirection" suggestion for Option)
 - #95384 (Update target_has_atomic documentation for stabilization)
 - #95517 (small rustc_borrowck cleanup)
 - #95520 (Fix typos in core::ptr docs)
 - #95523 (remove unused field from `infcx`)

Failed merges:

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

2 years agomake utf8_char_counts test faster in Miri
Ralf Jung [Thu, 31 Mar 2022 17:10:53 +0000 (13:10 -0400)]
make utf8_char_counts test faster in Miri

2 years agoCategorize and sort unstable features in std.
Mara Bos [Thu, 17 Mar 2022 10:05:32 +0000 (11:05 +0100)]
Categorize and sort unstable features in std.

2 years agoMerge impl_constness and is_const_fn_raw.
Camille GILLOT [Sun, 13 Mar 2022 10:12:50 +0000 (11:12 +0100)]
Merge impl_constness and is_const_fn_raw.

2 years agorustdoc: do not show primitives and keywords as private
Michael Howell [Thu, 31 Mar 2022 15:56:41 +0000 (08:56 -0700)]
rustdoc: do not show primitives and keywords as private

2 years agoCreate trait_def table.
Camille GILLOT [Thu, 10 Mar 2022 18:07:27 +0000 (19:07 +0100)]
Create trait_def table.

2 years agoStore fn constness in impl_constness.
Camille GILLOT [Wed, 9 Mar 2022 23:37:42 +0000 (00:37 +0100)]
Store fn constness in impl_constness.

2 years agoexpand: Do not count metavar declarations on RHS of `macro_rules`
Vadim Petrochenkov [Thu, 31 Mar 2022 15:56:40 +0000 (18:56 +0300)]
expand: Do not count metavar declarations on RHS of `macro_rules`

They are 0 by definition there.

2 years agoIntroduce repr_options table.
Camille GILLOT [Thu, 3 Mar 2022 16:51:47 +0000 (17:51 +0100)]
Introduce repr_options table.

2 years agoskip slow int_log tests in Miri
Ralf Jung [Thu, 31 Mar 2022 14:44:29 +0000 (10:44 -0400)]
skip slow int_log tests in Miri

2 years agoRollup merge of #95523 - lcnr:yeet-unused-field, r=oli-obk
Dylan DPC [Thu, 31 Mar 2022 15:29:56 +0000 (17:29 +0200)]
Rollup merge of #95523 - lcnr:yeet-unused-field, r=oli-obk

remove unused field from `infcx`

r? `@oli-obk` did we stop needing that for opaque types?

2 years agoRollup merge of #95520 - rust-lang:ptrtypo, r=lcnr
Dylan DPC [Thu, 31 Mar 2022 15:29:55 +0000 (17:29 +0200)]
Rollup merge of #95520 - rust-lang:ptrtypo, r=lcnr

Fix typos in core::ptr docs

2 years agoRollup merge of #95517 - lcnr:rustc_borrowck-misc, r=jackh726
Dylan DPC [Thu, 31 Mar 2022 15:29:54 +0000 (17:29 +0200)]
Rollup merge of #95517 - lcnr:rustc_borrowck-misc, r=jackh726

small rustc_borrowck cleanup

r? `@jackh726` because of the second commit, seems like that comment was missed in #91243

2 years agoRollup merge of #95384 - ehuss:doc-target_has_atomic-stabilized, r=Dylan-DPC
Dylan DPC [Thu, 31 Mar 2022 15:29:53 +0000 (17:29 +0200)]
Rollup merge of #95384 - ehuss:doc-target_has_atomic-stabilized, r=Dylan-DPC

Update target_has_atomic documentation for stabilization

`cfg(target_has_atomic)` was stabilized in #93824, but this small note in the docs was not updated at the time.

2 years agoRollup merge of #91416 - compiler-errors:infinite-ty-option-box, r=estebank
Dylan DPC [Thu, 31 Mar 2022 15:29:52 +0000 (17:29 +0200)]
Rollup merge of #91416 - compiler-errors:infinite-ty-option-box, r=estebank

Specialize infinite-type "insert some indirection" suggestion for Option

Suggest `Option<Box<_>>` instead of `Box<Option<_>>` for infinitely-recursive members of a struct.

Not sure if I can get the span of the generic subty of the Option so I can make this a `+++`-style suggestion. The current output is a tiny bit less fancy looking than the original suggestion.

Should I limit the specialization to just `Option<Box<TheOuterStruct>>`? Because right now it applies to all `Option` members in the struct that are returned by `Representability::SelfRecursive`.

Fixes #91402

r? `@estebank`
(since you wrote the original suggestion and are definitely most familiar with it!)

2 years agoAuto merge of #90204 - cjgillot:owner-pull, r=michaelwoerister
bors [Thu, 31 Mar 2022 15:20:59 +0000 (15:20 +0000)]
Auto merge of #90204 - cjgillot:owner-pull, r=michaelwoerister

Make lowering pull-based

~Based on https://github.com/rust-lang/rust/pull/90451~
Part of https://github.com/rust-lang/rust/pull/88186

The current lowering code visits all the item-likes in the AST in order, and lowers them one by one.
This PR changes it to index the AST and then proceed to lowering on-demand. This is closer to the logic of query-based lowering.

2 years agoremove unused field from `infcx`
lcnr [Thu, 31 Mar 2022 14:52:47 +0000 (16:52 +0200)]
remove unused field from `infcx`

2 years agoaddress comments, add test for shadowed Box type
Michael Goulet [Fri, 18 Feb 2022 03:49:45 +0000 (19:49 -0800)]
address comments, add test for shadowed Box type

2 years agoSpecialize suggestion for Option<T>
Michael Goulet [Wed, 1 Dec 2021 05:30:05 +0000 (21:30 -0800)]
Specialize suggestion for Option<T>

2 years agoFix typos in core::ptr docs
bstrie [Thu, 31 Mar 2022 13:56:36 +0000 (09:56 -0400)]
Fix typos in core::ptr docs

2 years agoupdate comment
lcnr [Thu, 31 Mar 2022 13:41:52 +0000 (15:41 +0200)]
update comment

2 years agoptr_metadata test: avoid ptr-to-int transmutes
Ralf Jung [Thu, 31 Mar 2022 13:32:30 +0000 (09:32 -0400)]
ptr_metadata test: avoid ptr-to-int transmutes

2 years agotest const size_of_val_raw on big value
Ralf Jung [Wed, 30 Mar 2022 02:34:37 +0000 (22:34 -0400)]
test const size_of_val_raw on big value

2 years agocatch overflow in slice size computation
Ralf Jung [Mon, 28 Mar 2022 00:02:11 +0000 (20:02 -0400)]
catch overflow in slice size computation

2 years agoaudit check_mul uses in interpret
Ralf Jung [Sun, 27 Mar 2022 23:49:52 +0000 (19:49 -0400)]
audit check_mul uses in interpret

2 years agointerpret: make isize::MAX the limit for dynamic value sizes
Ralf Jung [Sun, 27 Mar 2022 23:34:16 +0000 (19:34 -0400)]
interpret: make isize::MAX the limit for dynamic value sizes

2 years agoAuto merge of #95511 - Dylan-DPC:rollup-4n880fd, r=Dylan-DPC
bors [Thu, 31 Mar 2022 12:55:13 +0000 (12:55 +0000)]
Auto merge of #95511 - Dylan-DPC:rollup-4n880fd, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #95445 (Don't build the full compiler before running unit tests)
 - #95470 (Fix last rustdoc-gui spurious test)
 - #95478 (Add note to the move size diagnostic)
 - #95495 (Remove unneeded `to_string` call)
 - #95505 (Fix library/std compilation on openbsd.)

Failed merges:

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

2 years agoRecord item-likes in ItemLowerer.
Camille GILLOT [Thu, 15 Jul 2021 15:41:48 +0000 (17:41 +0200)]
Record item-likes in ItemLowerer.

2 years agoCreate a new LoweringContext for each item-like.
Camille GILLOT [Thu, 15 Jul 2021 14:40:41 +0000 (16:40 +0200)]
Create a new LoweringContext for each item-like.

2 years agoMake lowering pull-based.
Camille GILLOT [Wed, 14 Jul 2021 23:18:39 +0000 (01:18 +0200)]
Make lowering pull-based.

2 years agoImplement with_parent_item_lifetime_defs on ItemLowerer.
Camille GILLOT [Wed, 14 Jul 2021 18:28:56 +0000 (20:28 +0200)]
Implement with_parent_item_lifetime_defs on ItemLowerer.

2 years agoMove lower_crate outside the LoweringContext.
Camille GILLOT [Wed, 14 Jul 2021 19:00:02 +0000 (21:00 +0200)]
Move lower_crate outside the LoweringContext.

2 years agoStop emitting lints during lowering.
Camille GILLOT [Sat, 31 Jul 2021 20:50:43 +0000 (22:50 +0200)]
Stop emitting lints during lowering.

2 years agoStore next_disambiguator in Definitions.
Camille GILLOT [Fri, 2 Apr 2021 14:47:08 +0000 (16:47 +0200)]
Store next_disambiguator in Definitions.

2 years agoRemove mutability in ResolverAstLowering.
Camille GILLOT [Thu, 1 Apr 2021 17:05:14 +0000 (19:05 +0200)]
Remove mutability in ResolverAstLowering.

2 years agoRollup merge of #95505 - sunfishcode:sunfishcode/fix-openbsd, r=dtolnay
Dylan DPC [Thu, 31 Mar 2022 11:09:55 +0000 (13:09 +0200)]
Rollup merge of #95505 - sunfishcode:sunfishcode/fix-openbsd, r=dtolnay

Fix library/std compilation on openbsd.

Fix a minor typo from #95241 which prevented compilation on x86_64-unknown-openbsd.

2 years agoRollup merge of #95495 - GuillaumeGomez:rm-unneeded-to-string, r=notriddle
Dylan DPC [Thu, 31 Mar 2022 11:09:54 +0000 (13:09 +0200)]
Rollup merge of #95495 - GuillaumeGomez:rm-unneeded-to-string, r=notriddle

Remove unneeded `to_string` call

Fixes a confusion I made when reading `@camelid's` comment [here](https://github.com/rust-lang/rust/pull/95096#discussion_r838851170).

r? `@notriddle`

2 years agoRollup merge of #95478 - InfRandomness:infrandomness/lint_largemove_note, r=compiler...
Dylan DPC [Thu, 31 Mar 2022 11:09:53 +0000 (13:09 +0200)]
Rollup merge of #95478 - InfRandomness:infrandomness/lint_largemove_note, r=compiler-errors

Add note to the move size diagnostic

context: https://github.com/rust-lang/rust/issues/83518

2 years agoRollup merge of #95470 - GuillaumeGomez:fix-gui-spurious-test, r=notriddle
Dylan DPC [Thu, 31 Mar 2022 11:09:52 +0000 (13:09 +0200)]
Rollup merge of #95470 - GuillaumeGomez:fix-gui-spurious-test, r=notriddle

Fix last rustdoc-gui spurious test

This should the last spurious failing GUI test from https://github.com/rust-lang/rust/issues/93784.

r? ``@notriddle``

2 years agoRollup merge of #95445 - jyn514:rustc-unit-tests, r=Dylan-DPC
Dylan DPC [Thu, 31 Mar 2022 11:09:52 +0000 (13:09 +0200)]
Rollup merge of #95445 - jyn514:rustc-unit-tests, r=Dylan-DPC

Don't build the full compiler before running unit tests

This has been present since `builder.ensure` was first added in https://github.com/rust-lang/rust/pull/43059.
It's unclear to me why it was added then - I tested these changes locally
with `x test compiler/rustc_data_structures --stage 0` and they worked fine.

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

2 years agoobligation cause: `RepeatVec` -> `RepeatValueCopy`
lcnr [Thu, 31 Mar 2022 10:50:53 +0000 (12:50 +0200)]
obligation cause: `RepeatVec` -> `RepeatValueCopy`

2 years agoAuto merge of #95456 - RalfJung:size, r=oli-obk
bors [Thu, 31 Mar 2022 10:33:56 +0000 (10:33 +0000)]
Auto merge of #95456 - RalfJung:size, r=oli-obk

allow large Size again

This basically reverts most of https://github.com/rust-lang/rust/pull/80042, and instead does the panic in `bits()` with a `#[cold]` function to make sure it does not get inlined.

https://github.com/rust-lang/rust/pull/80042 added a comment about an invariant ("The top 3 bits are ALWAYS zero") that is not actually enforced, and if it were enforced that would be a problem for https://github.com/rust-lang/rust/pull/95388. So I think we should not have that invariant, and I adjusted the code accordingly.

r? `@oli-obk` Cc `@sivadeilra`

2 years agoAuto merge of #95507 - ehuss:update-cargo, r=ehuss
bors [Thu, 31 Mar 2022 07:40:18 +0000 (07:40 +0000)]
Auto merge of #95507 - ehuss:update-cargo, r=ehuss

Update cargo

13 commits in 109bfbd055325ef87a6e7f63d67da7e838f8300b..1ef1e0a12723ce9548d7da2b63119de9002bead8
2022-03-17 21:43:09 +0000 to 2022-03-31 00:17:18 +0000
- Support `-Zmultitarget` in cargo config (rust-lang/cargo#10473)
- doc: Fix document url for libcurl format (rust-lang/cargo#10515)
- Fix wrong info in "Environment variables" docs (rust-lang/cargo#10513)
- Use the correct flag in --locked --offline error message (rust-lang/cargo#10512)
- Don't treat host/target duplicates as duplicates (rust-lang/cargo#10466)
- Unstable --keep-going flag (rust-lang/cargo#10383)
- Part 1 of RFC2906 - Packages can inherit fields from their root workspace (rust-lang/cargo#10497)
- Remove unused profile support for -Zpanic-abort-tests (rust-lang/cargo#10495)
- HTTP registry implementation (rust-lang/cargo#10470)
- Add a notice about review capacity. (rust-lang/cargo#10501)
- Add tests for ignoring symlinks (rust-lang/cargo#10047)
- Update doc string for deps_of/compute_deps. (rust-lang/cargo#10494)
- Consistently use crate::display_error on errors during drain (rust-lang/cargo#10394)

2 years agoAuto merge of #95506 - Dylan-DPC:rollup-b6kxzjc, r=Dylan-DPC
bors [Thu, 31 Mar 2022 05:12:45 +0000 (05:12 +0000)]
Auto merge of #95506 - Dylan-DPC:rollup-b6kxzjc, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #95130 (Stabilize thread::is_finished)
 - #95263 (Restore `impl Future<Output = Type>` to async blocks)
 - #95471 (Don't ICE when opaque types get their hidden type constrained again.)
 - #95491 (Stabilize feature vec_retain_mut on Vec and VecDeque)
 - #95497 (Spellchecking compiler comments)

Failed merges:

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

2 years agoUpdate cargo
Eric Huss [Thu, 31 Mar 2022 04:28:18 +0000 (21:28 -0700)]
Update cargo

2 years agoMake `MatcherPos` not derive `Clone`.
Nicholas Nethercote [Thu, 31 Mar 2022 02:50:30 +0000 (13:50 +1100)]
Make `MatcherPos` not derive `Clone`.

It's only used in one place, and there we clone and then make a bunch of
modifications. It's clearer if we duplicate more explicitly, and there's
a symmetry now between `sequence()` and `empty_sequence()`.

2 years agoRemove `MatcherPos::stack`.
Nicholas Nethercote [Wed, 30 Mar 2022 21:21:36 +0000 (08:21 +1100)]
Remove `MatcherPos::stack`.

`parse_tt` needs a way to get from within submatchers make to the
enclosing submatchers. Currently it has two distinct mechanisms for
this:
- `Delimited` submatchers use `MatcherPos::stack` to record stuff about
  the parent (and further back ancestors).
- `Sequence` submatchers use `MatcherPosSequence::parent` to point to
  the parent matcher position.

Having two mechanisms is really confusing, and it took me a long time to
understand all this.

This commit eliminates `MatcherPos::stack`, and changes `Delimited`
submatchers to use the same mechanism as sequence submatchers. That
mechanism is also changed a bit: instead of storing the entire parent
`MatcherPos`, we now only store the necessary parts from the parent
`MatcherPos`.

Overall this is a small performance win, with the positives outweighing
the negatives, but it's mostly for clarity.

2 years agoRollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errors
Dylan DPC [Thu, 31 Mar 2022 02:57:28 +0000 (04:57 +0200)]
Rollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errors

Spellchecking compiler comments

This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.

2 years agoRollup merge of #95491 - faern:stabilize-vec_retain_mut, r=yaahc
Dylan DPC [Thu, 31 Mar 2022 02:57:27 +0000 (04:57 +0200)]
Rollup merge of #95491 - faern:stabilize-vec_retain_mut, r=yaahc

Stabilize feature vec_retain_mut on Vec and VecDeque

Closes #90829

2 years agoRollup merge of #95471 - oli-obk:tait_ice, r=estebank
Dylan DPC [Thu, 31 Mar 2022 02:57:26 +0000 (04:57 +0200)]
Rollup merge of #95471 - oli-obk:tait_ice, r=estebank

Don't ICE when opaque types get their hidden type constrained again.

Contrary to popular belief, `codegen_fulfill_obligation` does not get used solely in codegen, so we cannot rely on `param_env` being set to RevealAll and thus revealing the hidden types instead of constraining them.

Fixes #89312 (for real this time)

2 years agoRollup merge of #95263 - compiler-errors:async-block-pretty, r=jackh726
Dylan DPC [Thu, 31 Mar 2022 02:57:25 +0000 (04:57 +0200)]
Rollup merge of #95263 - compiler-errors:async-block-pretty, r=jackh726

Restore `impl Future<Output = Type>` to async blocks

I was sad when I undid some of the code I wrote in #91096 in the PR #95225, so I fixed it here to not print `[async output]`.

This PR "manually" normalizes the associated type `<[generator] as Generator>::Return` type which appears very frequently in `impl Future` types that result from async block desugaring.

2 years agoRollup merge of #95130 - workingjubilee:stably-finished, r=m-ou-se
Dylan DPC [Thu, 31 Mar 2022 02:57:25 +0000 (04:57 +0200)]
Rollup merge of #95130 - workingjubilee:stably-finished, r=m-ou-se

Stabilize thread::is_finished

Closes #90470.

r? `@m-ou-se`

2 years agoRestore `impl Future<Output = Type>` to async blocks
Michael Goulet [Thu, 31 Mar 2022 02:26:35 +0000 (19:26 -0700)]
Restore `impl Future<Output = Type>` to async blocks

2 years agoFix library/std compilation on openbsd.
Dan Gohman [Thu, 31 Mar 2022 01:06:21 +0000 (18:06 -0700)]
Fix library/std compilation on openbsd.

Fix a minor typo from #95241 which prevented compilation on x86_64-unknown-openbsd.

2 years agoClarify `idx` handling in sequences.
Nicholas Nethercote [Wed, 30 Mar 2022 20:00:07 +0000 (07:00 +1100)]
Clarify `idx` handling in sequences.

By adding comments, and improving an assertion. I finally fully
understand this part!

2 years agoRemove `MatcherPos::match_lo`.
Nicholas Nethercote [Wed, 30 Mar 2022 05:30:35 +0000 (16:30 +1100)]
Remove `MatcherPos::match_lo`.

It's redundant w.r.t. other fields.

2 years agoSimplify exit of `Delimited` submatchers.
Nicholas Nethercote [Wed, 30 Mar 2022 00:21:32 +0000 (11:21 +1100)]
Simplify exit of `Delimited` submatchers.

Currently, we detect an exit from a `Delimited` submatcher when `idx`
exceeds the bounds of the current submatcher *and* there is a `stack`
entry.

This commit changes it to something simpler: just look for a
`CloseDelim` token.

2 years agoAuto merge of #95501 - Dylan-DPC:rollup-arx6sdc, r=Dylan-DPC
bors [Thu, 31 Mar 2022 00:29:54 +0000 (00:29 +0000)]
Auto merge of #95501 - Dylan-DPC:rollup-arx6sdc, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #93901 (Stabilize native library modifier syntax and the `whole-archive` modifier specifically)
 - #94806 (Fix `cargo run tidy`)
 - #94869 (Add the generic_associated_types_extended feature)
 - #95011 (async: Give predictable name to binding generated from .await expressions.)
 - #95251 (Reduce max hash in raw strings from u16 to u8)
 - #95298 (Fix double drop of allocator in IntoIter impl of Vec)

Failed merges:

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

2 years agoRollup merge of #95298 - jhorstmann:fix-double-drop-of-allocator-in-vec-into-iter...
Dylan DPC [Wed, 30 Mar 2022 22:26:32 +0000 (00:26 +0200)]
Rollup merge of #95298 - jhorstmann:fix-double-drop-of-allocator-in-vec-into-iter, r=oli-obk

Fix double drop of allocator in IntoIter impl of Vec

Fixes #95269

The `drop` impl of `IntoIter` reconstructs a `RawVec` from `buf`, `cap` and `alloc`, when that `RawVec` is dropped it also drops the allocator. To avoid dropping the allocator twice we wrap it in `ManuallyDrop` in the `InttoIter` struct.

Note this is my first contribution to the standard library, so I might be missing some details or a better way to solve this.

2 years agoRollup merge of #95251 - GrishaVar:hashes-u16-to-u8, r=dtolnay
Dylan DPC [Wed, 30 Mar 2022 22:26:31 +0000 (00:26 +0200)]
Rollup merge of #95251 - GrishaVar:hashes-u16-to-u8, r=dtolnay

Reduce max hash in raw strings from u16 to u8

[Relevant discussion](https://rust-lang.zulipchat.com/#narrow/stream/237824-t-lang.2Fdoc/topic/Max.20raw.20string.20delimiters)

2 years agoRollup merge of #95011 - michaelwoerister:awaitee_field, r=tmandry
Dylan DPC [Wed, 30 Mar 2022 22:26:30 +0000 (00:26 +0200)]
Rollup merge of #95011 - michaelwoerister:awaitee_field, r=tmandry

async: Give predictable name to binding generated from .await expressions.

This name makes it to debuginfo and allows debuggers to identify such bindings and their captured versions in suspended async fns.

This will be useful for async stack traces, as discussed in https://internals.rust-lang.org/t/async-debugging-logical-stack-traces-setting-goals-collecting-examples/15547.

I don't know if this needs some discussion by ````@rust-lang/compiler,```` e.g. about the name of the binding (`__awaitee`) or about the fact that this PR introduces a (soft) guarantee about a compiler generated name. Although, regarding the later, I think the same reasoning applies here as it does for debuginfo in general.

r? ````@tmandry````

2 years agoRollup merge of #94869 - jackh726:gats_extended, r=compiler-errors
Dylan DPC [Wed, 30 Mar 2022 22:26:29 +0000 (00:26 +0200)]
Rollup merge of #94869 - jackh726:gats_extended, r=compiler-errors

Add the generic_associated_types_extended feature

Right now, this only ignore obligations that reference new placeholders in `poly_project_and_unify_type`. In the future, this might do other things, like allowing object-safe GATs.

**This feature is *incomplete* and quite likely unsound. This is mostly just for testing out potential future APIs using a "relaxed" set of rules until we figure out *proper* rules.**

Also drive by cleanup of adding a `ProjectAndUnifyResult` enum instead of using a `Result<Result<Option>>`.

r? `@nikomatsakis`

2 years agoRollup merge of #94806 - jyn514:cargo-run-tidy, r=Mark-Simulacrum
Dylan DPC [Wed, 30 Mar 2022 22:26:28 +0000 (00:26 +0200)]
Rollup merge of #94806 - jyn514:cargo-run-tidy, r=Mark-Simulacrum

Fix `cargo run tidy`

When I implemented rust-only bootstrapping in https://github.com/rust-lang/rust/pull/92260,
I neglected to test stage0 tools - it turns out they were broken because
they couldn't find the sysroot of the initial bootstrap compiler.

This fixes stage0 tools by using `rustc --print sysroot` instead of assuming rustc is already in a
sysroot and hard-coding the relative directory.

Fixes https://github.com/rust-lang/rust/issues/94797 (properly, without having to change rustup).

2 years agoRollup merge of #93901 - petrochenkov:linkmod, r=wesleywiser
Dylan DPC [Wed, 30 Mar 2022 22:26:28 +0000 (00:26 +0200)]
Rollup merge of #93901 - petrochenkov:linkmod, r=wesleywiser

Stabilize native library modifier syntax and the `whole-archive` modifier specifically

Stabilization report: https://github.com/rust-lang/rust/pull/93901#issuecomment-1041325522

cc https://github.com/rust-lang/rust/issues/81490

2 years agoAuto merge of #95436 - cjgillot:static-mut, r=oli-obk
bors [Wed, 30 Mar 2022 22:09:56 +0000 (22:09 +0000)]
Auto merge of #95436 - cjgillot:static-mut, r=oli-obk

Remember mutability in `DefKind::Static`.

This allows to compute the `BodyOwnerKind` from `DefKind` only, and
removes a direct dependency of some MIR queries onto HIR.

As a side effect, it also simplifies metadata, since we don't need 4
flavours of `EntryKind::*Static` any more.

2 years agoAdd the generic_associated_types_extended feature
Jack Huey [Fri, 11 Mar 2022 23:46:49 +0000 (18:46 -0500)]
Add the generic_associated_types_extended feature

2 years agoa few mode feedback fixes per @bjorn3
Yuri Astrakhan [Wed, 30 Mar 2022 21:28:19 +0000 (17:28 -0400)]
a few mode feedback fixes per @bjorn3

2 years agoAddressed comments by @compiler-errors and @bjorn3
Yuri Astrakhan [Wed, 30 Mar 2022 21:04:46 +0000 (17:04 -0400)]
Addressed comments by @compiler-errors and @bjorn3

2 years agoStabilize native library modifier syntax and the `whole-archive` modifier specifically
Vadim Petrochenkov [Fri, 11 Feb 2022 07:08:35 +0000 (15:08 +0800)]
Stabilize native library modifier syntax and the `whole-archive` modifier specifically

2 years agoRemove bad rustdoc trailing backslash
Yuri Astrakhan [Wed, 30 Mar 2022 19:50:27 +0000 (15:50 -0400)]
Remove bad rustdoc trailing backslash

2 years agoSpellchecking compiler comments
Yuri Astrakhan [Wed, 30 Mar 2022 19:14:15 +0000 (15:14 -0400)]
Spellchecking compiler comments

This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.

2 years agoRemove unneeded `to_string` call
Guillaume Gomez [Wed, 30 Mar 2022 19:13:15 +0000 (21:13 +0200)]
Remove unneeded `to_string` call

2 years agoAuto merge of #95425 - nnethercote:yet-more-parse_tt-improvements, r=petrochenkov
bors [Wed, 30 Mar 2022 19:08:01 +0000 (19:08 +0000)]
Auto merge of #95425 - nnethercote:yet-more-parse_tt-improvements, r=petrochenkov

Yet more `parse_tt` improvements

Including lots of comment improvements, and an overhaul of how `matches` work that gives big speedups.

r? `@petrochenkov`

2 years agoStabilize feature vec_retain_mut on Vec and VecDeque
Linus Färnstrand [Wed, 30 Mar 2022 05:48:48 +0000 (07:48 +0200)]
Stabilize feature vec_retain_mut on Vec and VecDeque

2 years agoAdd note to the lint diagnostic
InfRandomness [Wed, 30 Mar 2022 15:53:29 +0000 (17:53 +0200)]
Add note to the lint diagnostic

2 years agoOnly show associated consts from inherent impls in sidebar
Jules Bertholet [Wed, 30 Mar 2022 14:37:55 +0000 (10:37 -0400)]
Only show associated consts from inherent impls in sidebar

2 years agoUpdate error message & remove outdated test comment
Grisha Vartanyan [Wed, 30 Mar 2022 16:20:30 +0000 (18:20 +0200)]
Update error message & remove outdated test comment

2 years agoAuto merge of #95458 - calebcartwright:sync-rustfmt-subtree, r=calebcartwright
bors [Wed, 30 Mar 2022 15:57:58 +0000 (15:57 +0000)]
Auto merge of #95458 - calebcartwright:sync-rustfmt-subtree, r=calebcartwright

Sync rustfmt subtree

r? `@calebcartwright`

2 years agoDon't ICE when opaque types get their hidden type constrained again.
Oli Scherer [Wed, 30 Mar 2022 13:17:46 +0000 (13:17 +0000)]
Don't ICE when opaque types get their hidden type constrained again.

Contrary to popular belief, `codegen_fulfill_obligation` does not get used solely in codegen, so we cannot rely on `param_env` being set to RevealAll and thus revealing the hidden types instead of constraining them.

2 years agoFix last rustdoc-gui spurious test
Guillaume Gomez [Wed, 30 Mar 2022 12:30:46 +0000 (14:30 +0200)]
Fix last rustdoc-gui spurious test

2 years agoAuto merge of #94963 - lcnr:inherent-impls-std, r=oli-obk,m-ou-se
bors [Wed, 30 Mar 2022 12:28:50 +0000 (12:28 +0000)]
Auto merge of #94963 - lcnr:inherent-impls-std, r=oli-obk,m-ou-se

allow arbitrary inherent impls for builtin types in core

Part of https://github.com/rust-lang/compiler-team/issues/487. Slightly adjusted after some talks with `@m-ou-se` about the requirements of `t-libs-api`.

This adds a crate attribute `#![rustc_coherence_is_core]` which allows arbitrary impls for builtin types in core.

For other library crates impls for builtin types should be avoided if possible. We do have to allow the existing stable impls however. To prevent us from accidentally adding more of these in the future, there is a second attribute `#[rustc_allow_incoherent_impl]` which has to be added to **all impl items**. This only supports impls for builtin types but can easily be extended to additional types in a future PR.

This implementation does not check for overlaps in these impls. Perfectly checking that requires us to check the coherence of these incoherent impls in every crate, as two distinct dependencies may add overlapping methods. It should be easy enough to detect if it goes wrong and the attribute is only intended for use inside of std.

The first two commits are mostly unrelated cleanups.

2 years agoDon't stabilize ScopedJoinHandle::is_finished yet.
Mara Bos [Wed, 30 Mar 2022 11:59:27 +0000 (13:59 +0200)]
Don't stabilize ScopedJoinHandle::is_finished yet.

2 years agoAuto merge of #95241 - Gankra:cleaned-provenance, r=workingjubilee
bors [Wed, 30 Mar 2022 10:09:10 +0000 (10:09 +0000)]
Auto merge of #95241 - Gankra:cleaned-provenance, r=workingjubilee

Strict Provenance MVP

This patch series examines the question: how bad would it be if we adopted
an extremely strict pointer provenance model that completely banished all
int<->ptr casts.

The key insight to making this approach even *vaguely* pallatable is the

ptr.with_addr(addr) -> ptr

function, which takes a pointer and an address and creates a new pointer
with that address and the provenance of the input pointer. In this way
the "chain of custody" is completely and dynamically restored, making the
model suitable even for dynamic checkers like CHERI and Miri.

This is not a formal model, but lots of the docs discussing the model
have been updated to try to the *concept* of this design in the hopes
that it can be iterated on.

See #95228

2 years agoclippy: nameres for primitive type impls
lcnr [Wed, 30 Mar 2022 09:57:53 +0000 (11:57 +0200)]
clippy: nameres for primitive type impls

2 years agotypo
lcnr [Wed, 30 Mar 2022 09:24:26 +0000 (11:24 +0200)]
typo

2 years agorework error messages for incorrect inherent impls
lcnr [Tue, 29 Mar 2022 07:47:32 +0000 (09:47 +0200)]
rework error messages for incorrect inherent impls

2 years agofix rustdoc wrt builtin impls switch
lcnr [Fri, 18 Mar 2022 16:02:32 +0000 (17:02 +0100)]
fix rustdoc wrt builtin impls switch

2 years agoget clippy to compile again
lcnr [Fri, 18 Mar 2022 12:33:40 +0000 (13:33 +0100)]
get clippy to compile again