Commit Graph

125161 Commits

Author SHA1 Message Date
Ivan Tham
4b15b809eb
Remove abmiguity from PathBuf pop example 2020-08-08 18:28:55 +08:00
Ivan Tham
b3ae88f6bb
Use assert! for Path exists example to check bool 2020-08-08 18:23:18 +08:00
Ivan Tham
9532b83912
Show Path extension example change multi extension 2020-08-08 18:14:29 +08:00
Ivan Tham
e7e41a8465
Add additonal case for Path starts with
Show what happens if there is an extra extension
2020-08-08 18:06:04 +08:00
Ivan Tham
6dffd2d18e
Separate example for Path strip_prefix 2020-08-08 18:01:34 +08:00
Ivan Tham
a11c27925d
Show relative example for Path ancestors 2020-08-08 17:53:16 +08:00
bors
c92fc8db8b Auto merge of #75282 - RalfJung:miri-black-box, r=oli-obk
do not call black_box on Miri

Helps with https://github.com/rust-lang/rust/issues/75274 (but https://github.com/rust-lang/rust/pull/74932 introduced unrelated breakage that will need a separate fix)
Cc @eggyal r? @Mark-Simulacrum
2020-08-08 09:46:16 +00:00
strom-und-spiele
7e68b7d10a Update E0271.md
remove references to non existing code,
expand solution suggestions
remove unneeded code in solution
2020-08-08 11:01:34 +02:00
Ralf Jung
8385146ffa make black_box a NOP in Miri 2020-08-08 10:50:30 +02:00
Nikita Popov
7e5c7cf8e3 Emit == null instead of <= null
When the niche maximum is zero, emit a "== zero" check instead of
a "<= zero" check. In particular, this avoid the awkward case of
"<= null". While LLVM does canonicalize this to "!= null", this
appently doesn't happen for constant expressions, leading to the
issue in #74425. While that can be addressed on the LLVM side, it
still seems prudent to emit sensible IR here, because this will
allow null checks to be optimized earlier in the pipeline.

Fixes #74425.
2020-08-08 10:45:15 +02:00
bors
d19d7e2755 Auto merge of #75257 - ssomers:btree_74762_again, r=Mark-Simulacrum
BTreeMap: better way to postpone root access in DrainFilter

A slightly more elegant (in my opinion) adaptation of #74762. Benchmarks seem irrationally pleased to:
```
benchcmp old new --threshold 5
 name                                           old ns/iter  new ns/iter  diff ns/iter   diff %  speedup
 btree::map::clone_fat_100_and_remove_all       215,182      185,052           -30,130  -14.00%   x 1.16
 btree::map::clone_fat_100_and_remove_half      139,667      127,945           -11,722   -8.39%   x 1.09
 btree::map::clone_fat_val_100_and_remove_all   96,755       81,279            -15,476  -16.00%   x 1.19
 btree::map::clone_fat_val_100_and_remove_half  64,678       56,911             -7,767  -12.01%   x 1.14
 btree::map::find_rand_100                      18           17                     -1   -5.56%   x 1.06
 btree::map::first_and_last_0                   33           35                      2    6.06%   x 0.94
 btree::map::first_and_last_100                 40           54                     14   35.00%   x 0.74
 btree::map::insert_rand_100                    45           42                     -3   -6.67%   x 1.07
 btree::map::insert_rand_10_000                 45           41                     -4   -8.89%   x 1.10
 btree::map::iter_0                             2,010        1,759                -251  -12.49%   x 1.14
 btree::map::iter_100                           3,514        2,764                -750  -21.34%   x 1.27
 btree::map::iter_10k                           4,018        3,768                -250   -6.22%   x 1.07
 btree::map::range_unbounded_unbounded          37,269       28,929             -8,340  -22.38%   x 1.29
 btree::map::range_unbounded_vs_iter            31,518       28,814             -2,704   -8.58%   x 1.09
```

r? @Mark-Simulacrum
2020-08-08 07:46:04 +00:00
Marko Mijalkovic
27fca58993 Add back unwinding support for Sony PSP 2020-08-08 02:14:40 -04:00
bors
e61621c307 Auto merge of #74932 - nnethercote:rm-ast-session-globals, r=petrochenkov
Remove `librustc_ast` session globals

By moving the data onto `Session`.

r? @petrochenkov
2020-08-08 05:58:57 +00:00
kadmin
18481cbec9 Rm restriction on ord of default types w/ consts 2020-08-08 04:40:07 +00:00
julianknodt
58b1a04b9e Allow types to come after consts in AST validation 2020-08-08 04:40:07 +00:00
bors
1d100ba26c Auto merge of #75276 - JohnTitor:rollup-rz4hs0w, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #75224 (Don't call a function in function-arguments-naked.rs)
 - #75237 (Display elided lifetime for non-reference type in doc)
 - #75250 (make MaybeUninit::as_(mut_)ptr const)
 - #75253 (clean up const-hacks in int endianess conversion functions)
 - #75259 (Add missing backtick)
 - #75267 (Small cleanup)
 - #75270 (fix a couple of clippy findings)

Failed merges:

r? @ghost
2020-08-08 03:54:33 +00:00
Yuki Okushi
21bfe529c7
Rollup merge of #75270 - matthiaskrgr:clippy_aug_1, r=Dylan-DPC
fix a couple of clippy findings
2020-08-08 11:36:12 +09:00
Yuki Okushi
81546de429
Rollup merge of #75267 - estebank:cleanup, r=Dylan-DPC
Small cleanup

* Add docstring to `Parser` field
* Remove unnecessary `unwrap`
* Remove unnecessary borrow
* Fix indentation of some `teach`text output
2020-08-08 11:36:10 +09:00
Yuki Okushi
2c1fe50362
Rollup merge of #75259 - giraffate:add_missing_backtick, r=lcnr
Add missing backtick
2020-08-08 11:36:09 +09:00
Yuki Okushi
02bf036c6c
Rollup merge of #75253 - RalfJung:cleanup-const-hack, r=oli-obk
clean up const-hacks in int endianess conversion functions

Cleans up the const hacks added in https://github.com/rust-lang/rust/pull/69373.

r? @oli-obk
2020-08-08 11:36:07 +09:00
Yuki Okushi
b032a15fa8
Rollup merge of #75250 - RalfJung:uninit-const-ptr, r=oli-obk
make MaybeUninit::as_(mut_)ptr const

I think it was just an oversight that they are not const yet.

I also changed their implementation as the old one created references to uninitialized memory.^^
2020-08-08 11:36:05 +09:00
Yuki Okushi
255434d83c
Rollup merge of #75237 - nbdd0121:rustdoc, r=jyn514
Display elided lifetime for non-reference type in doc

In edition 2018 we encourage writing `<'_>` explicitly, so rustdoc should display like such as well.

Fixes #75225

~~Somehow when I run the compiled rustdoc using `cargo +stage2 doc` on other crates, it correctly produces `<'_>`, but I couldn't get the std doc to do the same with `./x.py doc --stage 2`. Might this be related to the recent change to x.py about how the doc is built?~~
2020-08-08 11:36:03 +09:00
Yuki Okushi
f5d2ffd7fb
Rollup merge of #75224 - Aaron1011:fix/function-arguments-naked, r=Amanieu
Don't call a function in function-arguments-naked.rs

Fixes #75096

It's U.B. to use anything other than inline assmebling in a naked
function. Fortunately, the `#break` directive works fine without
anything in the function body.
2020-08-08 11:36:02 +09:00
Nicholas Nethercote
96dd044827 Increase recursion_limit in librustc_plugin_impl.
To avoid rustdoc problems.
2020-08-08 12:05:10 +10:00
Nicholas Nethercote
3dc8a36958 Eliminate librustc_hir's dependency on librustc_session. 2020-08-08 12:03:44 +10:00
Nicholas Nethercote
01bba2c532 Eliminate the SessionGlobals from librustc_ast.
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This
means they are accessed via the `Session`, rather than via TLS. A few
`Attr` methods and `librustc_ast` functions are now methods of
`Session`.

All of this required passing a `Session` to lots of functions that didn't
already have one. Some of these functions also had arguments removed, because
those arguments could be accessed directly via the `Session` argument.

`contains_feature_attr()` was dead, and is removed.

Some functions were moved from `librustc_ast` elsewhere because they now need
to access `Session`, which isn't available in that crate.
- `entry_point_type()` --> `librustc_builtin_macros`
- `global_allocator_spans()` --> `librustc_metadata`
- `is_proc_macro_attr()` --> `Session`
2020-08-08 12:03:42 +10:00
Nicholas Nethercote
e539dd65f8 Eliminate the SessionGlobals from librustc_ast.
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This
means they are accessed via the `Session`, rather than via TLS. A few
`Attr` methods and `librustc_ast` functions are now methods of
`Session`.

All of this required passing a `Session` to lots of functions that didn't
already have one. Some of these functions also had arguments removed, because
those arguments could be accessed directly via the `Session` argument.

`contains_feature_attr()` was dead, and is removed.

Some functions were moved from `librustc_ast` elsewhere because they now need
to access `Session`, which isn't available in that crate.
- `entry_point_type()` --> `librustc_builtin_macros`
- `global_allocator_spans()` --> `librustc_metadata`
- `is_proc_macro_attr()` --> `Session`
2020-08-08 12:03:42 +10:00
Nicholas Nethercote
d6fa011f62 Remove some unnecessary uses of Option.
These arguments are never `None`.
2020-08-08 12:02:45 +10:00
bors
f9c2177ddc Auto merge of #74877 - lcnr:min_const_generics, r=oli-obk
Implement the `min_const_generics` feature gate

Implements both https://github.com/rust-lang/lang-team/issues/37 and https://github.com/rust-lang/compiler-team/issues/332.

Adds the new feature gate `#![feature(min_const_generics)]`.
This feature gate adds the following limitations to using const generics:
- generic parameters must only be used in types if they are trivial. (either `N` or `{ N }`)
- generic parameters must be either integers, `bool` or `char`.

We do allow arbitrary expressions in associated consts though, meaning that the following is allowed,
even if `<[u8; 0] as Foo>::ASSOC` is not const evaluatable.
```rust
trait Foo {
    const ASSOC: usize;
}

impl<const N: usize> Foo for [u8; N] {
    const ASSOC: usize = 64 / N;
}
```

r? @varkor cc @eddyb @withoutboats
2020-08-08 01:48:35 +00:00
Joshua Nelson
b146000e91 EXTREMELY hacky fix
This runs _just_ enough of typeck that later queries don't panic.
Because this is in the same part of the compiler that errors on `impl
Trait`, this special-cases impl Trait for rustdoc and no one else.
Everything is fine.
2020-08-07 21:26:12 -04:00
Gary Guo
541fbbb6fa Cross-crate doc inlining test case for elided lifetime 2020-08-08 01:07:43 +01:00
bors
f3a9de9b08 Auto merge of #75048 - eggyal:force-no-tco-start-backtrace-frame, r=Mark-Simulacrum
Prevent `__rust_begin_short_backtrace` frames from being tail-call optimised away

I've stumbled across some situations where there (unexpectedly) was no `__rust_begin_short_backtrace` frame on the stack during unwinding.

On closer examination, it appeared that the calls to that function had been tail-call optimised away.

This PR follows [@bjorn3's suggestion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Disabling.20tail.20call.20optimisation.3F/near/205699133), by adding calls to `black_box` that hint to rustc not to perform TCO.

Fixes #47429
2020-08-08 00:00:52 +00:00
Camelid
bd71b01a82 Make the docs clearer for new contributors
* Add an easy-to-see note at the top of `CONTRIBUTING.md` that points
  new contributors to the Basics docs
* Add a note about compiler errors as a result of internals changes
  that break Clippy
2020-08-07 16:15:44 -07:00
Matthias Krüger
a605e51056 fix clippy::needless_return: remove unneeded return statements 2020-08-08 00:57:37 +02:00
Matthias Krüger
ff692ab14f fix clippy::clone_on_copy: don't clone types that are copy 2020-08-08 00:57:30 +02:00
Matthias Krüger
15dcda36e6 fix clippy::map_clone: use .cloned() instead of .map(|x| x.clone()) 2020-08-08 00:57:21 +02:00
Matthias Krüger
4ba1a19463 fix clippy::into_iter_on_ref: use .iter() instead of into_iter() on references. 2020-08-08 00:57:15 +02:00
Matthias Krüger
ea9ccfa42c fix clippy::while_let_loop: use while let{} instead of loop { if ... break; } 2020-08-08 00:57:09 +02:00
Matthias Krüger
f95cfe573a fix clippy::redundant_closure: remove redundant closures and call functions directly 2020-08-08 00:57:03 +02:00
Gary Guo
505d157814 Display elided lifetime for external paths 2020-08-07 23:41:07 +01:00
Gary Guo
63c0d9ca51 Display elided lifetime for non-reference type in doc 2020-08-07 23:35:07 +01:00
bors
c2d1b0d980 Auto merge of #75071 - ssomers:btree_cleanup_5, r=Mark-Simulacrum
BTreeMap: enforce the panic rule imposed by `replace`

Also, reveal the unsafe parts in the closures fed to it.

r? @Mark-Simulacrum
2020-08-07 21:48:32 +00:00
Josh Stone
a2cfc74c5f Simplify array::IntoIter
- Initialization can use `transmute_copy` to do the bitwise copy.
- `as_slice` can use `get_unchecked` and `MaybeUninit::slice_get_ref`,
  and `as_mut_slice` can do similar.
- `next` and `next_back` can use the corresponding `Range` methods.
- `Clone` doesn't need any unsafety, and we can dynamically update the
  new range to get partial drops if `T::clone` panics.
2020-08-07 13:51:46 -07:00
Matthias Krüger
057730c4b1 fix clippy::len_zero: use is_empty() instead of comparing .len() to zero 2020-08-07 22:47:32 +02:00
Matthias Krüger
eccc2fe503 fix clippy::unneeded_wildcard_pattern: remove redundant wildcard pattern 2020-08-07 22:47:32 +02:00
Matthias Krüger
f6b1857353 fix clippy::unnecessary_mut_passed: function arg is not required to be mutable 2020-08-07 22:47:32 +02:00
Matthias Krüger
a1c22122da fix clippy::unit_arg: make it explicit that Ok(()) is being returned 2020-08-07 22:47:32 +02:00
Matthias Krüger
f3ec5be849 fix clippy::single_char_pattern: use char instead of string single-char pattern 2020-08-07 22:47:32 +02:00
Matthias Krüger
09e29e7e43 fix clippy::redundant_pattern_matching: use .is_some() instead of if let Some(_) = .. 2020-08-07 22:47:32 +02:00
Matthias Krüger
27bb68927d fix clippy::redundant_clone: remove redundant clones 2020-08-07 22:47:32 +02:00