Commit graph

28084 commits

Author SHA1 Message Date
Vadim Petrochenkov
642669c74d Update tests 2020-01-09 21:23:12 +03:00
Mazdak Farrokhzad
5e6eeb092d
Rollup merge of #68024 - petrochenkov:recoverall, r=Centril
Remove `-Z continue-parse-after-error`

We are just always recovering and continuing now.

r? @estebank @Centril
2020-01-09 00:22:20 +01:00
Mazdak Farrokhzad
d2922e51a7
Rollup merge of #68023 - FSciammarella:master, r=Centril,varkor
Fix issue #68008

Correcting Typo on error message. From "substract" to "subtract".

Fixes #68008.
2020-01-09 00:22:18 +01:00
Mazdak Farrokhzad
916a7d3a2c
Rollup merge of #67990 - Centril:slice-pats-move-tests-match, r=matthewjasper
slice patterns: harden match-based borrowck tests

This hardens some move-checking tests wrt. slice patterns and `match` expressions.

r? @matthewjasper
cc @pnkfelix
cc https://github.com/rust-lang/rust/pull/67712
cc https://github.com/rust-lang/rust/issues/53114
2020-01-09 00:22:14 +01:00
Mazdak Farrokhzad
0b3ef24e75
Rollup merge of #67979 - Centril:hir-cleanup, r=Zoxc
Move `intravisit` => `rustc_hir` + misc cleanup

Working towards https://github.com/rust-lang/rust/issues/65031.
This should eventually enable getting rid of rustc as a dependency in various passes (e.g. lints).

cc https://github.com/rust-lang/rust/pull/67806 (this also facilitates liberating lints from tcx)
cc https://github.com/rust-lang/rust/pull/67922 (some other dep reductions)

r? @Zoxc
2020-01-09 00:22:11 +01:00
Mazdak Farrokhzad
1a0b2a5aaa
Rollup merge of #67747 - estebank:bare-assoc-const, r=Centril
Explain that associated types and consts can't be accessed directly on the trait's path

Partially address #44539.
2020-01-09 00:22:07 +01:00
Mazdak Farrokhzad
60bef14bbc
Rollup merge of #67630 - oli-obk:extern_ptr_dangling, r=spastorino
Treat extern statics just like statics in the "const pointer to static" representation

fixes #67612

r? @spastorino

cc @RalfJung this does not affect runtime promotion at all. This is just about promotion within static item bodies.
2020-01-09 00:22:05 +01:00
Felipe Sciammarella
7de174b86e Fix Typo on cannot "substract"
Fix Typo on hir::BinOpKind::Sub

"substract" to "subtract"

Fix Typo on "Error cannot substract"

Fix Typo on cannot "substract"
2020-01-08 19:25:38 -03:00
Mazdak Farrokhzad
0997388b87 normalize rustc::hir::intravisit imports 2020-01-08 22:09:42 +01:00
Vadim Petrochenkov
41a93cba38 Remove -Z continue-parse-after-error 2020-01-08 21:48:04 +03:00
Esteban Küber
ac3d4cccea Explain that associated types and consts can't be accessed directly on the trait's path 2020-01-08 09:41:51 -08:00
Yuki Okushi
1f94425864
Rollup merge of #67955 - ollie27:rustdoc_cfg_dupes, r=GuillaumeGomez
rustdoc: Remove more `#[doc(cfg(..))]` duplicates

This is a follow up to #66959.

r? @GuillaumeGomez
2020-01-09 00:29:17 +09:00
Yuki Okushi
1c9b8036bf
Rollup merge of #67887 - anp:tracked-std-panics, r=nagisa
`Option::{expect,unwrap}` and `Result::{expect, expect_err, unwrap, unwrap_err}` have `#[track_caller]`

The annotated functions now produce panic messages pointing to the location where they were called, rather than `core`'s internals.
2020-01-09 00:29:15 +09:00
Yuki Okushi
03fe834a23
Rollup merge of #67875 - dtolnay:hidden, r=GuillaumeGomez
Distinguish between private items and hidden items in rustdoc

I believe rustdoc should not be conflating private items (visibility lower than `pub`) and hidden items (attribute `doc(hidden)`). This matters now that Cargo is passing --document-private-items by default for bin crates. In bin crates that rely on macros, intentionally hidden implementation details of the macros can overwhelm the actual useful internal API that one would want to document.

This PR restores the strip-hidden pass when documenting private items, and introduces a separate unstable --document-hidden-items option to skip the strip-hidden pass. The two options are orthogonal to one another.

Fixes #67851. Closes #60884.
2020-01-09 00:29:13 +09:00
Yuki Okushi
429a7e7522
Rollup merge of #67849 - cjkenn:check-sorted-words, r=estebank
Add a check for swapped words when we can't find an identifier

Fixes #66968

Couple things here:
1. The matches take the precedence of case insensitive match, then levenshtein match, then swapped words match. Doing this allows us to not even check for swapped words unless the other checks return `None`.
2. I've assumed that the swapped words check is not held to the limits of the max levenshtein distance threshold (ie. we want to try and find a match even if the levenshtein distance is very high). This means that we cannot perform this check in the `fold` that occurs after the `filter_map` call, because the candidate will be filtered out. So, I've split this into two separate `fold` calls, and had to collect the original iterator into a vec so it can be copied (I don't think we want to change the function signature to take a vec or require the `Copy` trait). An alternative implemenation may be to remove the `filter_map`, `fold` over the entire iterator, and do a check against `max_dist` inside the relevant cases there.

r? @estebank
2020-01-09 00:29:12 +09:00
Mazdak Farrokhzad
2c3e5d3de0 - remove syntax::{span_warn!, span_err!, span_fatal!. struct_err!}
- remove syntax::{help!, span_help!, span_note!}
- remove unused syntax::{struct_span_fatal, struct_span_err_or_warn!, span_err_or_warn!}
- lintify check_for_bindings_named_same_as_variants + conflicting_repr_hints
- inline syntax::{struct_span_warn!, diagnostic_used!}
- stringify_error_code! -> error_code! & use it more.
- find_plugin_registrar: de-fatalize an error
- de-fatalize metadata errors
- move type_error_struct! to rustc_typeck
- struct_span_err! -> rustc_errors
2020-01-08 04:25:33 +01:00
Mazdak Farrokhzad
0a6cdc231e slice patterns: harden match-based borrowck tests 2020-01-08 00:42:53 +01:00
Adam Perry
3acd346594 Skip caller location test in wasm32. 2020-01-07 07:22:49 -08:00
Yuki Okushi
b065031096
Rollup merge of #67936 - euclio:assoc-type-bad-style, r=Centril
fire "non_camel_case_types" for associated types

Fixes #67920.
2020-01-07 13:46:13 +09:00
Yuki Okushi
c07204b1d1
Rollup merge of #67908 - ollie27:rustdoc_const_html_escape, r=GuillaumeGomez
rustdoc: HTML escape const values

r? @GuillaumeGomez
2020-01-07 13:46:07 +09:00
Yuki Okushi
9ef3b2ca2a
Rollup merge of #67898 - matthewjasper:newtype-index-hygiene, r=Centril
Improve hygiene of `newtype_index`

`newtype_index` no longer needs `rustc_index::vec::Idx` to be in scope.

r? @Centril
2020-01-07 13:46:05 +09:00
Yuki Okushi
6d9913d51b
Rollup merge of #67880 - lbonn:fix/multi-substs, r=petrochenkov
Handle multiple error fix suggestions carefuly

The existing code seems to assume that substitutions spans are disjoint,
which is not always the case.

In the example:

    pub trait AAAA {}
    pub trait B {}
    pub trait C {}
    pub type T<P: AAAA + B + C> = P;

, we get three substituions starting from ':' and ending respectively at
the end of each trait token.

With the former offset calculation, this would cause `underline_start` to
eventually become negative before being converted to `usize`...

The new version may report erroneous results for non perfectly overlapping
substitutions but I don't know if such examples exist. Alternatively, we
could detect these cases and trim out overlapping substitutions.

Fixes #67690
2020-01-07 13:46:04 +09:00
Yuki Okushi
74ca7c7dd3
Rollup merge of #67877 - dtolnay:const-_, r=nagisa
Omit underscore constants from rustdoc

Underscore constants from https://github.com/rust-lang/rfcs/pull/2526 / https://github.com/rust-lang/rust/issues/54912 do not correspond to a nameable item and so are never useful in documentation.
<br>

#### Before:

> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="https://user-images.githubusercontent.com/1940490/71771409-0427cc80-2eef-11ea-8b7d-d9c74a873e7e.png" width="60%">

#### After:

> Not that.
2020-01-07 13:46:02 +09:00
Yuki Okushi
3cce950743
Rollup merge of #67671 - estebank:type-impl-trait, r=davidtwco
Account for `type X = impl Trait;` in lifetime suggestion

Fix #67619.
2020-01-07 13:45:59 +09:00
Oliver Middleton
86b9d49cbe rustdoc: Remove more #[doc(cfg(..))] duplicates 2020-01-06 23:57:02 +00:00
Esteban Küber
2905f14b67 Account for type X = impl Trait; in lifetime suggestion 2020-01-06 13:36:06 -08:00
Matthew Jasper
9462c8babb Improve hygiene of newtype_index
Also add unit tests
2020-01-06 20:43:10 +00:00
Andy Russell
a7727c59ac
fire "non_camel_case_types" for associated types 2020-01-06 09:51:23 -05:00
bors
ebbb2bf37a Auto merge of #67886 - Centril:rustc_hir_canon_imports, r=nagisa
Nix `rustc_hir` reexports in rustc::hir

r? @Zoxc cc @Mark-Simulacrum
2020-01-06 12:55:40 +00:00
Dylan DPC
34716a31db
Rollup merge of #67915 - lzutao:Self, r=Centril
Use Self instead of $type

r? @Dylan-DPC
2020-01-06 12:00:23 +05:30
Dylan DPC
c79034ed47
Rollup merge of #67906 - varkor:silence-toogeneric, r=nagisa
Silence `TooGeneric` error

This error may be produced during intermediate failed attempts at evaluation of a generic const, which may nevertheless succeed later.

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

r? @eddyb
2020-01-06 12:00:20 +05:30
Dylan DPC
3692075049
Rollup merge of #67800 - Aaron1011:fix/mir-generic-instance, r=oli-obk
Fix ICE involving calling `Instance.ty` during const evaluation

Fixes #67639

`Instance.ty` assumes that we are in a fully monomorphic context (e.g.
codegen), and can therefore use an empty `ParamEnv` when performing
normalization. Howver, the MIR constant evaluator code ends up calling
`Instance.ty` as a result of us attemptign to 'speculatively'
const-evaluate generic functions during const propagation.

As a result,
we may end up with projections involving type parameters
(e.g. <T as MyTrait>::Bar>) in the type we are trying to normalize.
Normalization expects us to have proper predicates in the `ParamEnv` for
such projections, and will ICE if we don't.

This commit adds a new method `Instance.ty_env`, which takes a
`ParamEnv` for use during normalization. The MIR const-evaluator code is
changed to use this method, passing in the proper `ParamEnv` for the
context at hand.
2020-01-06 12:00:16 +05:30
Lzu Tao
c7dbf5ad54 Use Self instead of $type 2020-01-06 04:33:31 +00:00
bors
33640f0e03 Auto merge of #67563 - euclio:rustdoc-buffer-lexer, r=GuillaumeGomez
buffer lexer errors in rustdoc syntax checking

The code isn't ideal (I really would like to display the errors inline), but this at least gets us to where we were before #63017.
2020-01-06 00:09:14 +00:00
Oliver Middleton
e2305d0055 rustdoc: HTML escape const values 2020-01-05 23:19:42 +00:00
varkor
adb46fd0a4 Silence TooGeneric error
This error may be produced during intermediate failed attempts at evaluation of a generic const, which may nevertheless succeed later.
2020-01-05 23:00:47 +00:00
Aaron Hill
ee922d47f2
Fix ICE involving calling Instance.ty during const evaluation
Fixes #67639

`Instance.ty` assumes that we are in a fully monomorphic context (e.g.
codegen), and can therefore use an empty `ParamEnv` when performing
normalization. Howver, the MIR constant evaluator code ends up calling
`Instance.ty` as a result of us attemptign to 'speculatively'
const-evaluate generic functions during const propagation.

As a result,
we may end up with projections involving type parameters
(e.g. <T as MyTrait>::Bar>) in the type we are trying to normalize.
Normalization expects us to have proper predicates in the `ParamEnv` for
such projections, and will ICE if we don't.

This commit adds a new method `Instance.ty_env`, which takes a
`ParamEnv` for use during normalization. The MIR const-evaluator code is
changed to use this method, passing in the proper `ParamEnv` for the
context at hand.
2020-01-05 14:37:59 -05:00
Dylan DPC
10a12c539a
Rollup merge of #67881 - varkor:scattering-of-backticks, r=Centril
Add backticks to various diagnostics
2020-01-05 22:44:33 +05:30
Dylan DPC
3548d983d2
Rollup merge of #67818 - ollie27:rustdoc_playground_syntax_error, r=GuillaumeGomez
rustdoc: Avoid panic when parsing codeblocks for playground links

`make_test` is also called when parsing codeblocks for the playground links so it should handle unwinds from the parser internally.

Fixes #63016

r? @GuillaumeGomez
2020-01-05 22:44:29 +05:30
Laurent Bonnans
12545c75ff Handle multiple error fix suggestions carefuly
The existing code seems to assume that substitutions spans are disjoint,
which is not always the case.

In the example:

    pub trait AAAA {}
    pub trait B {}
    pub trait C {}
    pub type T<P: AAAA + B + C> = P;

, we get three substituions starting from ':' and ending respectively at
the end of each trait token.

With the former offset calculation, this would cause `underline_start` to
eventually become negative before being converted to `usize`...

The new version may report erroneous results for non perfectly overlapping
substitutions but I don't know if such examples exist. Alternatively, we
could detect these cases and trim out overlapping substitutions.
2020-01-05 12:51:57 +01:00
Mazdak Farrokhzad
01563682c6 fix ui-fulldeps fallout 2020-01-05 12:49:22 +01:00
Adam Perry
b97ee0f07a
Fix typo
Co-Authored-By: lzutao <taolzu@gmail.com>
2020-01-04 22:54:09 -08:00
Adam Perry
7a6af7eb0e Result's panics have #[track_caller]. 2020-01-04 19:52:37 -08:00
Adam Perry
2e9d573d3f Option's panics are all #[track_caller].
Also includes a simple test with a custom panic hook to ensure we don't regress.
2020-01-04 19:52:37 -08:00
Andy Russell
1ad928ee52
buffer lexer errors in rustdoc syntax checking 2020-01-04 19:20:35 -05:00
varkor
0c2cf07d6e Add backticks to various diagnostics 2020-01-05 00:17:46 +00:00
David Tolnay
097126e284
Omit underscore constants from rustdoc 2020-01-04 12:35:23 -08:00
David Tolnay
90adafbc9e
Distinguish between private items and hidden items in rustdoc
I believe rustdoc should not be conflating private items (visibility
lower than `pub`) and hidden items (attribute `doc(hidden)`). This
matters now that Cargo is passing --document-private-items by default
for bin crates. In bin crates that rely on macros, intentionally hidden
implementation details of the macros can overwhelm the actual useful
internal API that one would want to document.

This PR restores the strip-hidden pass when documenting private items,
and introduces a separate unstable --document-hidden-items option to
skip the strip-hidden pass. The two options are orthogonal to one
another.
2020-01-04 11:28:53 -08:00
cjkenn
e01e8b9256 add ui test 2020-01-04 10:58:04 -08:00
Oliver Middleton
efb876f557 rustdoc: Avoid panic when parsing codeblocks for playground links
`make_test` is also called when parsing codeblocks for the playground links so it should handle unwinds from the parser internally.
2020-01-04 18:42:06 +00:00