Commit graph

134590 commits

Author SHA1 Message Date
Rune Tynan
ccbb0f5c1a
Add support for stable-const-since in docs on items (standalone or assoc) 2020-11-29 21:00:14 -05:00
Christiaan Dirkx
be554c4101 Make ui test that are run-pass and do not test the compiler itself library tests 2020-11-30 02:47:32 +01:00
bors
3be53bc45a 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.
2020-11-30 01:42:14 +00:00
bors
28b86e0860 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.
2020-11-30 01:42:14 +00:00
Erik Desjardins
0183b4109a Pass arguments up to 2*usize by value 2020-11-29 20:08:00 -05:00
Cameron Steffen
0e20788839 Split tests 2020-11-29 18:21:21 -06:00
Aman Arora
e35e46c113 Be cautious of calling upvar_tys before mir 2020-11-29 19:20:28 -05:00
Aman Arora
5da2bf197d Remove extra call to upvar_tys
Fixes #78720
2020-11-29 19:11:20 -05:00
bors
cf9bfdb872 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:👿:<impl core::fmt::Display for u64>::fmt
0000000000001ce0 T core::fmt::num:👿:<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
```
2020-11-29 23:14:40 +00:00
Matthias Krüger
252083f7e0 address review comments and rebase
ci: always build with internal lints
group up internal lints in lib.rs
dogfood: we already pass --all-features, no need to enable internal-lints again
2020-11-29 23:43:23 +01:00
Joshua Nelson
95a6427d2c Add -Z normalize-docs and enable it for compiler docs 2020-11-29 17:21:24 -05:00
Cameron Steffen
a5d6855333 Use LocalUsedVisitor in more places 2020-11-29 15:34:11 -06:00
Cameron Steffen
fff5fa6581 Eat collapsible_match dogfood 2020-11-29 15:34:11 -06:00
Cameron Steffen
28dec3b708 Add collapsible_match lint 2020-11-29 15:34:11 -06:00
bors
349b3b324d Auto merge of #79209 - spastorino:trait-inheritance-self, r=nikomatsakis
Allow Trait inheritance with cycles on associated types

Fixes #35237

r? `@nikomatsakis`

cc `@estebank`
2020-11-29 21:04:23 +00:00
Cameron Steffen
6e1fbfdb8f Add LocalUseVisitor 2020-11-29 15:02:27 -06:00
Cameron Steffen
5df286b636 Improve SpanlessEq for blocks 2020-11-29 15:02:27 -06:00
Matthias Krüger
b25a6df775 ci: partly clean build artifacts to work around "Found multiple rlibs for crate clippy_lints" compiletest error 2020-11-29 21:07:47 +01:00
Matthias Krüger
958e2e20de fix clippy-dev update_lints 2020-11-29 21:07:47 +01:00
Matthias Krüger
2838b04487 add internal-lints feature to enable clippys internal lints (off by default) 2020-11-29 21:07:43 +01:00
Joshua Nelson
2b17f02561 Add test for cross-crate Self 2020-11-29 13:52:51 -05:00
bors
b776d1c3e3 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
2020-11-29 18:50:19 +00:00
Joshua Nelson
aa8c9b0d29 Remove TypeKind hack in favor of with_crate_prefix 2020-11-29 13:40:49 -05:00
Joshua Nelson
6ab1f05697 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.
2020-11-29 13:40:08 -05:00
unknown
de3a0bdf05 Fixes #79357 unstable or-pat suggestions 2020-11-29 15:31:45 -03:00
bors
88b81970ba 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.
2020-11-29 16:39:23 +00:00
Eric Huss
a90fdfc701 lint-docs: Use strip-prefix to simplify. 2020-11-29 07:57:55 -08:00
Eric Huss
228510b0ec lint-docs: Add some extra detail to the error message.
This will hopefully help users figure out what was wrong and how
to fix it.
2020-11-29 07:39:36 -08:00
bors
af780e569d 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.
2020-11-29 14:29:23 +00:00
Suyash458
61b29281e7 add more tests for msrv 2020-11-29 17:08:56 +05:30
bors
2e5723137b 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`
2020-11-29 11:37:44 +00:00
Mara Bos
1da5780303 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.
2020-11-29 11:38:51 +01:00
Linus Färnstrand
f9220c3b14 Bump dependencies invalidly assuming memory layout of SocketAddr
Bumps net2, socket2 and miow.
Helps unblock https://github.com/rust-lang/rust/pull/78802
2020-11-29 10:51:03 +01:00
bors
760430e6fd 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.
2020-11-29 09:28:09 +00:00
Ashley Mannix
354c7d0ab8 args may be passed by value 2020-11-29 18:36:30 +10:00
suyash458
af095db64c fix msrv check 2020-11-29 00:33:07 -08:00
suyash458
a75ab302d2 fix dogfood tests 2020-11-28 23:36:24 -08:00
bors
3cbb56f80b 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
2020-11-29 07:05:49 +00:00
bstrie
d55d791a3a 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.
2020-11-29 00:55:55 -05:00
bstrie
90a2e5e3fe 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.
2020-11-29 00:55:55 -05:00
Suyash458
4e4b8319e8 fix msrv in test 2020-11-28 21:21:04 -08:00
Suyash458
cd087e5c5e add rustc-semver to dependencies
switch Version/VersionReq usages to RustcVersion
2020-11-28 21:21:04 -08:00
bors
6add378d6b 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" }
```
2020-11-29 04:54:20 +00:00
bors
40d7efad5e 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
2020-11-29 02:45:48 +00:00
Rune Tynan
d23b57c1a8
Add test for macro by example syntax in decl macros with only one option 2020-11-28 21:32:07 -05:00
Dylan DPC
d0515ce7ef
Rollup merge of #79528 - nooberfsh:fix_doc, r=Mark-Simulacrum
Fix a bootstrap comment
2020-11-29 03:14:29 +01:00
Dylan DPC
47e74a9a51
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.
2020-11-29 03:14:27 +01:00
Dylan DPC
f0e41ce495
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
2020-11-29 03:14:26 +01:00
Dylan DPC
6eb5245555
Rollup merge of #79505 - matklad:cleanup, r=jonas-schievink
Cleanup: shorter and faster code
2020-11-29 03:14:24 +01:00
Dylan DPC
c9c81d92a9
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.
2020-11-29 03:14:22 +01:00