about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2021-01-13Update code to account for extern ABI requirementMark Rousskov-163/+152
2021-01-13Update tests for extern block lintingMark Rousskov-919/+982
2021-01-13Auto merge of #77858 - ijackson:split-inclusive, r=KodrAusbors-1/+0
Stabilize split_inclusive ### Contents of this MR This stabilises: * `slice::split_inclusive` * `slice::split_inclusive_mut` * `str::split_inclusive` Closes #72360. ### A possible concern The proliferation of `split_*` methods is not particularly pretty. The existence of `split_inclusive` seems to invite the addition of `rsplit_inclusive`, `splitn_inclusive`, etc. We could instead have a more general API, along these kinds of lines maybe: ``` pub fn split_generic('a,P,H>(&'a self, pat: P, how: H) -> ... where P: Pattern where H: SplitHow; pub fn split_generic_mut('a,P,H>(&'a mut self, pat: P, how: H) -> ... where P: Pattern where H: SplitHow; trait SplitHow { fn reverse(&self) -> bool; fn inclusive -> bool; fn limit(&self) -> Option<usize>; } pub struct SplitFwd; ... pub struct SplitRevInclN(pub usize); ``` But maybe that is worse. ### Let us defer that? ### This seems like a can of worms. I think we can defer opening it now; if and when we have something more general, these two methods can become convenience aliases. But I thought I would mention it so the lang API team can consider it and have an opinion.
2021-01-13Auto merge of #80960 - Dylan-DPC:rollup-89tri8x, r=Dylan-DPCbors-41/+449
Rollup of 10 pull requests Successful merges: - #78901 (diagnostics: Note capturing closures can't be coerced to fns) - #79588 (Provide more information for HRTB lifetime errors involving closures) - #80232 (Remove redundant def_id lookups) - #80662 (Added support for i386-unknown-linux-gnu and i486-unknown-linux-gnu) - #80736 (use Once instead of Mutex to manage capture resolution) - #80796 (Update to LLVM 11.0.1) - #80859 (Fix --pretty=expanded with --remap-path-prefix) - #80922 (Revert "Auto merge of #76896 - spastorino:codegen-inline-fns2) - #80924 (Fix rustdoc --test-builder argument parsing) - #80935 (Rename `rustc_middle::lint::LevelSource` to `LevelAndSource`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-01-13Rollup merge of #80924 - teryror:issue-80893-fix, r=jyn514Dylan DPC-5/+7
Fix rustdoc --test-builder argument parsing My suggested fix to issue #80893. I can actually hook Miri in there now. I also fixed what I believe to be a typo in the option's help text.
2021-01-13Rollup merge of #80922 - spastorino:revert-inline-always-in-debug, r=wesleywiserDylan DPC-21/+4
Revert "Auto merge of #76896 - spastorino:codegen-inline-fns2 This reverts commit ddf2cc7f8eb34f1a63b491d6a52e3e8208393c09, reversing changes made to 937f629535f38c655267f1ed21ce6830f592f5df. As `@alexcrichton` pointed out in https://github.com/rust-lang/rust/issues/80916 there's a problem with the taken approach.
2021-01-13Rollup merge of #80859 - jsgf:fix-pretty-remap, r=davidtwcoDylan DPC-0/+20
Fix --pretty=expanded with --remap-path-prefix Per https://github.com/rust-lang/rust/issues/80832, using --pretty=expanded and --remap-path-prefix results in an ICE. This is becasue the session source files table is stored in remapped form, whereas --pretty-expanded looks up unremapped files. This remaps the path prefixes before lookup. ~~There don't appear to be any existing tests for --pretty=expanded; I'll look into adding some.~~ Never mind, found the pretty tests. Fixes #80832
2021-01-13Rollup merge of #80796 - cuviper:llvm-11.0.1, r=nikicDylan DPC-2/+3
Update to LLVM 11.0.1 This updates to a new LLVM branch, rebased on the upstream `llvmorg-11.0.1`. All our patches applied cleanly except the fortanix unwind changes, which just needed a small adjustment in cmake files. r? `@nikic` Fixes https://github.com/rust-lang/rust/issues/73722
2021-01-13Rollup merge of #79588 - estebank:issue-79187, r=oli-obkDylan DPC-13/+328
Provide more information for HRTB lifetime errors involving closures
2021-01-13Rollup merge of #78901 - arora-aman:fix_closure_coerce, r=estebankDylan DPC-0/+87
diagnostics: Note capturing closures can't be coerced to fns Fixes #72457, fixes #71895 r? `@estebank`
2021-01-13Auto merge of #79322 - jyn514:refactor-impl, r=estebankbors-97/+86
Separate out a `hir::Impl` struct This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases. See `rustc_save_analysis::dump_visitor::process_impl` or `rustdoc::clean::clean_impl` for a good example of how this makes `impl`s easier to work with. r? `@petrochenkov` maybe?
2021-01-12Separate out a `hir::Impl` structJoshua Nelson-97/+86
This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases.
2021-01-12Auto merge of #79670 - Nadrieril:uninhabited-query, r=estebankbors-448/+434
Turn type inhabitedness into a query to fix `exhaustive_patterns` perf We measured in https://github.com/rust-lang/rust/pull/79394 that enabling the [`exhaustive_patterns` feature](https://github.com/rust-lang/rust/issues/51085) causes significant perf degradation. It was conjectured that the culprit is type inhabitedness checking, and [I hypothesized](https://github.com/rust-lang/rust/pull/79394#issuecomment-733861149) that turning this computation into a query would solve most of the problem. This PR turns `tcx.is_ty_uninhabited_from` into a query, and I measured a 25% perf gain on the benchmark that stress-tests `exhaustiveness_patterns`. This more than compensates for the 30% perf hit I measured [when creating it](https://github.com/rust-lang/rustc-perf/pull/801). We'll have to measure enabling the feature again, but I suspect this fixes the perf regression entirely. I'd like a perf run on this PR obviously. I made small atomic commits to help reviewing. The first one is just me discovering the "revisions" feature of the testing framework. I believe there's a push to move things out of `rustc_middle` because it's huge. I guess `inhabitedness/mod.rs` could be moved out, but it's quite small. `DefIdForest` might be movable somewhere too. I don't know what the policy is for that. Ping `@camelid` since you were interested in following along `@rustbot` modify labels: +A-exhaustiveness-checking
2021-01-12Provide more information for HRTB lifetime errors involving closuresEsteban Küber-13/+328
2021-01-12Auto merge of #80009 - jumbatm:issue79581-overeager-clashing-extern-decl, ↵bors-0/+21
r=alexcrichton Use tcx.symbol_name when determining clashing extern declarations. Fixes #79581. r? `@alexcrichton`
2021-01-12Add tests for uninhabited typesNadrieril-212/+351
2021-01-12Deduplicate some tests using revisionsNadrieril-227/+74
2021-01-12Auto merge of #78407 - oli-obk:ub_checkable_ctfe, r=RalfJung,pnkfelixbors-129/+223
Make CTFE able to check for UB... ... by not doing any optimizations on the `const fn` MIR used in CTFE. This means we duplicate all `const fn`'s MIR now, once for CTFE, once for runtime. This PR is for checking the perf effect, so we have some data when talking about https://github.com/rust-lang/const-eval/blob/master/rfcs/0000-const-ub.md To do this, we now have two queries for obtaining mir: `optimized_mir` and `mir_for_ctfe`. It is now illegal to invoke `optimized_mir` to obtain the MIR of a const/static item's initializer, an array length, an inline const expression or an enum discriminant initializer. For `const fn`, both `optimized_mir` and `mir_for_ctfe` work, the former returning the MIR that LLVM should use if the function is called at runtime. Similarly it is illegal to invoke `mir_for_ctfe` on regular functions. This is all checked via appropriate assertions and I don't think it is easy to get wrong, as there should be no `mir_for_ctfe` calls outside the const evaluator or metadata encoding. Almost all rustc devs should keep using `optimized_mir` (or `instance_mir` for that matter).
2021-01-12Simplify regression testTristan Dannenberg-4/+3
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-01-12Update help message and add regression testTristan Dannenberg-6/+8
2021-01-12Fix rustdoc --test-builder argument parsingTristan Dannenberg-2/+3
2021-01-12Auto merge of #80517 - wabain:issue-77880-infer-error-try-conversion-msg, ↵bors-3/+68
r=davidtwco Enhance type inference errors involving the `?` operator This patch adds a special-cased note on type inference errors when the error span points to a `?` return. It also makes the primary label for such errors "cannot infer type of `?` error" in cases where before we would have only said "cannot infer type". One beneficiary of this change is async blocks, where we can't explicitly annotate the return type and so may not generate any other help (#77880); this lets us at least print the error type we're converting from and anything we know about the type we can't fully infer. More generally, it signposts that an implicit conversion is happening that may have impeded type inference the user was expecting. We already do something similar for [mismatched type errors](https://github.com/rust-lang/rust/blob/2987785df3d46d5ff144a5c67fbb8f5cca798d78/src/test/ui/try-block/try-block-bad-type.stderr#L7). The check for a relevant `?` operator is built into the existing HIR traversal which looks for places that could be annotated to resolve the error. That means we could identify `?` uses anywhere in the function that output the type we can't infer, but this patch just sticks to adding the note if the primary span given for the error has the operator; if there are other expressions where the type occurs and one of them is selected for the error instead, it's more likely that the `?` operator's implicit conversion isn't the sole cause of the inference failure and that adding an additional diagnostic would just be noise. I added a ui test for one such case. The data about the `?` conversion is passed around in a `UseDiagnostic` enum that in theory could be used to add more of this kind of note in the future. It was also just easier to pass around than something with a more specific name. There are some follow-up refactoring commits for the code that generates the error label, which was already pretty involved and made a bit more complicated by this change.
2021-01-12Rollup merge of #80930 - euclio:trait-method-mutability-help, r=estebankYuki Okushi-15/+12
fix typo in trait method mutability mismatch help
2021-01-12Rollup merge of #80880 - c410-f3r:tests-tests-tests, r=petrochenkovYuki Okushi-10/+0
Move some tests to more reasonable directories The idea is to move `issues`/`ui` tests in small batches r? `@petrochenkov`
2021-01-12Rollup merge of #79757 - jryans:long-line-tab-handling-early-expand, r=estebankYuki Okushi-0/+25
Replace tabs earlier in diagnostics This replaces tabs earlier in the diagnostics emitting process, which allows various margin calculations to ignore the existence of tabs. It does add a string copy for the source lines that are emitted. Fixes https://github.com/rust-lang/rust/issues/78438 r? `@estebank`
2021-01-12Auto merge of #76580 - rokob:iss76011, r=estebankbors-12/+3
Suggest async {} for async || {} Fixes #76011 This adds support for adding help diagnostics to the feature gating checks and then uses it for the async_closure gate to add the extra bit of help information as described in the issue.
2021-01-11fix typo in trait method mutability mismatch helpAndy Russell-15/+12
2021-01-11differentiate functions in extern-compare-with-return-type.rsJosh Stone-2/+3
2021-01-12Rollup merge of #80885 - camelid:intra-doc-str-ref, r=jyn514Yuki Okushi-1/+10
rustdoc: Resolve `&str` as `str` People almost always are referring to `&str`, not `str`, so this will save a manual link resolve in many cases. Note that we already accept `&` (resolves to `reference`) in intra-doc links, so this shouldn't cause breakage. r? `@jyn514`
2021-01-12Rollup merge of #80324 - Aaron1011:loop-move-fn-self, r=oli-obkYuki Okushi-20/+40
Explain method-call move errors in loops PR #73708 added a more detailed explanation of move errors that occur due to a call to a method that takes `self`. This PR extends that logic to work when a move error occurs due to a method call in the previous iteration of a loop.
2021-01-12Rollup merge of #79997 - coolreader18:wasm-reactor, r=alexcrichtonYuki Okushi-8/+10
Emit a reactor for cdylib target on wasi Fixes #79199, and relevant to #73432 Implements wasi reactors, as described in WebAssembly/WASI#13 and [`design/application-abi.md`](https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md) Empty `lib.rs`, `lib.crate-type = ["cdylib"]`: ```shell $ cargo +reactor build --release --target wasm32-wasi Compiling wasm-reactor v0.1.0 (/home/coolreader18/wasm-reactor) Finished release [optimized] target(s) in 0.08s $ wasm-dis target/wasm32-wasi/release/wasm_reactor.wasm >reactor.wat ``` `reactor.wat`: ```wat (module (type $none_=>_none (func)) (type $i32_=>_none (func (param i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $i32_=>_i32 (func (param i32) (result i32))) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import "wasi_snapshot_preview1" "fd_prestat_get" (func $__wasi_fd_prestat_get (param i32 i32) (result i32))) (import "wasi_snapshot_preview1" "fd_prestat_dir_name" (func $__wasi_fd_prestat_dir_name (param i32 i32 i32) (result i32))) (import "wasi_snapshot_preview1" "proc_exit" (func $__wasi_proc_exit (param i32))) (import "wasi_snapshot_preview1" "environ_sizes_get" (func $__wasi_environ_sizes_get (param i32 i32) (result i32))) (import "wasi_snapshot_preview1" "environ_get" (func $__wasi_environ_get (param i32 i32) (result i32))) (memory $0 17) (table $0 1 1 funcref) (global $global$0 (mut i32) (i32.const 1048576)) (global $global$1 i32 (i32.const 1049096)) (global $global$2 i32 (i32.const 1049096)) (export "memory" (memory $0)) (export "_initialize" (func $_initialize)) (export "__data_end" (global $global$1)) (export "__heap_base" (global $global$2)) (func $__wasm_call_ctors (call $__wasilibc_initialize_environ_eagerly) (call $__wasilibc_populate_preopens) ) (func $_initialize (call $__wasm_call_ctors) ) (func $malloc (param $0 i32) (result i32) (call $dlmalloc (local.get $0) ) ) ;; lots of dlmalloc, memset/memcpy, & libpreopen code ) ``` I went with repurposing cdylib because I figured that it doesn't make much sense to have a wasi shared library that can't be initialized, and even if someone was using it adding an `_initialize` export is a very small change.
2021-01-11Move some tests to more reasonable directoriesCaio-10/+0
2021-01-11Revert "Auto merge of #76896 - spastorino:codegen-inline-fns2, ↵Santiago Pastorino-21/+4
r=davidtwco,wesleywiser" This reverts commit ddf2cc7f8eb34f1a63b491d6a52e3e8208393c09, reversing changes made to 937f629535f38c655267f1ed21ce6830f592f5df.
2021-01-11test for issue 80832Jeremy Fitzhardinge-0/+20
2021-01-12Add test case for wasm non-clash.jumbatm-0/+21
2021-01-11--emit=mir now emits both `mir_for_ctfe` and `optimized_mir` for `const fn`oli-0/+65
2021-01-11Rollup merge of #80892 - camelid:intra-doc-remove-star, r=jyn514Yuki Okushi-3/+1
rustdoc: Remove `*` intra-doc alias for `pointer` It's not valid Rust code and it can easily be confused with a wildcard glob pattern or something else. People can always use `pointer` instead, so it's just removing an alias. It hasn't hit stable yet (I think it's still on nightly), so it's okay to remove it. (We can always add it back later if we change our mind too.) r? `@jyn514` cc https://github.com/rust-lang/rust/pull/80885#discussion_r554622737
2021-01-11Rollup merge of #80881 - jyn514:intra-doc-self, r=GuillaumeGomezYuki Okushi-21/+26
Fix intra-doc links to `Self` and `crate` Closes https://github.com/rust-lang/rust/issues/77732.
2021-01-11Rollup merge of #80872 - eltociear:patch-4, r=jonas-schievinkYuki Okushi-1/+1
Fix typo in source-based-code-coverage.md preceeding -> preceding
2021-01-11Rollup merge of #80809 - camelid:rust-call-abi-msg, r=lcnrYuki Okushi-12/+12
Use standard formatting for "rust-call" ABI message Nearly all error messages start with a lowercase letter and don't use articles - instead they refer to the plural case.
2021-01-10Tweak `?` inference error messagesWilliam Bain-8/+8
2021-01-10Note inference failures using `?` conversionWilliam Bain-3/+68
2021-01-10rustdoc: Remove `*` intra-doc alias for `pointer`Camelid-3/+1
It's not valid Rust code and it can easily be confused with a wildcard glob pattern or something else. People can always use `pointer` instead, so it's just removing an alias. It hasn't hit stable yet (I think it's still on nightly), so it's okay to remove it. (We can always add it back later if we change our mind too.)
2021-01-10rustdoc: Resolve `&str` as `str`Camelid-1/+10
People almost always are referring to `&str`, not `str`, so this will save a manual link resolve in many cases. Note that we already accept `&` (resolves to `reference`) in intra-doc links, so this shouldn't cause breakage.
2021-01-10Auto merge of #79414 - ↵bors-1/+1
sasurau4:feature/add-suggestion-for-pattern-in-fns-without-body, r=matthewjasper Add suggestion for PATTERNS_IN_FNS_WITHOUT_BODY ## Overview Fix #78927
2021-01-10Use standard formatting for "rust-call" ABI messageCamelid-12/+12
Nearly all error messages start with a lowercase letter and don't use articles - instead they refer to the plural case.
2021-01-10Auto merge of #80789 - Aaron1011:fix/stmt-empty, r=petrochenkovbors-0/+40
Synthesize a `TokenStream` for `StmtKind::Empty` Fixes #80760
2021-01-10Small cleanupsJoshua Nelson-15/+4
2021-01-10Fix intra-doc links to `Self` and `crate`Joshua Nelson-6/+22
2021-01-10Fix typo in source-based-code-coverage.mdIkko Ashimine-1/+1
preceeding -> preceding