]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoreview comment and one more test
Vishnunarayan K I [Tue, 1 Dec 2020 14:42:22 +0000 (20:12 +0530)]
review comment and one more test

3 years agoreview comments
Vishnunarayan K I [Tue, 1 Dec 2020 14:18:09 +0000 (19:48 +0530)]
review comments

3 years agoadd const_allocate intrisic
Vishnunarayan K I [Tue, 1 Dec 2020 10:09:25 +0000 (15:39 +0530)]
add const_allocate intrisic

3 years agoAuto merge of #76467 - jyn514:intra-link-self, r=Manishearth
bors [Mon, 30 Nov 2020 09:00:52 +0000 (09:00 +0000)]
Auto merge of #76467 - jyn514:intra-link-self, r=Manishearth

Fix intra-doc links for `Self` on cross-crate items and primitives

- Remove the difference between `parent_item` and `current_item`; these
  should never have been different.
- Remove `current_item` from `resolve` and `variant_field` so that
  `Self` is only substituted in one place at the very start.
- Resolve the current item as a `DefId`, not a `HirId`. This is what
  actually fixed the bug.

Hacks:
- `clean` uses `TypedefItem` when it _really_ should be
  `AssociatedTypeItem`. I tried fixing this without success and hacked
  around it instead (see comments)
- This second-guesses the `to_string()` impl since it wants
  fully-qualified paths. Possibly there's a better way to do this.

3 years agoAuto merge of #79329 - camelid:int-lit-suffix-error, r=davidtwco
bors [Mon, 30 Nov 2020 01:42:14 +0000 (01:42 +0000)]
Auto merge of #79329 - camelid:int-lit-suffix-error, r=davidtwco

Update error to reflect that integer literals can have float suffixes

For example, `1` is parsed as an integer literal, but it can be turned
into a float with the suffix `f32`. Now the error calls them "numeric
literals" and notes that you can add a float suffix since they can be
either integers or floats.

3 years agoAuto merge of #78122 - fusion-engineering-forks:fmt-write-bounds-check, r=Mark-Simulacrum
bors [Sun, 29 Nov 2020 23:14:40 +0000 (23:14 +0000)]
Auto merge of #78122 - fusion-engineering-forks:fmt-write-bounds-check, r=Mark-Simulacrum

Avoid panic_bounds_check in fmt::write.

Writing any fmt::Arguments would trigger the inclusion of usize formatting and padding code in the resulting binary, because indexing used in fmt::write would generate code using panic_bounds_check, which prints the index and length.

These bounds checks are not necessary, as fmt::Arguments never contains any out-of-bounds indexes.

This change replaces them with unsafe get_unchecked, to reduce the amount of generated code, which is especially important for embedded targets.

---

Demonstration of the size of and the symbols in a 'hello world' no_std binary:

<details>
<summary>Source code</summary>

```rust
#![feature(lang_items)]
#![feature(start)]
#![no_std]

use core::fmt;
use core::fmt::Write;

#[link(name = "c")]
extern "C" {
    #[allow(improper_ctypes)]
    fn write(fd: i32, s: &str) -> isize;
    fn exit(code: i32) -> !;
}

struct Stdout;

impl fmt::Write for Stdout {
    fn write_str(&mut self, s: &str) -> fmt::Result {
        unsafe { write(1, s) };
        Ok(())
    }
}

#[start]
fn main(_argc: isize, _argv: *const *const u8) -> isize {
    let _ = writeln!(Stdout, "Hello World");
    0
}

#[lang = "eh_personality"]
fn eh_personality() {}

#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! {
    unsafe { exit(1) };
}
```
</details>

Before:
```
   text    data     bss     dec     hex filename
   6059     736       8    6803    1a93 before
```
```
0000000000001e00 T <T as core::any::Any>::type_id
0000000000003dd0 D core::fmt::num::DEC_DIGITS_LUT
0000000000001ce0 T core::fmt::num::imp::<impl core::fmt::Display for u64>::fmt
0000000000001ce0 T core::fmt::num::imp::<impl core::fmt::Display for usize>::fmt
0000000000001370 T core::fmt::write
0000000000001b30 t core::fmt::Formatter::pad_integral::write_prefix
0000000000001660 T core::fmt::Formatter::pad_integral
0000000000001350 T core::ops::function::FnOnce::call_once
0000000000001b80 t core::ptr::drop_in_place
0000000000001120 t core::ptr::drop_in_place
0000000000001c50 t core::iter::adapters::zip::Zip<A,B>::new
0000000000001c90 t core::iter::adapters::zip::Zip<A,B>::new
0000000000001b90 T core::panicking::panic_bounds_check
0000000000001c10 T core::panicking::panic_fmt
0000000000001130 t <&mut W as core::fmt::Write>::write_char
0000000000001200 t <&mut W as core::fmt::Write>::write_fmt
0000000000001250 t <&mut W as core::fmt::Write>::write_str
```

After:
```
   text    data     bss     dec     hex filename
   3068     600       8    3676     e5c after
```
```
0000000000001360 T core::fmt::write
0000000000001340 T core::ops::function::FnOnce::call_once
0000000000001120 t core::ptr::drop_in_place
0000000000001620 t core::iter::adapters::zip::Zip<A,B>::new
0000000000001660 t core::iter::adapters::zip::Zip<A,B>::new
0000000000001130 t <&mut W as core::fmt::Write>::write_char
0000000000001200 t <&mut W as core::fmt::Write>::write_fmt
0000000000001250 t <&mut W as core::fmt::Write>::write_str
```

3 years agoAuto merge of #79209 - spastorino:trait-inheritance-self, r=nikomatsakis
bors [Sun, 29 Nov 2020 21:04:23 +0000 (21:04 +0000)]
Auto merge of #79209 - spastorino:trait-inheritance-self, r=nikomatsakis

Allow Trait inheritance with cycles on associated types

Fixes #35237

r? `@nikomatsakis`

cc `@estebank`

3 years agoAdd test for cross-crate Self
Joshua Nelson [Sun, 29 Nov 2020 18:49:44 +0000 (13:49 -0500)]
Add test for cross-crate Self

3 years agoAuto merge of #79523 - Nadrieril:fix-usize-ranges, r=varkor
bors [Sun, 29 Nov 2020 18:50:19 +0000 (18:50 +0000)]
Auto merge of #79523 - Nadrieril:fix-usize-ranges, r=varkor

Fix overlap detection of `usize`/`isize` range patterns

`usize` and `isize` are a bit of a special case in the match usefulness algorithm, because the range of values they contain depends on the platform. Specifically, we don't want `0..usize::MAX` to count as an exhaustive match (see also [`precise_pointer_size_matching`](https://github.com/rust-lang/rust/issues/56354)). The way this was initially implemented is by treating those ranges like float ranges, i.e. with limited cleverness. This means we didn't catch the following as unreachable:
```rust
match 0usize {
    0..10 => {},
    10..20 => {},
    5..15 => {}, // oops, should be detected as unreachable
    _ => {},
}
```
This PRs fixes this oversight. Now the only difference between `usize` and `u64` range patterns is in what ranges count as exhaustive.

r? `@varkor`
`@rustbot` label +A-exhaustiveness-checking

3 years agoRemove `TypeKind` hack in favor of `with_crate_prefix`
Joshua Nelson [Sun, 29 Nov 2020 18:37:43 +0000 (13:37 -0500)]
Remove `TypeKind` hack in favor of `with_crate_prefix`

3 years agoFix intra-doc links for `Self` on primitives
Joshua Nelson [Tue, 8 Sep 2020 04:07:40 +0000 (00:07 -0400)]
Fix intra-doc links for `Self` on primitives

- Remove the difference between `parent_item` and `current_item`; these
  should never have been different.
- Remove `current_item` from `resolve` and `variant_field` so that
  `Self` is only substituted in one place at the very start.
- Resolve the current item as a `DefId`, not a `HirId`. This is what
  actually fixed the bug.

Hacks:
- `clean` uses `TypedefItem` when it _really_ should be
  `AssociatedTypeItem`. I tried fixing this without success and hacked
  around it instead (see comments)
- This stringifies DefIds, then resolves them a second time. This is
  really silly and rustdoc should just use DefIds throughout. Fixing
  this is a larger task than I want to take on right now.

3 years agoAuto merge of #79482 - faern:bump-dependencies-invalidly-assuming-mem-layout, r=Mark...
bors [Sun, 29 Nov 2020 16:39:23 +0000 (16:39 +0000)]
Auto merge of #79482 - faern:bump-dependencies-invalidly-assuming-mem-layout, r=Mark-Simulacrum

Bump dependencies invalidly assuming memory layout of SocketAddr

Bumps net2, socket2 and miow.
Helps unblock #78802

Done as separate PR since frequent lockfile collisions is a thing... And since the main PR can't be merged until large parts of the ecosystem uses the newer crates only, so we have to start somewhere.

3 years agoAuto merge of #78380 - bstrie:rm-old-num-const-from-tests, r=jyn514
bors [Sun, 29 Nov 2020 14:29:23 +0000 (14:29 +0000)]
Auto merge of #78380 - bstrie:rm-old-num-const-from-tests, r=jyn514

Update tests to remove old numeric constants

Part of #68490.

Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros.

For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.

3 years agoAuto merge of #77616 - jyn514:no-normalize, r=lcnr
bors [Sun, 29 Nov 2020 11:37:44 +0000 (11:37 +0000)]
Auto merge of #77616 - jyn514:no-normalize, r=lcnr

Don't run `resolve_vars_if_possible` in `normalize_erasing_regions`

Neither `@eddyb` nor I could figure out what this was for. I changed it to `assert_eq!(normalized_value, infcx.resolve_vars_if_possible(&normalized_value));` and it passed the UI test suite.

<details><summary>

Outdated, I figured out the issue - `needs_infer()` needs to come _after_ erasing the lifetimes

</summary>

Strangely, if I change it to `assert!(!normalized_value.needs_infer())` it panics almost immediately:

```
query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `<str::IsWhitespace as str::pattern::Pattern>::Searcher`
#1 [needs_drop_raw] computing whether `str::iter::Split<str::IsWhitespace>` needs drop
#2 [mir_built] building MIR for `str::<impl str>::split_whitespace`
#3 [unsafety_check_result] unsafety-checking `str::<impl str>::split_whitespace`
#4 [mir_const] processing MIR for `str::<impl str>::split_whitespace`
#5 [mir_promoted] processing `str::<impl str>::split_whitespace`
#6 [mir_borrowck] borrow-checking `str::<impl str>::split_whitespace`
#7 [analysis] running analysis passes on this crate
end of query stack
```

I'm not entirely sure what's going on - maybe the two disagree?

</details>

For context, this came up while reviewing https://github.com/rust-lang/rust/pull/77467/ (cc `@lcnr).`

Possibly this needs a crater run?

r? `@nikomatsakis`
cc `@matthewjasper`

3 years agoAdd test to check for fmt::write bloat.
Mara Bos [Tue, 20 Oct 2020 18:20:31 +0000 (20:20 +0200)]
Add test to check for fmt::write bloat.

It checks that fmt::write by itself doesn't pull in any panicking or
or display code.

3 years agoBump dependencies invalidly assuming memory layout of SocketAddr
Linus Färnstrand [Fri, 27 Nov 2020 23:56:12 +0000 (00:56 +0100)]
Bump dependencies invalidly assuming memory layout of SocketAddr

Bumps net2, socket2 and miow.
Helps unblock https://github.com/rust-lang/rust/pull/78802

3 years agoAuto merge of #78863 - KodrAus:feat/simd-array, r=oli-obk
bors [Sun, 29 Nov 2020 09:28:09 +0000 (09:28 +0000)]
Auto merge of #78863 - KodrAus:feat/simd-array, r=oli-obk

Support repr(simd) on ADTs containing a single array field

This is a squash and rebase of `@gnzlbg's` #63531

I've never actually written code in the compiler before so just fumbled my way around until it would build 😅

I imagine there'll be some work we need to do in `rustc_codegen_cranelift` too for this now, but might need some input from `@bjorn3` to know what that is.

cc `@rust-lang/project-portable-simd`

-----

This PR allows using `#[repr(simd)]` on ADTs containing a single array field:

```rust
 #[repr(simd)] struct S0([f32; 4]);
 #[repr(simd)] struct S1<const N: usize>([f32; N]);
 #[repr(simd)] struct S2<T, const N: usize>([T; N]);
```

This should allow experimenting with portable packed SIMD abstractions on nightly that make use of const generics.

3 years agoargs may be passed by value
Ashley Mannix [Sun, 29 Nov 2020 08:36:30 +0000 (18:36 +1000)]
args may be passed by value

3 years agoAuto merge of #79455 - CraftSpider:master, r=jyn514
bors [Sun, 29 Nov 2020 07:05:49 +0000 (07:05 +0000)]
Auto merge of #79455 - CraftSpider:master, r=jyn514

Remove doctree::Macro and distinguish between `macro_rules!` and `pub macro`

This is a part of #78082, removing doctree::Macro. Uses the changes in #79372

Fixes #76761

3 years agoUpdate tests to remove old numeric constants
bstrie [Sat, 24 Oct 2020 23:21:40 +0000 (19:21 -0400)]
Update tests to remove old numeric constants

Part of #68490.

Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros.

For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.

3 years agoAuto merge of #75752 - jakoschiko:test-suite-time, r=m-ou-se
bors [Sun, 29 Nov 2020 04:54:20 +0000 (04:54 +0000)]
Auto merge of #75752 - jakoschiko:test-suite-time, r=m-ou-se

libtest: Print the total time taken to execute a test suite

Print the total time taken to execute a test suite by default, without any kind of flag.

Closes #75660

# Example
```
anon@anon:~/code/rust/example$ cargo test
   Compiling example v0.1.0 (/home/anon/code/rust/example)
    Finished test [unoptimized + debuginfo] target(s) in 0.18s
     Running target/debug/deps/example-745b64d3885c3565

running 3 tests
test tests::foo ... ok
test tests::bar ... ok
test tests::baz ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; 1.2s

   Doc-tests example

running 3 tests
test src/lib.rs - foo (line 3) ... ok
test src/lib.rs - bar (line 11) ... ok
test src/lib.rs - baz (line 19) ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; 1.3s
```

```
anon@anon:~/code/rust/example$ cargo test -- --format terse
    Finished test [unoptimized + debuginfo] target(s) in 0.08s
     Running target/debug/deps/example-745b64d3885c3565

running 3 tests
...
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; 1.2s

   Doc-tests example

running 3 tests
...
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; 1.3s
```

```
anon@anon:~/code/rust/example$ cargo test -- --format json -Z unstable-options
   Compiling example v0.1.0 (/home/anon/code/rust/example)
    Finished test [unoptimized + debuginfo] target(s) in 0.25s
     Running target/debug/deps/example-745b64d3885c3565
{ "type": "suite", "event": "started", "test_count": 3 }
{ "type": "test", "event": "started", "name": "tests::bar" }
{ "type": "test", "event": "started", "name": "tests::baz" }
{ "type": "test", "event": "started", "name": "tests::foo" }
{ "type": "test", "name": "tests::foo", "event": "ok" }
{ "type": "test", "name": "tests::bar", "event": "ok" }
{ "type": "test", "name": "tests::baz", "event": "ok" }
{ "type": "suite", "event": "ok", "passed": 3, "failed": 0, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": "1.2s" }
   Doc-tests example
{ "type": "suite", "event": "started", "test_count": 3 }
{ "type": "test", "event": "started", "name": "src/lib.rs - bar (line 11)" }
{ "type": "test", "event": "started", "name": "src/lib.rs - baz (line 19)" }
{ "type": "test", "event": "started", "name": "src/lib.rs - foo (line 3)" }
{ "type": "test", "name": "src/lib.rs - foo (line 3)", "event": "ok" }
{ "type": "test", "name": "src/lib.rs - bar (line 11)", "event": "ok" }
{ "type": "test", "name": "src/lib.rs - baz (line 19)", "event": "ok" }
{ "type": "suite", "event": "ok", "passed": 3, "failed": 0, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": "1.3s" }
```

3 years agoAuto merge of #79529 - Dylan-DPC:rollup-6k20msr, r=Dylan-DPC
bors [Sun, 29 Nov 2020 02:45:48 +0000 (02:45 +0000)]
Auto merge of #79529 - Dylan-DPC:rollup-6k20msr, r=Dylan-DPC

Rollup of 11 pull requests

Successful merges:

 - #79327 (Require allocator to be static for boxed `Pin`-API)
 - #79340 (Rename "stability" CSS class to "item-info" and combine `document_stability` with `document_short`)
 - #79363 (BTreeMap: try to enhance various comments)
 - #79395 (Move ui if tests from top-level into `expr/if`)
 - #79443 (Improve rustdoc JS tests error output)
 - #79464 (Extend doc keyword feature by allowing any ident)
 - #79484 (add enable-full-tools to freebsd builds to prevent occasional link er…)
 - #79505 (Cleanup: shorter and faster code)
 - #79514 (Add test for issue #54121: order dependent trait bounds)
 - #79516 (Remove unnecessary `mut` binding)
 - #79528 (Fix a bootstrap comment)

Failed merges:

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

3 years agoAdd test for macro by example syntax in decl macros with only one option
Rune Tynan [Sun, 29 Nov 2020 02:32:07 +0000 (21:32 -0500)]
Add test for macro by example syntax in decl macros with only one option

3 years agoRollup merge of #79528 - nooberfsh:fix_doc, r=Mark-Simulacrum
Dylan DPC [Sun, 29 Nov 2020 02:14:29 +0000 (03:14 +0100)]
Rollup merge of #79528 - nooberfsh:fix_doc, r=Mark-Simulacrum

Fix a bootstrap comment

3 years agoRollup merge of #79516 - jyn514:cleanup-trait-solver, r=Aaron1011
Dylan DPC [Sun, 29 Nov 2020 02:14:27 +0000 (03:14 +0100)]
Rollup merge of #79516 - jyn514:cleanup-trait-solver, r=Aaron1011

Remove unnecessary `mut` binding

Found while fiddling around with https://github.com/rust-lang/rust/issues/77459.

3 years agoRollup merge of #79514 - Julian-Wollersberger:order-dependent-bounds, r=Mark-Simulacrum
Dylan DPC [Sun, 29 Nov 2020 02:14:26 +0000 (03:14 +0100)]
Rollup merge of #79514 - Julian-Wollersberger:order-dependent-bounds, r=Mark-Simulacrum

Add test for issue #54121: order dependent trait bounds

This adds a test for #54121, which has already been fixed by #73905. Now that issue can be closed.

I tested the test [on the playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6cb061d3b81518f268649551eb67769f) where it indeed fails on stable 1.48, but compiles successfully on beta and nightly.

fixes #54121

3 years agoRollup merge of #79505 - matklad:cleanup, r=jonas-schievink
Dylan DPC [Sun, 29 Nov 2020 02:14:24 +0000 (03:14 +0100)]
Rollup merge of #79505 - matklad:cleanup, r=jonas-schievink

Cleanup: shorter and faster code

3 years agoRollup merge of #79484 - sreehax:master, r=Mark-Simulacrum
Dylan DPC [Sun, 29 Nov 2020 02:14:22 +0000 (03:14 +0100)]
Rollup merge of #79484 - sreehax:master, r=Mark-Simulacrum

add enable-full-tools to freebsd builds to prevent occasional link er…

On FreeBSD, there is sometimes an issue where linking a rust program will fail due to rust not finding a linker, even though lld is included in the base system. This seems to mostly affect bare metal/cross compilation things, such as wasm builds and arm/riscv bare metal work (eg. when trying to compile [this](https://github.com/quantumscraps/scraps)). On Linux and other operating systems, full tools are enabled for builds of rust, so there are no linking issues. This pr should enable fully functional builds on FreeBSD, assuming rust builds correctly with these options.

3 years agoRollup merge of #79464 - GuillaumeGomez:doc-keyword-ident, r=jyn514
Dylan DPC [Sun, 29 Nov 2020 02:14:21 +0000 (03:14 +0100)]
Rollup merge of #79464 - GuillaumeGomez:doc-keyword-ident, r=jyn514

Extend doc keyword feature by allowing any ident

Part of #51315.

As suggested by ``@danielhenrymantilla`` in [this comment](https://github.com/rust-lang/rust/issues/51315#issuecomment-733879934), this PR extends `#[doc(keyword = "...")]` to allow any ident to be used as keyword. The final goal is to allow (proc-)macro crates' owners to write documentation of the keywords they might introduce.

r? ``@jyn514``

3 years agoRollup merge of #79443 - GuillaumeGomez:improve-rustdoc-js-error-output, r=jyn514
Dylan DPC [Sun, 29 Nov 2020 02:14:19 +0000 (03:14 +0100)]
Rollup merge of #79443 - GuillaumeGomez:improve-rustdoc-js-error-output, r=jyn514

Improve rustdoc JS tests error output

It's pretty common when starting to add new tests for rustdoc-js to have issues to understand the errors. With this, it should make things a bit simpler. So now, in case of an error, it displays:

```
---- [js-doc-test] rustdoc-js/basic.rs stdout ----

error: rustdoc-js test failed!
failed to decode compiler output as json: line: {
output: Checking "basic" ... FAILED
==> Result not found in 'others': '{"path":"basic","name":"Fo"}'
Diff of first error:
{
    "path": "basic",
    - "name": "Fo",
    + "name": "Foo",
}
thread '[js-doc-test] rustdoc-js/basic.rs' panicked at 'explicit panic', src/tools/compiletest/src/json.rs:126:21
```

I think it was ``@camelid`` who asked about it a few days ago?

r? ``@jyn514``

3 years agoRollup merge of #79395 - Havvy:test-move-if, r=Mark-Simulacrum
Dylan DPC [Sun, 29 Nov 2020 02:14:17 +0000 (03:14 +0100)]
Rollup merge of #79395 - Havvy:test-move-if, r=Mark-Simulacrum

Move ui if tests from top-level into `expr/if`

This lowers the number of top-level files in src/test/ui from 1612 to 1604.

3 years agoRollup merge of #79363 - ssomers:btree_cleanup_comments, r=Mark-Simulacrum
Dylan DPC [Sun, 29 Nov 2020 02:14:15 +0000 (03:14 +0100)]
Rollup merge of #79363 - ssomers:btree_cleanup_comments, r=Mark-Simulacrum

BTreeMap: try to enhance various comments

All in internal documentation, propagating the "key-value pair" notation from public documentation.

r? ``@Mark-Simulacrum``

3 years agoRollup merge of #79340 - GuillaumeGomez:rename-stability, r=jyn514
Dylan DPC [Sun, 29 Nov 2020 02:14:13 +0000 (03:14 +0100)]
Rollup merge of #79340 - GuillaumeGomez:rename-stability, r=jyn514

Rename "stability" CSS class to "item-info" and combine `document_stability` with `document_short`

Follow-up of #79300

The point of this PR is to make the CSS class more accurate since it's not only about stability anymore.

r? ``@jyn514``

3 years agoRollup merge of #79327 - TimDiekmann:static-alloc-pin-in-box, r=Mark-Simulacrum
Dylan DPC [Sun, 29 Nov 2020 02:14:07 +0000 (03:14 +0100)]
Rollup merge of #79327 - TimDiekmann:static-alloc-pin-in-box, r=Mark-Simulacrum

Require allocator to be static for boxed `Pin`-API

Allocators has to retain their validity until the instance and all of its clones are dropped. When pinning a value, it must live forever, thus, the allocator requires a `'static` lifetime for pinning a value. [Example from reddit](https://www.reddit.com/r/rust/comments/jymzdw/the_story_continues_vec_now_supports_custom/gd7qak2?utm_source=share&utm_medium=web2x&context=3):

```rust
let alloc = MyAlloc(/* ... */);
let pinned = Box::pin_in(42, alloc);
mem::forget(pinned); // Now `value` must live forever
// Otherwise `Pin`'s invariants are violated, storage invalidated
// before Drop was called.
// borrow of `memory` can end here, there is no value keeping it.
drop(alloc); // Oh, value doesn't live forever.
```

3 years agoFix a bootstrap comment
nooberfsh [Sun, 29 Nov 2020 02:02:24 +0000 (10:02 +0800)]
Fix a bootstrap comment

3 years agoAdd support for multi-argument decl macros
Rune Tynan [Sun, 29 Nov 2020 01:46:17 +0000 (20:46 -0500)]
Add support for multi-argument decl macros

3 years agolibtest: Make `sed` arguments compatible with apple
Jakob Schikowski [Sat, 28 Nov 2020 09:23:36 +0000 (10:23 +0100)]
libtest: Make `sed` arguments compatible with apple

3 years agolooser regex on local args
Ashley Mannix [Sun, 29 Nov 2020 00:18:07 +0000 (10:18 +1000)]
looser regex on local args

3 years agoAuto merge of #79511 - cjgillot:fitem-2, r=lcnr
bors [Sat, 28 Nov 2020 22:52:18 +0000 (22:52 +0000)]
Auto merge of #79511 - cjgillot:fitem-2, r=lcnr

Do not visit ForeignItemRef for HIR indexing and validation.

Similarly to what is done for ImplItemRef and TraitItemRef.

Fixes #79487

r? `@lcnr`

3 years agoDon't store `ty` and `span` in `IntRange`
Nadrieril [Sat, 28 Nov 2020 22:07:15 +0000 (22:07 +0000)]
Don't store `ty` and `span` in `IntRange`

We prefer to grab `ty` and `span` from `pcx`. This makes it consistent
with other constructors.

3 years agoCorrectly detect `usize`/`isize` range overlaps
Nadrieril [Sat, 28 Nov 2020 21:23:38 +0000 (21:23 +0000)]
Correctly detect `usize`/`isize` range overlaps

3 years agoRemove unnecessary `mut` binding
Joshua Nelson [Sat, 28 Nov 2020 19:52:25 +0000 (14:52 -0500)]
Remove unnecessary `mut` binding

3 years agoAdd test for issue #54121:
Julian Wollersberger [Sat, 28 Nov 2020 18:44:31 +0000 (19:44 +0100)]
Add test for issue #54121:
"simple type inference fails depending on order of trait bounds"

3 years agoDo not visit ForeignItemRef for HIR indexing and validation.
Camille GILLOT [Sat, 28 Nov 2020 17:08:11 +0000 (18:08 +0100)]
Do not visit ForeignItemRef for HIR indexing and validation.

Similarly to what is done for ImplItemRef and TraitItemRef.

Fixes #79487

3 years agoAuto merge of #79507 - jonas-schievink:rollup-e5yeayh, r=jonas-schievink
bors [Sat, 28 Nov 2020 15:17:13 +0000 (15:17 +0000)]
Auto merge of #79507 - jonas-schievink:rollup-e5yeayh, r=jonas-schievink

Rollup of 10 pull requests

Successful merges:

 - #78086 (Improve doc for 'as _')
 - #78853 (rustc_parse: fix ConstBlock expr span)
 - #79234 (Resolve typedefs in HashMap gdb/lldb pretty-printers)
 - #79344 (Convert UNC path to local path to satisfy install script on Windows)
 - #79383 (Fix bold code formatting in keyword docs)
 - #79460 (Remove intermediate vectors from `add_bounds`)
 - #79474 (Change comments on types to doc-comments)
 - #79476 (Sync rustc_codegen_cranelift)
 - #79478 (Expand docs on Peekable::peek_mut)
 - #79486 (Slightly improve code samples in E0591)

Failed merges:

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

3 years agoRollup merge of #79486 - camelid:E0591-code-cleanup, r=lcnr
Jonas Schievink [Sat, 28 Nov 2020 14:58:30 +0000 (15:58 +0100)]
Rollup merge of #79486 - camelid:E0591-code-cleanup, r=lcnr

Slightly improve code samples in E0591

* Improve formatting
* Don't hide `unsafe` block - it's important!

3 years agoRollup merge of #79478 - lukaslueg:peek_mut_docs, r=m-ou-se
Jonas Schievink [Sat, 28 Nov 2020 14:58:28 +0000 (15:58 +0100)]
Rollup merge of #79478 - lukaslueg:peek_mut_docs, r=m-ou-se

Expand docs on Peekable::peek_mut

Slightly expand docs on `std::iter::Peekable::peek_mut`, tracked in #78302

r? `@m-ou-se`

3 years agoRollup merge of #79476 - bjorn3:sync_cg_clif-2020-11-27, r=bjorn3
Jonas Schievink [Sat, 28 Nov 2020 14:58:26 +0000 (15:58 +0100)]
Rollup merge of #79476 - bjorn3:sync_cg_clif-2020-11-27, r=bjorn3

Sync rustc_codegen_cranelift

This implements a few extra simd intrinsics, fixes yet another 128bit bug and updates a few dependencies. It also fixes an cg_clif subtree update that did compile, but that caused a panic when compiling libcore. Other than that this is mostly cleanups.

`@rustbot` modify labels: +A-codegen +A-cranelift +T-compiler

3 years agoRollup merge of #79474 - jyn514:query-mode, r=Aaron1011
Jonas Schievink [Sat, 28 Nov 2020 14:58:25 +0000 (15:58 +0100)]
Rollup merge of #79474 - jyn514:query-mode, r=Aaron1011

Change comments on types to doc-comments

Found while investigating https://github.com/rust-lang/rust/issues/79459.

r? `@Aaron1011`

3 years agoRollup merge of #79460 - bugadani:simplify, r=jonas-schievink
Jonas Schievink [Sat, 28 Nov 2020 14:58:23 +0000 (15:58 +0100)]
Rollup merge of #79460 - bugadani:simplify, r=jonas-schievink

Remove intermediate vectors from `add_bounds`

This PR removes two short lived vectors that don't serve any obvious purpose.

3 years agoRollup merge of #79383 - abdnh:patch-1, r=shepmaster
Jonas Schievink [Sat, 28 Nov 2020 14:58:21 +0000 (15:58 +0100)]
Rollup merge of #79383 - abdnh:patch-1, r=shepmaster

Fix bold code formatting in keyword docs

3 years agoRollup merge of #79344 - JRF63:fix_install_script_win, r=Mark-Simulacrum
Jonas Schievink [Sat, 28 Nov 2020 14:58:19 +0000 (15:58 +0100)]
Rollup merge of #79344 - JRF63:fix_install_script_win, r=Mark-Simulacrum

Convert UNC path to local path to satisfy install script on Windows

`mkdir` with the `-p` flag attempts to create `//?` if passed a UNC path. This fails on both MSYS2 and Git Bash.

The UNC paths come from [canonicalizing](https://github.com/rust-lang/rust/blob/32da90b431919eedb3e281a91caea063ba4edb77/src/bootstrap/install.rs#L79) the install prefix path. `mkdir -p` gets invoked on the [install script](https://github.com/rust-lang/rust-installer/blob/d66f476b4d5e7fdf1ec215c9ac16c923dc292324/install-template.sh#L149).

3 years agoRollup merge of #79234 - ortem:fix-hashmap-pretty-printers, r=Mark-Simulacrum
Jonas Schievink [Sat, 28 Nov 2020 14:58:17 +0000 (15:58 +0100)]
Rollup merge of #79234 - ortem:fix-hashmap-pretty-printers, r=Mark-Simulacrum

Resolve typedefs in HashMap gdb/lldb pretty-printers

`GetTypedefedType` (LLDB) and `strip_typedefs` (GDB) calls are needed to resolve key and value types completely.
Without these calls, debugger doesn't show the actual type.

**Before** (without `GetTypedefedType`):
```
(lldb) frame variable hm[0]
(T) hm[0] = { ... }
```

**After** (with `GetTypedefedType`):
```
(lldb) frame variable hm[0]
((i32, alloc::string::String)) hm[0] = { ... }
```

Based on https://github.com/intellij-rust/intellij-rust/pull/6258

3 years agoRollup merge of #78853 - calebcartwright:fix-const-block-expr-span, r=spastorino
Jonas Schievink [Sat, 28 Nov 2020 14:58:15 +0000 (15:58 +0100)]
Rollup merge of #78853 - calebcartwright:fix-const-block-expr-span, r=spastorino

rustc_parse: fix ConstBlock expr span

The span for a ConstBlock expression should presumably run through the end of the block it contains and not stop at the keyword, just like is done with similar block-containing expression kinds, such as a TryBlock

3 years agoRollup merge of #78086 - poliorcetics:as-placeholder, r=Mark-Simulacrum
Jonas Schievink [Sat, 28 Nov 2020 14:58:13 +0000 (15:58 +0100)]
Rollup merge of #78086 - poliorcetics:as-placeholder, r=Mark-Simulacrum

Improve doc for 'as _'

Fix #78042.

`@rustbot` modify labels: A-coercions T-doc

3 years agoCleanup: shorter and faster code
Aleksey Kladov [Sat, 28 Nov 2020 14:47:34 +0000 (17:47 +0300)]
Cleanup: shorter and faster code

3 years agoRequire allocator to be static for boxed `Pin`-API
Tim Diekmann [Sat, 28 Nov 2020 14:24:30 +0000 (15:24 +0100)]
Require allocator to be static for boxed `Pin`-API

3 years agoBTreeMap: try to enhance various comments & local identifiers
Stein Somers [Thu, 5 Nov 2020 12:23:11 +0000 (13:23 +0100)]
BTreeMap: try to enhance various comments & local identifiers

3 years agoAuto merge of #78296 - Aaron1011:fix/stmt-tokens, r=petrochenkov
bors [Sat, 28 Nov 2020 07:48:56 +0000 (07:48 +0000)]
Auto merge of #78296 - Aaron1011:fix/stmt-tokens, r=petrochenkov

Properly handle attributes on statements

We now collect tokens for the underlying node wrapped by `StmtKind`
nstead of storing tokens directly in `Stmt`.

`LazyTokenStream` now supports capturing a trailing semicolon after it
is initially constructed. This allows us to avoid refactoring statement
parsing to wrap the parsing of the semicolon in `parse_tokens`.

Attributes on item statements
(e.g. `fn foo() { #[bar] struct MyStruct; }`) are now treated as
item attributes, not statement attributes, which is consistent with how
we handle attributes on other kinds of statements. The feature-gating
code is adjusted so that proc-macro attributes are still allowed on item
statements on stable.

Two built-in macros (`#[global_allocator]` and `#[test]`) needed to be
adjusted to support being passed `Annotatable::Stmt`.

3 years agoUpdate src/test/rustdoc/decl_macro_priv.rs
Rune Tynan [Sat, 28 Nov 2020 05:02:46 +0000 (00:02 -0500)]
Update src/test/rustdoc/decl_macro_priv.rs

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agoAuto merge of #79353 - cjgillot:procmacro, r=petrochenkov
bors [Sat, 28 Nov 2020 03:20:09 +0000 (03:20 +0000)]
Auto merge of #79353 - cjgillot:procmacro, r=petrochenkov

Setup proc-macro metadata at encoding instead of decoding

This should improve the common non-proc-macro case for metadata decoding.

3 years agoUpdate error to reflect that integer literals can have float suffixes
Camelid [Sun, 22 Nov 2020 22:29:46 +0000 (14:29 -0800)]
Update error to reflect that integer literals can have float suffixes

For example, `1` is parsed as an integer literal, but it can be turned
into a float with the suffix `f32`. Now the error calls them "numeric
literals" and notes that you can add a float suffix since they can be
either integers or floats.

3 years agoSlightly improve code samples in E0591
Camelid [Sat, 28 Nov 2020 01:18:29 +0000 (17:18 -0800)]
Slightly improve code samples in E0591

* Improve formatting
* Don't hide `unsafe` block - it's important!

3 years agoUpdate decl_macro test, add decl_macro_priv test for --document-private-items
Rune Tynan [Fri, 27 Nov 2020 03:08:59 +0000 (22:08 -0500)]
Update decl_macro test, add decl_macro_priv test for --document-private-items

3 years agoAdd test, fix pub macro impl, compile error
Rune Tynan [Fri, 27 Nov 2020 02:57:11 +0000 (21:57 -0500)]
Add test, fix pub macro impl, compile error

3 years agoApply review: use from_hir, add macro source fix.
Rune Tynan [Fri, 27 Nov 2020 02:17:13 +0000 (21:17 -0500)]
Apply review: use from_hir, add macro source fix.

3 years agoRemove doctree::Macro
Rune Tynan [Thu, 26 Nov 2020 23:36:59 +0000 (18:36 -0500)]
Remove doctree::Macro

3 years agoAuto merge of #79469 - rust-lang:revert-77467-query-docs, r=jyn514
bors [Sat, 28 Nov 2020 00:53:02 +0000 (00:53 +0000)]
Auto merge of #79469 - rust-lang:revert-77467-query-docs, r=jyn514

Revert "Normalize `<X as Y>::T` for rustdoc"

Reverts rust-lang/rust#77467 by disabling normalization. See https://github.com/rust-lang/rust/issues/79459; I intend to reland normalization once that's fixed.

r? `@Aaron1011`
cc `@oli-obk` `@GuillaumeGomez`

3 years agoAuto merge of #79284 - Nadrieril:constructor-module, r=varkor
bors [Fri, 27 Nov 2020 22:34:59 +0000 (22:34 +0000)]
Auto merge of #79284 - Nadrieril:constructor-module, r=varkor

Split match exhaustiveness into two files

I feel the constructor-related things in the `_match` module make enough sense on their own so I split them off. It makes `_match` feel less like a complicated mess. I'm not aware of PRs in progress against this module apart from my own so hopefully I'm not annoying too many people.
I have a lot of questions about the conventions in naming and modules around the compiler. Like, why is the module named `_match`? Could I rename it to `usefulness` maybe? Should `deconstruct_pat` be a submodule of `_match` since only `_match` uses it? Is it ok to move big piles of code around even if it makes git blame more difficult?

r? `@varkor`
`@rustbot` modify labels: +A-exhaustiveness-checking

3 years agoadd enable-full-tools to freebsd builds to prevent occasional link errors when compil...
Sreehari S [Fri, 27 Nov 2020 22:21:23 +0000 (14:21 -0800)]
add enable-full-tools to freebsd builds to prevent occasional link errors when compiling rust programs

3 years agoExpand docs on Peekable::peek_mut
Lukas Lueg [Fri, 27 Nov 2020 20:46:39 +0000 (21:46 +0100)]
Expand docs on Peekable::peek_mut

3 years agoReturn FxIndexSet instead of FxHashSet to avoid order errors on different platforms
Santiago Pastorino [Fri, 27 Nov 2020 21:45:34 +0000 (18:45 -0300)]
Return FxIndexSet instead of FxHashSet to avoid order errors on different platforms

3 years agoBump recursion_limit in rustc_ast_passes
Aaron Hill [Fri, 27 Nov 2020 20:46:19 +0000 (15:46 -0500)]
Bump recursion_limit in rustc_ast_passes

When cfg(parallel_compiler) is enabled, we end up trying to prove
Send/Sync bounds for some deeply nested types (at least when rustdoc is
run).

3 years agoMerge commit '5988bbd24aa87732bfa1d111ba00bcdaa22c481a' into sync_cg_clif-2020-11-27
bjorn3 [Fri, 27 Nov 2020 19:48:53 +0000 (20:48 +0100)]
Merge commit '5988bbd24aa87732bfa1d111ba00bcdaa22c481a' into sync_cg_clif-2020-11-27

3 years agoEncode proc_macro directly.
Camille GILLOT [Sun, 15 Nov 2020 17:34:10 +0000 (18:34 +0100)]
Encode proc_macro directly.

Encode proc_macro name directly.

Do not store None values.

3 years agoAuto merge of #79372 - jyn514:more-cleanup, r=GuillaumeGomez
bors [Fri, 27 Nov 2020 19:30:58 +0000 (19:30 +0000)]
Auto merge of #79372 - jyn514:more-cleanup, r=GuillaumeGomez

Cleanup more of rustdoc

-  Use `Item::from_def_id` for StructField
- Use `from_def_id_and_parts` for primitives and keywords
- Take `String` instead of `Symbol` in `from_def_id` - this avoids having to intern then immediately stringify the existing string.
- Remove unused `get_stability` and `get_deprecation`
- Remove unused `attrs` field from `primitives`
- Remove unused `attrs` field from `keywords`

This will probably conflict with https://github.com/rust-lang/rust/pull/79335 and I would prefer for that PR to land first - I'm anxious for https://github.com/rust-lang/rust/pull/77467 to land :)

Makes https://github.com/rust-lang/rust/issues/76998 easier to add.

r? `@GuillaumeGomez`

3 years agoChange comments on types to doc-comments
Joshua Nelson [Fri, 27 Nov 2020 19:17:25 +0000 (14:17 -0500)]
Change comments on types to doc-comments

3 years agoRename `_match` to `usefulness`
Nadrieril [Fri, 27 Nov 2020 18:43:28 +0000 (18:43 +0000)]
Rename `_match` to `usefulness`

3 years agoRename `pat_constructor` to `Constructor::from_pat`
Nadrieril [Sat, 21 Nov 2020 23:26:53 +0000 (23:26 +0000)]
Rename `pat_constructor` to `Constructor::from_pat`

3 years agoMove the definitions of the two `Ctxt`s to the top
Nadrieril [Sat, 21 Nov 2020 22:41:17 +0000 (22:41 +0000)]
Move the definitions of the two `Ctxt`s to the top

3 years agoExtract everything related to pattern deconstruction to a new module
Nadrieril [Sat, 21 Nov 2020 23:13:32 +0000 (23:13 +0000)]
Extract everything related to pattern deconstruction to a new module

3 years agoNo need to expose `Matrix` internals
Nadrieril [Sat, 21 Nov 2020 23:12:53 +0000 (23:12 +0000)]
No need to expose `Matrix` internals

3 years agoDisentangle `Fields` and `PatStack`
Nadrieril [Wed, 18 Nov 2020 22:07:37 +0000 (22:07 +0000)]
Disentangle `Fields` and `PatStack`

3 years agoMove `Constructor::apply` to `Fields`
Nadrieril [Sat, 21 Nov 2020 21:22:13 +0000 (21:22 +0000)]
Move `Constructor::apply` to `Fields`

3 years agoRevert the effect of #77467 by disabling normalization in rustdoc
oli [Fri, 27 Nov 2020 17:08:49 +0000 (17:08 +0000)]
Revert the effect of #77467 by disabling normalization in rustdoc

3 years agoRevert "Use the new component dependency option of the rust-toolchain file"
bjorn3 [Fri, 27 Nov 2020 17:05:05 +0000 (18:05 +0100)]
Revert "Use the new component dependency option of the rust-toolchain file"

This reverts commit 648caced6eb0d23c31758f69f2f44a7d748526b9.

Rustup on github actions isn't yet updated

3 years agoSync from rust c9228570668803e3e6402770d55f23a12c9ae686
bjorn3 [Fri, 27 Nov 2020 17:01:29 +0000 (18:01 +0100)]
Sync from rust c9228570668803e3e6402770d55f23a12c9ae686

3 years agoRustup to rustc 1.50.0-nightly (72da5a9d8 2020-11-26)
bjorn3 [Fri, 27 Nov 2020 17:01:01 +0000 (18:01 +0100)]
Rustup to rustc 1.50.0-nightly (72da5a9d8 2020-11-26)

3 years agoRemove unused is_doc_keyword function
Guillaume Gomez [Fri, 27 Nov 2020 13:55:06 +0000 (14:55 +0100)]
Remove unused is_doc_keyword function

3 years agoAdd tests for doc_keyword feature extension
Guillaume Gomez [Fri, 27 Nov 2020 13:28:17 +0000 (14:28 +0100)]
Add tests for doc_keyword feature extension

3 years agolibtest: Print the total time taken to execute a test suite
Jakob Schikowski [Thu, 26 Nov 2020 20:15:15 +0000 (21:15 +0100)]
libtest: Print the total time taken to execute a test suite

3 years agoUse the new component dependency option of the rust-toolchain file
bjorn3 [Fri, 27 Nov 2020 15:52:17 +0000 (16:52 +0100)]
Use the new component dependency option of the rust-toolchain file

3 years agoAllow to have any valid ident used as keyword in doc_keyword feature
Guillaume Gomez [Fri, 27 Nov 2020 13:27:59 +0000 (14:27 +0100)]
Allow to have any valid ident used as keyword in doc_keyword feature

3 years agoAuto merge of #77484 - terhechte:support-ios-catalyst-macabi-arm64-target-triple...
bors [Fri, 27 Nov 2020 15:58:26 +0000 (15:58 +0000)]
Auto merge of #77484 - terhechte:support-ios-catalyst-macabi-arm64-target-triple, r=nikomatsakis

Add support for Arm64 Catalyst on ARM Macs

This is an iteration on https://github.com/rust-lang/rust/pull/63467 which was merged a while ago. In the aforementioned PR, I added support for the `X86_64-apple-ios-macabi` target triple, which is Catalyst, iOS apps running on macOS.

Very soon, Apple will launch ARM64 based Macs which will introduce `aarch64_apple_darwin.rs`, macOS apps using the Darwin ABI running on ARM. This PR adds support for Catalyst apps on ARM Macs: iOS apps compiled for the darwin ABI.

I don't have access to a Apple Developer Transition Kit (DTK), so I can't really test if the generated binaries work correctly. I'm vaguely hopeful that somebody with access to a DTK could give this a spin.

3 years agoMake super_traits_of return an iterator
Santiago Pastorino [Wed, 25 Nov 2020 16:24:05 +0000 (13:24 -0300)]
Make super_traits_of return an iterator

3 years agoDon't lint on redundant semicolons after item statements
Aaron Hill [Fri, 27 Nov 2020 14:36:59 +0000 (09:36 -0500)]
Don't lint on redundant semicolons after item statements

This preserves the current lint behavior for now.

Linting after item statements currently prevents the compiler from bootstrapping.
Fixing this is blocked on fixing this upstream in Cargo, and bumping the Cargo
submodule.

3 years agoRemove super_traits_of query, just leave a helper function
Santiago Pastorino [Wed, 25 Nov 2020 15:53:52 +0000 (12:53 -0300)]
Remove super_traits_of query, just leave a helper function

3 years agoSimplify super_traits_of
Santiago Pastorino [Wed, 25 Nov 2020 15:49:48 +0000 (12:49 -0300)]
Simplify super_traits_of

3 years agoAdd test to check that we handle predicates that can define assoc types correctly
Santiago Pastorino [Wed, 25 Nov 2020 13:31:48 +0000 (10:31 -0300)]
Add test to check that we handle predicates that can define assoc types correctly

3 years agoMake super_traits_of return Lrc for cheaper clone
Santiago Pastorino [Tue, 24 Nov 2020 20:36:36 +0000 (17:36 -0300)]
Make super_traits_of return Lrc for cheaper clone