]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoUpdate cargo
Eric Huss [Tue, 14 Apr 2020 16:50:52 +0000 (09:50 -0700)]
Update cargo

4 years agoAuto merge of #70893 - tmiasko:llvm-sanitizers, r=cuviper
bors [Tue, 14 Apr 2020 10:04:47 +0000 (10:04 +0000)]
Auto merge of #70893 - tmiasko:llvm-sanitizers, r=cuviper

Update LLVM submodule fixing sanitizers build with glibc 2.31

Fixes #69556.

4 years agoAuto merge of #70679 - tmandry:issue-68112, r=nikomatsakis
bors [Tue, 14 Apr 2020 06:47:38 +0000 (06:47 +0000)]
Auto merge of #70679 - tmandry:issue-68112, r=nikomatsakis

Improve async-await/generator obligation errors in some cases

Fixes #68112.

This change is best read one commit at a time (I add a test at the beginning and update it in each change after).

The `test2` function is a case I found while writing the test that we don't handle with this code yet. I don't attempt to fix it in this PR, but it's a good candidate for future work.

r? @davidtwco, @nikomatsakis

4 years agoAuto merge of #70643 - Rustin-Liu:rustin-patch-rename, r=eddyb
bors [Tue, 14 Apr 2020 03:11:12 +0000 (03:11 +0000)]
Auto merge of #70643 - Rustin-Liu:rustin-patch-rename, r=eddyb

Rename AssocKind::Method to AssocKind::Fn

Part of https://github.com/rust-lang/rust/issues/60163.

https://github.com/rust-lang/rust/issues/60163#issuecomment-607284413

4 years agoUpdate test after rebase
Tyler Mandry [Tue, 14 Apr 2020 02:14:26 +0000 (19:14 -0700)]
Update test after rebase

4 years agoIncorporate feedback into diagnostics
Tyler Mandry [Wed, 8 Apr 2020 18:54:31 +0000 (11:54 -0700)]
Incorporate feedback into diagnostics

4 years agoFix style nits
Tyler Mandry [Wed, 8 Apr 2020 01:50:27 +0000 (18:50 -0700)]
Fix style nits

4 years agoInclude type info when available for awaited expr
Tyler Mandry [Thu, 2 Apr 2020 02:54:11 +0000 (19:54 -0700)]
Include type info when available for awaited expr

4 years agorustfmt
Tyler Mandry [Thu, 2 Apr 2020 02:14:51 +0000 (19:14 -0700)]
rustfmt

4 years agoDon't double-annotate the same Span
Tyler Mandry [Thu, 2 Apr 2020 02:04:55 +0000 (19:04 -0700)]
Don't double-annotate the same Span

4 years agoUse clearer message when obligation is caused by await expr
Tyler Mandry [Thu, 2 Apr 2020 01:53:00 +0000 (18:53 -0700)]
Use clearer message when obligation is caused by await expr

4 years agoUse "generator" instead of "future" when appropriate
Tyler Mandry [Wed, 25 Mar 2020 04:13:05 +0000 (21:13 -0700)]
Use "generator" instead of "future" when appropriate

4 years agoDon't annotate type when type is opaque
Tyler Mandry [Wed, 25 Mar 2020 02:25:40 +0000 (19:25 -0700)]
Don't annotate type when type is opaque

4 years agoImprove span label
Tyler Mandry [Wed, 25 Mar 2020 01:51:16 +0000 (18:51 -0700)]
Improve span label

4 years agoAdd test for #68112 (existing output)
Tyler Mandry [Wed, 25 Mar 2020 00:23:50 +0000 (17:23 -0700)]
Add test for #68112 (existing output)

4 years agoUse inner/outer generator naming instead of first/last
Tyler Mandry [Wed, 25 Mar 2020 00:06:40 +0000 (17:06 -0700)]
Use inner/outer generator naming instead of first/last

I personally find this clearer.

4 years agoAuto merge of #71111 - Dylan-DPC:rollup-esp17qn, r=Dylan-DPC
bors [Mon, 13 Apr 2020 23:54:52 +0000 (23:54 +0000)]
Auto merge of #71111 - Dylan-DPC:rollup-esp17qn, r=Dylan-DPC

Rollup of 4 pull requests

Successful merges:

 - #70654 (Explain how to work with subtree)
 - #71092 (Remove some usage of `DUMMY_HIR_ID`)
 - #71103 (Add test case for type aliasing `impl Sized`)
 - #71109 (allow const generics in const fn)

Failed merges:

r? @ghost

4 years agoRollup merge of #71109 - lcnr:generics_in_const_fn, r=eddyb
Dylan DPC [Mon, 13 Apr 2020 23:24:18 +0000 (01:24 +0200)]
Rollup merge of #71109 - lcnr:generics_in_const_fn, r=eddyb

allow const generics in const fn

This was explicitly forbidden before. As we were unable to think of a reason
why this should still be the case, this check has been removed.

r? @eddyb
cc @varkor @Centril

4 years agoRollup merge of #71103 - samrat:tait-sized, r=estebank
Dylan DPC [Mon, 13 Apr 2020 23:24:16 +0000 (01:24 +0200)]
Rollup merge of #71103 - samrat:tait-sized, r=estebank

Add test case for type aliasing `impl Sized`

Fixes #71085

4 years agoRollup merge of #71092 - marmeladema:dummy-hir-id-removal, r=eddyb
Dylan DPC [Mon, 13 Apr 2020 23:24:15 +0000 (01:24 +0200)]
Rollup merge of #71092 - marmeladema:dummy-hir-id-removal, r=eddyb

Remove some usage of `DUMMY_HIR_ID`

4 years agoRollup merge of #70654 - oli-obk:subrepo_docs, r=Mark-Simulacrum
Dylan DPC [Mon, 13 Apr 2020 23:24:13 +0000 (01:24 +0200)]
Rollup merge of #70654 - oli-obk:subrepo_docs, r=Mark-Simulacrum

Explain how to work with subtree

cc #70651

r? @centril @RalfJung

This PR just contains the usage documentation, we'll do actual moves in later PRs

4 years agoRename AssocKind::Method to AssocKind::Fn
Rustin-Liu [Wed, 1 Apr 2020 02:09:50 +0000 (10:09 +0800)]
Rename AssocKind::Method to AssocKind::Fn

Rename fn_has_self_argument to fn_has_self_parameter

Rename AssocItemKind::Method to AssocItemKind::Fn

Refine has_no_input_arg

Refine has_no_input_arg

Revert has_no_input_arg

Refine suggestion_descr

Move as_def_kind into AssocKind

Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>
Fix tidy check issue

Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>
4 years agoallow const generics in const fn
Bastian Kauschke [Mon, 13 Apr 2020 20:32:40 +0000 (22:32 +0200)]
allow const generics in const fn

4 years agoAuto merge of #71105 - Dylan-DPC:rollup-nezezxr, r=Dylan-DPC
bors [Mon, 13 Apr 2020 19:47:23 +0000 (19:47 +0000)]
Auto merge of #71105 - Dylan-DPC:rollup-nezezxr, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #70656 (Improve scrollbar display in rustdoc)
 - #71051 (Suggest .into() over try_into() when it would work)
 - #71087 (Remove `FnCtxt::impl_self_ty`)
 - #71097 (Pattern docs)
 - #71101 (Miri: let machine hook dynamically decide about alignment checks)

Failed merges:

r? @ghost

4 years agoRollup merge of #71101 - RalfJung:miri-alignment-check, r=ecstatic-morse
Dylan DPC [Mon, 13 Apr 2020 18:23:33 +0000 (20:23 +0200)]
Rollup merge of #71101 - RalfJung:miri-alignment-check, r=ecstatic-morse

Miri: let machine hook dynamically decide about alignment checks

This is needed for https://github.com/rust-lang/miri/pull/1332.

4 years agoRollup merge of #71097 - pickfire:pattern-docs, r=Dylan-DPC
Dylan DPC [Mon, 13 Apr 2020 18:23:32 +0000 (20:23 +0200)]
Rollup merge of #71097 - pickfire:pattern-docs, r=Dylan-DPC

Pattern docs

https://doc.rust-lang.org/std/str/pattern/trait.Pattern.html#implementors

4 years agoRollup merge of #71087 - JohnTitor:impl-self-ty, r=eddyb
Dylan DPC [Mon, 13 Apr 2020 18:23:30 +0000 (20:23 +0200)]
Rollup merge of #71087 - JohnTitor:impl-self-ty, r=eddyb

Remove `FnCtxt::impl_self_ty`

Fixes #69489
r? @eddyb cc @Centril

4 years agoRollup merge of #71051 - ryr3:fix_try_into, r=estebank
Dylan DPC [Mon, 13 Apr 2020 18:23:29 +0000 (20:23 +0200)]
Rollup merge of #71051 - ryr3:fix_try_into, r=estebank

Suggest .into() over try_into() when it would work

It would be better to suggest x.into() instead, which is shorter, cannot fail, and doesn't require importing a trait.
Tests have been added and made up to date.
Fixes #70851

4 years agoRollup merge of #70656 - GuillaumeGomez:scrollbar-display, r=kinnison
Dylan DPC [Mon, 13 Apr 2020 18:23:27 +0000 (20:23 +0200)]
Rollup merge of #70656 - GuillaumeGomez:scrollbar-display, r=kinnison

Improve scrollbar display in rustdoc

The scrollbar of the left sidebar in rustdoc looks very bad on firefox (on dark theme). This PR improves it:

<div style="display:inline-block;">
<div style="width:50%;display:inline-block;float:left;">
<image src="https://user-images.githubusercontent.com/3050060/78148412-202b0380-7435-11ea-8ff3-79f02ea8f9ed.png">
</div>
<div style="width:50%;display:inline-block;float:left;">
<image src="https://user-images.githubusercontent.com/3050060/78148437-28833e80-7435-11ea-946b-a6fc9320b705.png">
</div>
</div>

With light theme:

![old-firefox-light](https://user-images.githubusercontent.com/3050060/78148718-7bf58c80-7435-11ea-93d3-2a2cafd5c6ae.png)
![firefox-light](https://user-images.githubusercontent.com/3050060/78148736-7f891380-7435-11ea-8b10-a8898f73b4c9.png)

And on chrome:

![chrome-light](https://user-images.githubusercontent.com/3050060/78148903-ac3d2b00-7435-11ea-9a10-6c0376a675c3.png)
![chrome-dark](https://user-images.githubusercontent.com/3050060/78148907-ae9f8500-7435-11ea-9b89-0397b977753c.png)

Small extra question: should I extend it to all scrollbars? I think it'd be better but just in case...

r? @kinnison

4 years agoRemove usage of `DUMMY_HIR_ID` in `FnCtxt::get_conversion_methods`
marmeladema [Mon, 13 Apr 2020 16:57:39 +0000 (17:57 +0100)]
Remove usage of `DUMMY_HIR_ID` in `FnCtxt::get_conversion_methods`

4 years agoAdd test case for type aliasing `impl Sized`
Samrat Man Singh [Mon, 13 Apr 2020 16:44:08 +0000 (22:14 +0530)]
Add test case for type aliasing `impl Sized`

4 years agoAuto merge of #70989 - eddyb:mir-opt-32-pr-ci, r=Mark-Simulacrum
bors [Mon, 13 Apr 2020 16:28:57 +0000 (16:28 +0000)]
Auto merge of #70989 - eddyb:mir-opt-32-pr-ci, r=Mark-Simulacrum

 ci: run mir-opt tests on PR CI also as 32-bit (for `EMIT_MIR_FOR_EACH_BIT_WIDTH`).

Background: #69916 and [`src/test/mir-opt/README.md`](https://github.com/rust-lang/rust/blob/master/src/test/mir-opt/README.md):
> By default 32 bit and 64 bit targets use the same dump files, which can be problematic in the
presence of pointers in constants or other bit width dependent things. In that case you can add
>
> ```
> // EMIT_MIR_FOR_EACH_BIT_WIDTH
> ```
>
> to your test, causing separate files to be generated for 32bit and 64bit systems.

However, if you change the output of such a test (intentionally or not), or if you add a test and it varies between 32-bit and 64-bit platforms, you have to run this command (for a x64 linux host):
`./x.py test --stage 1 --target x86_64-unknown-linux-gnu --target i686-unknown-linux-gnu --bless  src/test/mir-opt`

Otherwise, bors trying to merge the PR will fail, since we test 32-bit targets there.
But we don't on PR CI, which means there's no way the PR author would know (unless they were burnt by this already and know what to look for).

This PR resolves that by running `mir-opt` tests for ~~`i686-unknown-linux-gnu`~~, on PR CI.
**EDIT**: switched to `armv5te-unknown-linux-gnueabi` to work around LLVM 7 crashes (see https://github.com/rust-lang/compiler-builtins/pull/311#issuecomment-612270089), found during testing.

cc @rust-lang/wg-mir-opt @rust-lang/infra

4 years agoMiri: let machine hook dynamically decide about alignment checks
Ralf Jung [Mon, 13 Apr 2020 15:59:12 +0000 (17:59 +0200)]
Miri: let machine hook dynamically decide about alignment checks

4 years agoUse `CRATE_HIR_ID` instead of `DUMMY_HIR_ID` when appropriate.
marmeladema [Mon, 13 Apr 2020 10:09:25 +0000 (11:09 +0100)]
Use `CRATE_HIR_ID` instead of `DUMMY_HIR_ID` when appropriate.

Those usage ends up forwarded to a `ObligationClause` which uses
`CRATE_HIR_ID` for dummy value as seen in `ObligationClause::dummy`.

4 years agoAdd examples to Pattern docs
Ivan Tham [Mon, 13 Apr 2020 14:25:15 +0000 (22:25 +0800)]
Add examples to Pattern docs

4 years agoAdd period to Pattern docs
Ivan Tham [Mon, 13 Apr 2020 14:24:58 +0000 (22:24 +0800)]
Add period to Pattern docs

4 years agoAuto merge of #70961 - ecstatic-morse:into-def-id, r=eddyb
bors [Mon, 13 Apr 2020 12:50:43 +0000 (12:50 +0000)]
Auto merge of #70961 - ecstatic-morse:into-def-id, r=eddyb

Take `impl Into<DefId>` for query methods on `TyCtxt`

Alternative implementation of #70956. cc #70853.

4 years agoJust `unwrap()` instead of `unwrap_or(DUMMY_HIR_ID)`.
marmeladema [Sun, 12 Apr 2020 21:49:34 +0000 (22:49 +0100)]
Just `unwrap()` instead of `unwrap_or(DUMMY_HIR_ID)`.

A valid hir id should always be returned in this case.

4 years agoRemove usage of `DUMMY_HIR_ID` in some visitors
marmeladema [Mon, 13 Apr 2020 10:12:57 +0000 (11:12 +0100)]
Remove usage of `DUMMY_HIR_ID` in some visitors

4 years agoRemove useless calls to `assemble_extension_candidates_for_traits_in_scope`
marmeladema [Sun, 12 Apr 2020 20:22:30 +0000 (21:22 +0100)]
Remove useless calls to `assemble_extension_candidates_for_traits_in_scope`

Calls to `assemble_extension_candidates_for_traits_in_scope` with
`DUMMY_HIR_ID` as `expr_hir_id` are useless because the first thing
that this function does is to return `Ok(())` in this case.

4 years agoAuto merge of #70882 - tmiasko:llvm-version-suffix, r=Mark-Simulacrum
bors [Mon, 13 Apr 2020 07:34:11 +0000 (07:34 +0000)]
Auto merge of #70882 - tmiasko:llvm-version-suffix, r=Mark-Simulacrum

Make LLVM version suffix independent of rustc version on dev channel

Remove rustc version from LLVM version suffix on dev channel,
avoiding the need for full rebuilds when switching between
branches with different LLVM submodule & rustc version.

Note: To avoid full rebuild, on subsequent LLVM submodule update, copy the
current value of `LLVM_VERSION_SUFFIX` from `build/*/llvm/build/CMakeCache.txt`,
to `version-suffix` in `config.toml`.

4 years agoAuto merge of #71056 - matthiaskrgr:submodule_upd, r=Dylan-DPC
bors [Mon, 13 Apr 2020 04:16:08 +0000 (04:16 +0000)]
Auto merge of #71056 - matthiaskrgr:submodule_upd, r=Dylan-DPC

submodules: update clippy from d342cee7 to af5940b7

Changes:
````
Allow UUID style formatting for `inconsistent_digit_grouping` lint
rustup https://github.com/rust-lang/rust/pull/70986
rustup https://github.com/rust-lang/rust/pull/69745
Rustup to https://github.com/rust-lang/rust/pull/70913
compare with the second largest instead of the smallest variant
Revert "Downgrade new_ret_no_self to pedantic"
Check for clone-on-copy in argument positions
Check fn header along with decl when suggesting to implement trait
Downgrade implicit_hasher to pedantic
Move cognitive_complexity to nursery
Run fmt and update test
Use int assoc consts in MANUAL_SATURATING_ARITHMETIC
Use int assoc consts in checked_conversions lint
Use primitive type assoc consts in more tests
Use integer assoc consts in more lint example code
Don't import primitive type modules
Use assoc const NAN for zero_div_zero lint
Fix float cmp to use assoc fxx::EPSILON
Fix NAN comparison lint to use assoc NAN
Refine lint message.
Lint on opt.as_ref().map(|x| &**x).
Include OpAssign in suspicious_op_assign_impl
result_map_or_into_option: fix syntax error in example
result_map_or_into: fix dogfood_clippy error => {h,l}int
CONTRIBUTING.md: fix broken triage link
result_map_or_into_option: fix `cargo dev fmt --check` errors
result_map_or_into_option: move arg checks into tuple assignment
result_map_or_into_option: add `opt.map_or(None, |_| Some(y))` test
result_map_or_into_option: destructure lint tuple or return early
result_map_or_into_option: add good and bad examples
result_map_or_into_option: explicitly note absence of known problems
Downgrade new_ret_no_self to pedantic
Downgrade unreadable_literal to pedantic
Update CONTRIBUTING.md
Rename rustc -> rustc_middle in doc links
result_map_or_into_option: add lint to catch manually adpating Result -> Option
Move matches test in matches module
Run update_lints
Make lint modules private
Don't filter lints in code generation functions
Build lint lists once and the reuse them to update files
Get rid of Lint::is_internal method
Clean up update_lints
Downgrade inefficient_to_string to pedantic
Downgrade trivially_copy_pass_by_ref to pedantic
Downgrade let_unit_value to pedantic
````
Fixes #70993

r? @Dylan-DPC

4 years agoRemove `FnCtxt::impl_self_ty`
Yuki Okushi [Mon, 13 Apr 2020 02:36:37 +0000 (11:36 +0900)]
Remove `FnCtxt::impl_self_ty`

4 years agoAuto merge of #71023 - mati865:mingw-unwind-linking-cleanup, r=Amanieu
bors [Mon, 13 Apr 2020 00:59:36 +0000 (00:59 +0000)]
Auto merge of #71023 - mati865:mingw-unwind-linking-cleanup, r=Amanieu

[windows] Add testscase for self-contained executables and fix pthread linking

Fixes https://github.com/rust-lang/rust/issues/71061

4 years agoAuto merge of #71079 - Dylan-DPC:rollup-g7yh3sn, r=Dylan-DPC
bors [Sun, 12 Apr 2020 21:48:24 +0000 (21:48 +0000)]
Auto merge of #71079 - Dylan-DPC:rollup-g7yh3sn, r=Dylan-DPC

Rollup of 4 pull requests

Successful merges:

 - #67766 (Fix warning for unused variables in or pattern (issue #67691))
 - #71013 (Pass the `PlaceElem::Index` local to `visit_local`)
 - #71064 (fix issue 69130)
 - #71069 (Remove some usage of `DUMMY_HIR_ID`)

Failed merges:

r? @ghost

4 years agoRollup merge of #71069 - marmeladema:dummy-hir-id-obligation-clause, r=eddyb
Dylan DPC [Sun, 12 Apr 2020 21:47:41 +0000 (23:47 +0200)]
Rollup merge of #71069 - marmeladema:dummy-hir-id-obligation-clause, r=eddyb

Remove some usage of `DUMMY_HIR_ID`

Use `ObligationClause::dummy()` when appropriate or replace `hir::DUMMY_HIR_ID`by `hir::CRATE_HIR_ID`, as used in `ObligationClause::dummy()`.

4 years agoRollup merge of #71064 - dwrensha:issue-69130, r=eddyb
Dylan DPC [Sun, 12 Apr 2020 21:47:39 +0000 (23:47 +0200)]
Rollup merge of #71064 - dwrensha:issue-69130, r=eddyb

fix issue 69130

Closes #69130.

4 years agoRollup merge of #71013 - jonas-schievink:visit-projection, r=eddyb
Dylan DPC [Sun, 12 Apr 2020 21:47:38 +0000 (23:47 +0200)]
Rollup merge of #71013 - jonas-schievink:visit-projection, r=eddyb

Pass the `PlaceElem::Index` local to `visit_local`

Fixes https://github.com/rust-lang/rust/issues/71008

cc @rust-lang/wg-mir-opt

r? @spastorino

4 years agoRollup merge of #67766 - sapir:fix-unused-in-or-pattern-warning, r=matthewjasper
Dylan DPC [Sun, 12 Apr 2020 21:47:36 +0000 (23:47 +0200)]
Rollup merge of #67766 - sapir:fix-unused-in-or-pattern-warning, r=matthewjasper

Fix warning for unused variables in or pattern (issue #67691)

Is this a good way to fix it?

Also, the tests fail, the "fixed" code output says `{ i, j }` instead of `{ i, j: _ }`, how can I fix that?

4 years agoRemove usage of `DUMMY_HIR_ID` in `Scope::hir_id`
marmeladema [Sun, 12 Apr 2020 19:59:13 +0000 (20:59 +0100)]
Remove usage of `DUMMY_HIR_ID` in `Scope::hir_id`

4 years agoRemove usage of `DUMMY_HIR_ID` in `CheckAttrVisitor::check_inline`
marmeladema [Sun, 12 Apr 2020 19:57:43 +0000 (20:57 +0100)]
Remove usage of `DUMMY_HIR_ID` in `CheckAttrVisitor::check_inline`

4 years agoRemove usage of `DUMMY_HIR_ID` in `CheckLoopVisitor`
marmeladema [Sun, 12 Apr 2020 18:20:07 +0000 (19:20 +0100)]
Remove usage of `DUMMY_HIR_ID` in `CheckLoopVisitor`

4 years agoRemove usage of `DUMMY_HIR_ID` in calls to `ObligationClause::misc`
marmeladema [Sun, 12 Apr 2020 17:42:45 +0000 (18:42 +0100)]
Remove usage of `DUMMY_HIR_ID` in calls to `ObligationClause::misc`

Use `ObligationClause::dummy()` when appropriate or replace
`hir::DUMMY_HIR_ID` by `hir::CRATE_HIR_ID`, as used in
`ObligationClause::dummy()`.

4 years ago[windows-gnu] Link pthread statically
Mateusz Mikuła [Sun, 12 Apr 2020 16:11:11 +0000 (18:11 +0200)]
[windows-gnu] Link pthread statically

4 years agoAuto merge of #71059 - Dylan-DPC:rollup-zgu6jmx, r=Dylan-DPC
bors [Sun, 12 Apr 2020 18:09:46 +0000 (18:09 +0000)]
Auto merge of #71059 - Dylan-DPC:rollup-zgu6jmx, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #71029 (Partial work on building with Cargo)
 - #71034 (Clean up E0515 explanation)
 - #71041 (Update links of `rustc guide`)
 - #71048 (Normalize source when loading external foreign source into SourceMap)
 - #71053 (Add some basic docs to `sym` and `kw` modules)
 - #71057 (Clean up E0516 explanation)

Failed merges:

r? @ghost

4 years agofix issue 69130
David Renshaw [Sun, 12 Apr 2020 15:36:37 +0000 (11:36 -0400)]
fix issue 69130

4 years agoRollup merge of #71057 - GuillaumeGomez:cleanup-e0516, r=Dylan-DPC
Dylan DPC [Sun, 12 Apr 2020 12:49:10 +0000 (14:49 +0200)]
Rollup merge of #71057 - GuillaumeGomez:cleanup-e0516, r=Dylan-DPC

Clean up E0516 explanation

r? @Dylan-DPC

4 years agoRollup merge of #71053 - phansch:update_kw_sym_docs, r=Dylan-DPC
Dylan DPC [Sun, 12 Apr 2020 12:49:08 +0000 (14:49 +0200)]
Rollup merge of #71053 - phansch:update_kw_sym_docs, r=Dylan-DPC

Add some basic docs to `sym` and `kw` modules

I was looking into improving some Clippy documentation but was missing a
place that explains the `kw` and `sym` modules from rustc.

This adds some very basic usage documentation to these modules.

4 years agoRollup merge of #71048 - arlosi:normalize_ext_src, r=eddyb
Dylan DPC [Sun, 12 Apr 2020 12:49:06 +0000 (14:49 +0200)]
Rollup merge of #71048 - arlosi:normalize_ext_src, r=eddyb

Normalize source when loading external foreign source into SourceMap

The compiler normalizes source when reading files initially (removes BOMs, etc), but not when loading external sources.

This leads to the external source matching according to the `src_hash`, but differing internally because it was not normalized.

Fixes #70874.

4 years agoRollup merge of #71041 - JohnTitor:rustc-dev-guide, r=jonas-schievink
Dylan DPC [Sun, 12 Apr 2020 12:49:05 +0000 (14:49 +0200)]
Rollup merge of #71041 - JohnTitor:rustc-dev-guide, r=jonas-schievink

Update links of `rustc guide`

Picks up the things we left behind in the transition, hopefully they're last ones.

r? @spastorino

4 years agoRollup merge of #71034 - GuillaumeGomez:cleanup-e0515, r=Dylan-DPC
Dylan DPC [Sun, 12 Apr 2020 12:49:03 +0000 (14:49 +0200)]
Rollup merge of #71034 - GuillaumeGomez:cleanup-e0515, r=Dylan-DPC

Clean up E0515 explanation

r? @Dylan-DPC

4 years agoRollup merge of #71029 - Mark-Simulacrum:cargo-build, r=Mark-Simulacrum
Dylan DPC [Sun, 12 Apr 2020 12:49:01 +0000 (14:49 +0200)]
Rollup merge of #71029 - Mark-Simulacrum:cargo-build, r=Mark-Simulacrum

Partial work on building with Cargo

This cherry picks the commits I'm directly approving from #70999, I want to land them so that that PR is smaller.

4 years agoAuto merge of #70873 - mark-i-m:update-rdg, r=JohnTitor
bors [Sun, 12 Apr 2020 12:46:47 +0000 (12:46 +0000)]
Auto merge of #70873 - mark-i-m:update-rdg, r=JohnTitor

Update rustc-dev-guide

This should finally fix toolstate

r? @JohnTitor

4 years agoClean up E0516 explanation
Guillaume Gomez [Sun, 12 Apr 2020 11:58:05 +0000 (13:58 +0200)]
Clean up E0516 explanation

4 years agosubmodules: update clippy from d342cee7 to af5940b7
Matthias Krüger [Sun, 12 Apr 2020 11:08:47 +0000 (13:08 +0200)]
submodules: update clippy from d342cee7 to af5940b7

Changes:
````
Allow UUID style formatting for `inconsistent_digit_grouping` lint
rustup https://github.com/rust-lang/rust/pull/70986
rustup https://github.com/rust-lang/rust/pull/69745
Rustup to https://github.com/rust-lang/rust/pull/70913
compare with the second largest instead of the smallest variant
Revert "Downgrade new_ret_no_self to pedantic"
Check for clone-on-copy in argument positions
Check fn header along with decl when suggesting to implement trait
Downgrade implicit_hasher to pedantic
Move cognitive_complexity to nursery
Run fmt and update test
Use int assoc consts in MANUAL_SATURATING_ARITHMETIC
Use int assoc consts in checked_conversions lint
Use primitive type assoc consts in more tests
Use integer assoc consts in more lint example code
Don't import primitive type modules
Use assoc const NAN for zero_div_zero lint
Fix float cmp to use assoc fxx::EPSILON
Fix NAN comparison lint to use assoc NAN
Refine lint message.
Lint on opt.as_ref().map(|x| &**x).
Include OpAssign in suspicious_op_assign_impl
result_map_or_into_option: fix syntax error in example
result_map_or_into: fix dogfood_clippy error => {h,l}int
CONTRIBUTING.md: fix broken triage link
result_map_or_into_option: fix `cargo dev fmt --check` errors
result_map_or_into_option: move arg checks into tuple assignment
result_map_or_into_option: add `opt.map_or(None, |_| Some(y))` test
result_map_or_into_option: destructure lint tuple or return early
result_map_or_into_option: add good and bad examples
result_map_or_into_option: explicitly note absence of known problems
Downgrade new_ret_no_self to pedantic
Downgrade unreadable_literal to pedantic
Update CONTRIBUTING.md
Rename rustc -> rustc_middle in doc links
result_map_or_into_option: add lint to catch manually adpating Result -> Option
Move matches test in matches module
Run update_lints
Make lint modules private
Don't filter lints in code generation functions
Build lint lists once and the reuse them to update files
Get rid of Lint::is_internal method
Clean up update_lints
Downgrade inefficient_to_string to pedantic
Downgrade trivially_copy_pass_by_ref to pedantic
Downgrade let_unit_value to pedantic
````
Fixes #70993

4 years agoAdd some basic docs to `sym` and `kw` modules
Philipp Hansch [Sun, 12 Apr 2020 07:45:08 +0000 (09:45 +0200)]
Add some basic docs to `sym` and `kw` modules

I was looking into improving some Clippy documentation but was missing a
place that explains the `kw` and `sym` modules from rustc.

4 years agoAdd blessed tests after compiler message fix
Yashhwanth Ram [Sun, 12 Apr 2020 06:42:46 +0000 (12:12 +0530)]
Add blessed tests after compiler message fix

4 years agoFix order of comparison and remove incorrect case for ints in typeck/demand.rs
Yashhwanth Ram [Sun, 12 Apr 2020 04:32:02 +0000 (10:02 +0530)]
Fix order of comparison and remove incorrect case for ints in typeck/demand.rs
Add tests for *size

4 years agoAuto merge of #69707 - estebank:impl-trait-missing-bounds, r=Centril
bors [Sun, 12 Apr 2020 06:32:45 +0000 (06:32 +0000)]
Auto merge of #69707 - estebank:impl-trait-missing-bounds, r=Centril

Handle `impl Trait` where `Trait` has an assoc type with missing bounds

When encountering a type parameter that needs more bounds the trivial case is `T` `where T: Bound`, but it can also be an `impl Trait` param that needs to be decomposed to a type param for cleaner code. For example, given

```rust
fn foo(constraints: impl Iterator) {
    for constraint in constraints {
        println!("{:?}", constraint);
    }
}
```

the previous output was

```
error[E0277]: `<impl Iterator as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug`
 --> src/main.rs:3:26
  |
1 | fn foo(constraints: impl Iterator) {
  |                                    - help: consider further restricting the associated type: `where <impl Iterator as std::iter::Iterator>::Item: std::fmt::Debug`
2 |     for constraint in constraints {
3 |         println!("{:?}", constraint);
  |                          ^^^^^^^^^^ `<impl Iterator as std::iter::Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
  |
  = help: the trait `std::fmt::Debug` is not implemented for `<impl Iterator as std::iter::Iterator>::Item`
  = note: required by `std::fmt::Debug::fmt`
```

which is incorrect as `where <impl Iterator as std::iter::Iterator>::Item: std::fmt::Debug` is not valid syntax nor would it restrict the positional `impl Iterator` parameter if it were.

The output being introduced is

```
error[E0277]: `<impl Iterator as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug`
 --> src/main.rs:3:26
  |
3 |         println!("{:?}", constraint);
  |                          ^^^^^^^^^^ `<impl Iterator as std::iter::Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
  |
  = help: the trait `std::fmt::Debug` is not implemented for `<impl Iterator as std::iter::Iterator>::Item`
  = note: required by `std::fmt::Debug::fmt`
help: introduce a type parameter with a trait bound instead of using `impl Trait`
   |
LL | fn foo<T: Iterator>(constraints: T) where <T as std::iter::Iterator>::Item: std::fmt::Debug  {
   |       ^^^^^^^^^^^^^              ^  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

This suggestion is correct and lead the user in the right direction: because you have an associated type restriction you can no longer use `impl Trait`, the only reasonable alternative is to introduce a named type parameter, bound by `Trait` and with a `where` binding on the associated type for the new type parameter `as Trait` for the missing bound.

*Ideally*, we would want to suggest something like the following, but that is not valid syntax today

```
error[E0277]: `<impl Iterator as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug`
 --> src/main.rs:3:26
  |
3 |         println!("{:?}", constraint);
  |                          ^^^^^^^^^^ `<impl Iterator as std::iter::Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
  |
  = help: the trait `std::fmt::Debug` is not implemented for `<impl Iterator as std::iter::Iterator>::Item`
  = note: required by `std::fmt::Debug::fmt`
help: introduce a type parameter with a trait bound instead of using `impl Trait`
   |
LL | fn foo(constraints: impl Iterator<Item: std::fmt::Debug>) {
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

Fix #69638.

4 years agoNormalize source when loading external foreign source into SourceMap
Arlo Siemsen [Sun, 12 Apr 2020 03:21:51 +0000 (20:21 -0700)]
Normalize source when loading external foreign source into SourceMap

The compiler normalizes source when reading files initially (removes BOMs, etc), but not when loading external sources.

Fixes #70874 by normalizing when loading external sources too. Adds a test to verify normalization.

4 years agoAuto merge of #69926 - RoccoDev:master, r=estebank,varkor
bors [Sun, 12 Apr 2020 00:31:11 +0000 (00:31 +0000)]
Auto merge of #69926 - RoccoDev:master, r=estebank,varkor

rustc: Add a warning count upon completion

This adds a `build completed with one warning/x warnings` message, similar to the already present `aborted due to previous error` message.

4 years agoAdd `#[inline(always)]` to `into_query_param`
Dylan MacKenzie [Sat, 11 Apr 2020 23:29:50 +0000 (16:29 -0700)]
Add `#[inline(always)]` to `into_query_param`

4 years agoApply suggestions from review
Dylan MacKenzie [Fri, 10 Apr 2020 21:06:57 +0000 (14:06 -0700)]
Apply suggestions from review

4 years agoUse custom trait instead of `Into`
Dylan MacKenzie [Fri, 10 Apr 2020 20:54:06 +0000 (13:54 -0700)]
Use custom trait instead of `Into`

4 years agoSimplify macro
Dylan MacKenzie [Fri, 10 Apr 2020 20:44:15 +0000 (13:44 -0700)]
Simplify macro

4 years agoRemove call to `to_def_id` before calling query helper
Dylan MacKenzie [Thu, 9 Apr 2020 17:30:21 +0000 (10:30 -0700)]
Remove call to `to_def_id` before calling query helper

4 years agoFix inference fallout
Dylan MacKenzie [Thu, 9 Apr 2020 17:29:55 +0000 (10:29 -0700)]
Fix inference fallout

4 years agoImpl `From<LocalDefId>` for `DefId`
Dylan MacKenzie [Thu, 9 Apr 2020 17:29:37 +0000 (10:29 -0700)]
Impl `From<LocalDefId>` for `DefId`

4 years agoMake query helpers on `TyCtxt` take `impl Into<DefId>`
Dylan MacKenzie [Thu, 9 Apr 2020 17:29:08 +0000 (10:29 -0700)]
Make query helpers on `TyCtxt` take `impl Into<DefId>`

4 years agofix rebase
Esteban Küber [Sat, 11 Apr 2020 21:59:15 +0000 (14:59 -0700)]
fix rebase

4 years agoMake panic-unwind a default feature for libstd
Luca Barbieri [Fri, 10 Apr 2020 20:42:20 +0000 (22:42 +0200)]
Make panic-unwind a default feature for libstd

x.py sets it unconditionally, so want it for plain "cargo build".

We need to load one of the panic runtimes that is in src (vs. pre-built in the
compiler's sysroot) to ensure that we don't load libpanic_unwind from the
sysroot. That would lead to a load of libcore, also from the sysroot, and create
lots of errors about duplicate lang items.

4 years agoDon't emit rerun-if-changed on llvm-config if using system LLVM
Luca Barbieri [Fri, 10 Apr 2020 20:42:19 +0000 (22:42 +0200)]
Don't emit rerun-if-changed on llvm-config if using system LLVM

The code was broken because it printed "llvm-config" instead of the
absolute path to the llvm-config executable, causing Cargo to always
rebuild librustc_llvm if using system LLVM.

Also, it's not the build system's job to rebuild when a system library
changes, so we simply don't emit "rerun-if-changed" if a path to LLVM
was not explicitly provided.

4 years agoRequire compiler-rt root at ../src/llvm-project/compiler-rt
Luca Barbieri [Fri, 10 Apr 2020 20:42:19 +0000 (22:42 +0200)]
Require compiler-rt root at ../src/llvm-project/compiler-rt

4 years agoDepend on getopts from crates.io
Luca Barbieri [Fri, 10 Apr 2020 20:42:19 +0000 (22:42 +0200)]
Depend on getopts from crates.io

rustc_session exports it for other crates to avoid mismatching
crate versions.

4 years agoreview comments
Esteban Küber [Fri, 10 Apr 2020 17:40:47 +0000 (10:40 -0700)]
review comments

4 years agoreview comments
Esteban Küber [Sun, 5 Apr 2020 22:33:33 +0000 (15:33 -0700)]
review comments

4 years agoTry to use the first char in the trait name as type param
Esteban Küber [Sun, 5 Apr 2020 21:55:06 +0000 (14:55 -0700)]
Try to use the first char in the trait name as type param

4 years agoAccount for existing names when suggesting adding a type param
Esteban Küber [Sun, 5 Apr 2020 20:13:13 +0000 (13:13 -0700)]
Account for existing names when suggesting adding a type param

4 years agoAccount for type params with bounds
Esteban Küber [Sun, 5 Apr 2020 19:32:34 +0000 (12:32 -0700)]
Account for type params with bounds

4 years agoreview comments
Esteban Küber [Sun, 5 Apr 2020 17:52:54 +0000 (10:52 -0700)]
review comments

4 years agoreview comments
Esteban Küber [Sun, 5 Apr 2020 00:31:32 +0000 (17:31 -0700)]
review comments

4 years agoHandle `impl Trait` where `Trait` has an assoc type with missing bounds
Esteban Küber [Wed, 4 Mar 2020 18:50:05 +0000 (10:50 -0800)]
Handle `impl Trait` where `Trait` has an assoc type with missing bounds

Fix #69638.

4 years agoAuto merge of #71031 - Dylan-DPC:rollup-zr8hh86, r=Dylan-DPC
bors [Sat, 11 Apr 2020 21:19:28 +0000 (21:19 +0000)]
Auto merge of #71031 - Dylan-DPC:rollup-zr8hh86, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #70644 (Clean up `ModuleConfig` initialization)
 - #70937 (Fix staticlib name for *-pc-windows-gnu targets)
 - #70996 (Add or_insert_with_key to Entry of HashMap/BTreeMap)
 - #71020 (Store UNICODE_VERSION as a tuple)
 - #71021 (Use write!-style syntax for MIR assert terminator)

Failed merges:

r? @ghost

4 years agoUpdate links of `rustc guide`
Yuki Okushi [Sat, 11 Apr 2020 20:02:35 +0000 (05:02 +0900)]
Update links of `rustc guide`

4 years ago[windows] Add testcase to make sure executables are self-contained
Mateusz Mikuła [Sat, 11 Apr 2020 11:22:21 +0000 (13:22 +0200)]
[windows] Add testcase to make sure executables are self-contained

4 years agoClean up E0515 explanation
Guillaume Gomez [Sat, 11 Apr 2020 16:58:03 +0000 (18:58 +0200)]
Clean up E0515 explanation

4 years agoRollup merge of #71021 - robojumper:71000-mir-assert-syntax, r=jonas-schievink
Dylan DPC [Sat, 11 Apr 2020 15:52:14 +0000 (17:52 +0200)]
Rollup merge of #71021 - robojumper:71000-mir-assert-syntax, r=jonas-schievink

Use write!-style syntax for MIR assert terminator

Fixes #71000.

r? @jonas-schievink

4 years agoRollup merge of #71020 - pyfisch:unicode-version, r=sfackler
Dylan DPC [Sat, 11 Apr 2020 15:52:13 +0000 (17:52 +0200)]
Rollup merge of #71020 - pyfisch:unicode-version, r=sfackler

Store UNICODE_VERSION as a tuple

Remove the UnicodeVersion struct containing
major, minor and update fields and replace it with
a 3-tuple containing the version number.
As the value of each field is limited to 255
use u8 to store them.

4 years agoRollup merge of #70996 - ChaiTRex:master, r=Amanieu
Dylan DPC [Sat, 11 Apr 2020 15:52:11 +0000 (17:52 +0200)]
Rollup merge of #70996 - ChaiTRex:master, r=Amanieu

Add or_insert_with_key to Entry of HashMap/BTreeMap

Going along with `or_insert_with`, `or_insert_with_key` provides the `Entry`'s key to the lambda, avoiding the need to either clone the key or the need to reimplement this body of this method from scratch each time.

This is useful when the initial value for a map entry is derived from the key. For example, the introductory Rust book has an example Cacher struct that takes an expensive-to-compute lambda and then can, given an argument to the lambda, produce either the cached result or execute the lambda.

---

I'm fairly new to Rust, so any optimizations, corrections to types, better names, better documentation, or whatever else would be appreciated. I'd like to thank Arnavion on freenode for helping me to implement a very similar method when I found that `or_insert_with_key` was unavailable.

As a somewhat-related note, this implements https://github.com/rust-lang/rfcs/issues/1202 from 2015, so if this pull request is accepted, that should be closed.

4 years agoRollup merge of #70937 - mati865:mingw-staticlib-suffix, r=petrochenkov
Dylan DPC [Sat, 11 Apr 2020 15:52:10 +0000 (17:52 +0200)]
Rollup merge of #70937 - mati865:mingw-staticlib-suffix, r=petrochenkov

Fix staticlib name for *-pc-windows-gnu targets

Fix https://github.com/rust-lang/rust/issues/69904

Guess this will need FCP but opened PR anyway to bring the attention.

In short Rust has been using wrong `foo.lib` format for static libraries when building for `*-pc-windows-gnu` since version [1.8.0](https://github.com/rust-lang/rust/commit/34b4e66736a0fb65235feadbb5178d42bd09ed67).
[LD](https://github.com/bminor/binutils-gdb/blob/f4a220077b03af3a1f905b7dc6dc84c0a06d582f/ld/emultempl/pe.em#L2224-L2227) and [LLD](https://github.com/llvm/llvm-project/blob/0605f5fbe755326e3dbc8daa4fc34453b8c5ac0e/lld/MinGW/Driver.cpp#L140-L141) agree in that regard and only accept static libraries with `libfoo.a` format. So the only thing to break here is when somebody added a hack to rename created library to proper format (like [here](https://gitlab.gnome.org/GNOME/librsvg/-/commit/ad86ab8580c8779fc3eb2bee2422bb116919844e#d5b4de16d947214ec306bd57bed1bd23a939b5f9_197_194)).