about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2020-12-31Rustdoc render public underscore_imports as Re-exportsbors-2/+109
Fixes #61592
2020-12-21Auto merge of #79270 - RalfJung:array-repeat-consts, r=oli-obkbors-37/+68
Acknowledge that `[CONST; N]` is stable When `const_in_array_repeat_expressions` (RFC 2203) got unstably implemented as part of https://github.com/rust-lang/rust/pull/61749, accidentally, the special case of repeating a *constant* got stabilized immediately. That is why the following code works on stable: ```rust const EMPTY: Vec<i32> = Vec::new(); pub const fn bar() -> [Vec<i32>; 2] { [EMPTY; 2] } fn main() { let x = bar(); } ``` In contrast, if we had written `[expr; 2]` for some expression that is not *literally* a constant but could be evaluated at compile-time (e.g. `(EMPTY,).0`), this would have failed. We could take back this stabilization as it was clearly accidental. However, I propose we instead just officially accept this and stabilize a small subset of RFC 2203, while leaving the more complex case of general expressions that could be evaluated at compile-time unstable. Making that case work well is pretty much blocked on inline `const` expressions (to avoid relying too much on [implicit promotion](https://github.com/rust-lang/const-eval/blob/master/promotion.md)), so it could take a bit until it comes to full fruition. `[CONST; N]` is an uncontroversial subset of this feature that has no semantic ambiguities, does not rely on promotion, and basically provides the full expressive power of RFC 2203 but without the convenience (people have to define constants to repeat them, possibly using associated consts if generics are involved). Well, I said "no semantic ambiguities", that is only almost true... the one point I am not sure about is `[CONST; 0]`. There are two possible behaviors here: either this is equivalent to `let x = CONST; [x; 0]`, or it is a NOP (if we argue that the constant is never actually instantiated). The difference between the two is that if `CONST` has a destructor, it should run in the former case (but currently doesn't, due to https://github.com/rust-lang/rust/issues/74836); but should not run if it is considered a NOP. For regular `[x; 0]` there seems to be consensus on running drop (there isn't really an alternative); any opinions for the `CONST` special case? Should this instantiate the const only to immediately run its destructors? That seems somewhat silly to me. After all, the `let`-expansion does *not* work in general, for `N > 1`. Cc `@rust-lang/lang` `@rust-lang/wg-const-eval` Cc https://github.com/rust-lang/rust/issues/49147
2020-12-21Auto merge of #80205 - tomprogrammer:prettyprint-pattern-mut-binding, ↵bors-1/+28
r=davidtwco Fix pretty printing an AST representing `&(mut ident)` The PR fixes a misguiding help diagnostic in the parser that I reported in #80186. I discovered that the parsers recovery and reporting logic was correct but the pretty printer produced wrong code for the example. (Details in https://github.com/rust-lang/rust/issues/80186#issuecomment-748498676) Example: ```rust #![allow(unused_variables)] fn main() { let mut &x = &0; } ``` The AST fragment `PatKind::Ref(PatKind::Ident(BindingMode::ByValue(Mutability::Mut), ..), Mutability::Not)` was printed to be `&mut ident`. But this wouldn't round trip through parsing again, because then it would be: `PatKind::Ref(PatKind::Ident(BindingMode::ByValue(Mutability::Not), ..), Mutability::Mut)` Now the pretty-printer prints `&(mut ident)`. Reparsing that code results in the AST fragment `PatKind::Ref(PatKind::Paren(PatKind::Ident(BindingMode::ByValue(Mutability::Mut), ..)), Mutability::Not)` which I think should behave like the original pattern. Old diagnostic: ``` error: `mut` must be attached to each individual binding --> src/main.rs:3:9 | 3 | let mut &x = &0; | ^^^^^^ help: add `mut` to each binding: `&mut x` | = note: `mut` may be followed by `variable` and `variable @ pattern` ``` New diagnostic: ``` error: `mut` must be attached to each individual binding --> src/main.rs:3:9 | 3 | let mut &x = &0; | ^^^^^^ help: add `mut` to each binding: `&(mut x)` | = note: `mut` may be followed by `variable` and `variable @ pattern` ``` Fixes #80186
2020-12-21Auto merge of #80206 - poliorcetics:rustdoc-default-langstring, ↵bors-39/+29
r=GuillaumeGomez,jyn514 impl Default for LangString, replacing all_false by default Fix #80015 `@rustbot` label C-cleanup T-rustdoc A-markdown-parsing
2020-12-21Auto merge of #80253 - Dylan-DPC:rollup-bkmn74z, r=Dylan-DPCbors-1234/+3573
Rollup of 11 pull requests Successful merges: - #80159 (Add array search aliases) - #80166 (Edit rustc_middle docs) - #80170 (Fix ICE when lookup method in trait for type that have bound vars) - #80171 (Edit rustc_middle::ty::TyKind docs) - #80199 (also const-check FakeRead) - #80211 (Handle desugaring in impl trait bound suggestion) - #80236 (Use pointer type in AtomicPtr::swap implementation) - #80239 (Update Clippy) - #80240 (make sure installer only creates directories in DESTDIR) - #80244 (Cleanup markdown span handling) - #80250 (Minor cleanups in LateResolver) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-12-21Rollup merge of #80250 - bugadani:resolver-cleanup, r=petrochenkovDylan DPC-36/+29
Minor cleanups in LateResolver - Avoid calculating hash twice - Avoid creating a closure in every iteration of a loop - Reserve space for path in advance - Some readability changes
2020-12-21Rollup merge of #80244 - jyn514:spans, r=bugadaniDylan DPC-103/+94
Cleanup markdown span handling 1. Get rid of `locate()` in markdown handling This function was unfortunate for several reasons: - It used `unsafe` because it wanted to tell whether a string came from the same *allocation* as another, not just whether it was a textual match. - It recalculated spans even though they were already available from pulldown - It sometimes *failed* to calculate the span, which meant it was always possible for the span to be `None`, even though in practice that should never happen. This has several cleanups: - Make the span required - Pass through the span from pulldown in the `HeadingLinks` and `Footnotes` iterators - Only add iterator bounds on the `impl Iterator`, not on `new` and the struct itself. 2. Remove unnecessary scope in `markdown_links` I recommend reading a single commit at a time. cc ``@bugadani`` - this will conflict with https://github.com/rust-lang/rust/pull/77859, I'll try to make sure that gets merged first.
2020-12-21Rollup merge of #80240 - yshui:master, r=Mark-SimulacrumDylan DPC-6/+8
make sure installer only creates directories in DESTDIR Fixes #80238 Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-21Rollup merge of #80239 - flip1995:clippyup, r=ManishearthDylan DPC-1049/+3201
Update Clippy Biweekly Clippy update. r? ``@Manishearth``
2020-12-21Rollup merge of #80236 - tmiasko:atomic-swap, r=oli-obkDylan DPC-3/+22
Use pointer type in AtomicPtr::swap implementation Closes #80234.
2020-12-21Rollup merge of #80211 - wabain:async-fn-trait-bound-suggestion, r=petrochenkovDylan DPC-13/+95
Handle desugaring in impl trait bound suggestion Fixes #79843. When an associated type of a generic function parameter needs extra bounds, the diagnostics may suggest replacing an `impl Trait` with a named type parameter so that it can be referenced in the where clause. On stable and nightly, the suggestion can be malformed, for instance transforming: ```rust async fn run(_: &(), foo: impl Foo) -> std::io::Result<()> ``` Into: ```rust async fn run(_: &, F: Foo(), foo: F) -> std::io::Result<()> where <F as Foo>::Bar: Send ^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` Where we want something like: ```rust async fn run<F: Foo>(_: &(), foo: F) -> std::io::Result<()> where <F as Foo>::Bar: Send ^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` The problem is that the elided lifetime of `&()` is added as a generic parameter when desugaring the async fn; the suggestion code sees this as an existing generic parameter and tries to use its span as an anchor to inject `F` into the parameter list. There doesn't seem to be an entirely principled way to check which generic parameters in the HIR were explicitly named in the source, so this commit changes the heuristics when generating the suggestion to only consider type parameters whose spans are contained within the span of the `Generics` when determining how to insert an additional type parameter into the declaration. (And to be safe it also excludes parameters whose spans are marked as originating from desugaring, although that doesn't seem to handle this elided lifetime.)
2020-12-21Rollup merge of #80199 - RalfJung:const-fake, r=oli-obkDylan DPC-7/+40
also const-check FakeRead We need to const-check all statements, including `FakeRead`, to avoid issues like https://github.com/rust-lang/rust/issues/77694. Fixes https://github.com/rust-lang/rust/issues/77694. r? ``@oli-obk``
2020-12-21Rollup merge of #80171 - pierwill:pierwill-rustcmiddle-tykind, r=lcnrDylan DPC-3/+5
Edit rustc_middle::ty::TyKind docs - Add a definition for this enum. - Fix typo and missing punctuation. - Spell out "algebraic data type".
2020-12-21Rollup merge of #80170 - ldm0:fixice, r=lcnrDylan DPC-3/+66
Fix ICE when lookup method in trait for type that have bound vars Closes #77910
2020-12-21Rollup merge of #80166 - pierwill:pierwill-rustcmiddle-place, r=petrochenkovDylan DPC-10/+10
Edit rustc_middle docs Re-word doc comment for rustc_middle::hir::place::Projection. Also adds: - Missing end stop punctuation, and - Documentation links to `rustc_middle::mir::Place`.
2020-12-21Rollup merge of #80159 - jyn514:array, r=m-ou-seDylan DPC-1/+3
Add array search aliases Missed this in https://github.com/rust-lang/rust/pull/80068. This one will really fix https://github.com/rust-lang/rust/issues/46075. The last alias especially I'm a little unsure about - maybe fuzzy search should be fixed in rustdoc instead? Happy to make that change although I'd have to figure out how. r? ``@m-ou-se`` although cc ``@GuillaumeGomez`` for the search issue.
2020-12-21Auto merge of #80088 - operutka:fix-cmsg-len-uclibc, r=dtolnaybors-1/+5
Fix failing build of std on armv5te-unknown-linux-uclibceabi due to missing cmsg_len_zero I'm getting the following error when trying to build `std` on `armv5te-unknown-linux-uclibceabi`: ``` error[E0425]: cannot find value `cmsg_len_zero` in this scope --> /home/operutka/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/ext/net/ancillary.rs:376:47 | 376 | let data_len = (*cmsg).cmsg_len - cmsg_len_zero; | ^^^^^^^^^^^^^ not found in this scope ``` Obviously, this branch: ```rust cfg_if::cfg_if! { if #[cfg(any(target_os = "android", all(target_os = "linux", target_env = "gnu")))] { let cmsg_len_zero = libc::CMSG_LEN(0) as libc::size_t; } else if #[cfg(any( target_os = "dragonfly", target_os = "emscripten", target_os = "freebsd", all(target_os = "linux", target_env = "musl",), target_os = "netbsd", target_os = "openbsd", ))] { let cmsg_len_zero = libc::CMSG_LEN(0) as libc::socklen_t; } } ``` does not cover the case `all(target_os = "linux", target_env = "uclibc")`.
2020-12-20Move std_path construction into conditionDániel Buga-5/+4
2020-12-20Inline a single-use closureDániel Buga-2/+2
2020-12-20Create closure outside of the loopDániel Buga-4/+4
2020-12-20Fix incorrect logic when merging matchesJoshua Nelson-2/+3
2020-12-20Add missing semicolonDániel Buga-1/+1
2020-12-20Remove unnecessary clonedDániel Buga-1/+1
2020-12-20Precompute vector length in smart_resolve_path_fragmentDániel Buga-1/+2
2020-12-20Clean up with_generic_param_rib, avoid double hashingDániel Buga-24/+17
2020-12-20Remove unnecessary scopeJoshua Nelson-0/+2
2020-12-20Get rid of `locate()` in markdown handlingJoshua Nelson-102/+90
This function was unfortunate for several reasons: - It used `unsafe` because it wanted to tell whether a string came from the same *allocation* as another, not just whether it was a textual match. - It recalculated spans even though they were already available from pulldown - It sometimes *failed* to calculate the span, which meant it was always possible for the span to be `None`, even though in practice that should never happen. This commit has several cleanups: - Make the span required - Pass through the span from pulldown in the `HeadingLinks` and `Footnotes` iterators - Only add iterator bounds on the `impl Iterator`, not on `new` and the struct itself.
2020-12-20Auto merge of #78317 - est31:linear_in_impl_count, r=matthewjasperbors-16/+365
Turn quadratic time on number of impl blocks into linear time Previously, if you had a lot of inherent impl blocks on a type like: ```Rust struct Foo; impl Foo { fn foo_1() {} } // ... impl Foo { fn foo_100_000() {} } ``` The compiler would be very slow at processing it, because an internal algorithm would run in O(n^2), where n is the number of impl blocks. Now, we add a new algorithm that allocates but is faster asymptotically. Comparing rustc nightly with a local build of rustc as of this PR (results in seconds): | N | real time before | real time after | | - | - | - | | 4_000 | 0.57 | 0.46 | | 8_000 | 1.31 | 0.84 | | 16_000 | 3.56 | 1.69 | | 32_000 | 10.60 | 3.73 | I've tuned up the numbers to make the effect larger than the startup noise of rustc, but the asymptotic difference should hold for smaller n as well. Note: current state of the PR omits error messages if there are other errors present already. For now, I'm mainly interested in a perf run to study whether this issue is present at all. Please queue one for this PR. Thanks!
2020-12-20Edit rustc_middle docspierwill-10/+10
Re-word doc comment for rustc_middle::hir::place::Projection. Also adds: - Missing end stop punctuation, and - Documentation links to `rustc_middle::mir::Place`.
2020-12-20make sure installer only creates directories in DESTDIRYuxuan Shui-6/+8
Fixes #80238 Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-20Edit rustc_middle::ty::TyKind docspierwill-3/+5
- Add a definition for this enum. - Fix typo and missing punctuation. - Spell out "algebraic data type".
2020-12-20Auto merge of #74699 - notriddle:fd-non-negative, r=m-ou-sebors-6/+27
Mark `-1` as an available niche for file descriptors Based on discussion from <https://internals.rust-lang.org/t/can-the-standard-library-shrink-option-file/12768>, the file descriptor `-1` is chosen based on the POSIX API designs that use it as a sentinel to report errors. A bigger niche could've been chosen, particularly on Linux, but would not necessarily be portable. This PR also adds a test case to ensure that the -1 niche (which is kind of hacky and has no obvious test case) works correctly. It requires the "upper" bound, which is actually -1, to be expressed in two's complement.
2020-12-21Move test from compile-fail to ui/binopDonough Liu-0/+37
2020-12-20Merge commit '4911ab124c481430672a3833b37075e6435ec34d' into clippyupflip1995-1049/+3201
2020-12-20Auto merge of #6482 - flip1995:rustup, r=flip1995bors-8/+35
Rustup r? `@ghost` changelog: none
2020-12-20Bump nightly to 2020-12-20flip1995-1/+1
2020-12-20Merge remote-tracking branch 'upstream/master' into rustupflip1995-1068/+3207
2020-12-20make sure [CONST; N] drops N timesRalf Jung-2/+16
2020-12-20add test that repeating non-Copy constants worksRalf Jung-0/+13
2020-12-20use exhaustive match for checking Rvalue::RepeatRalf Jung-37/+41
2020-12-20Auto merge of #80213 - jryans:bootstrap-skip-dsymutil, r=nagisabors-0/+24
Skip `dsymutil` by default for compiler bootstrap `dsymutil` adds time to builds on Apple platforms for no clear benefit, and also makes it more difficult for debuggers to find debug info (which `@pnkfelix` highlighted on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/does.20lldb.20%28or.20gdb%29.20work.20on.20rustc.20on.20Mac.3F/near/220482092)). The compiler currently defaults to running `dsymutil` to preserve its historical default, but when compiling the compiler itself, we skip it by default since we know it's safe to do so in that case. r? `@nagisa`
2020-12-20Update compiler/rustc_typeck/src/check/op.rsDonough Liu-1/+0
Co-authored-by: lcnr <bastian_kauschke@hotmail.de>
2020-12-20Fix pretty printing an AST representing `&(mut ident)`Thomas Bahn-1/+28
`PatKind::Ref(PatKind::Ident(BindingMode::ByValue(Mutability::Mut), ..), ..)` is an AST representing `&(mut ident)`. It was errorneously printed as `&mut ident` which reparsed into a syntactically different AST. This affected help diagnostics in the parser.
2020-12-20Check that c_int is i32 in FileDesc::new.Mara Bos-1/+1
2020-12-20Fix ICE on suggesting calling functionDonough Liu-2/+29
2020-12-20Auto merge of #80123 - DrMeepster:maybe_uninit_write_slice, r=RalfJungbors-5/+11
Fix memory leak in test "mem::uninit_write_slice_cloned_no_drop" This fixes #80116. I replaced the `Rc` based method I was using with a type that panics when dropped.
2020-12-20Auto merge of #80163 - jackh726:binder-refactor-part-3, r=lcnrbors-181/+183
Make BoundRegion have a kind of BoungRegionKind Split from #76814 Also includes making `replace_escaping_bound_vars` only return `T` Going to r? `@lcnr` Feel free to reassign
2020-12-20Auto merge of #80100 - mark-i-m:pattORns-2, r=petrochenkovbors-75/+193
or_patterns: implement :pat edition-specific behavior cc #54883 `@joshtriplett` This PR implements the edition-specific behavior of `:pat` wrt or-patterns, as determined by the crater runs and T-lang consensus in https://github.com/rust-lang/rust/issues/54883#issuecomment-745509090. I believe this can unblock stabilization of or_patterns. r? `@petrochenkov`
2020-12-20Skip `dsymutil` by default for compiler bootstrapJ. Ryan Stinnett-0/+24
`dsymutil` adds time to builds on Apple platforms for no clear benefit, and also makes it more difficult for debuggers to find debug info. The compiler currently defaults to running `dsymutil` to preserve its historical default, but when compiling the compiler itself, we skip it by default since we know it's safe to do so in that case.
2020-12-19Handle desugaring in impl trait bound suggestionWilliam Bain-13/+95