Commit Graph

206 Commits

Author SHA1 Message Date
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
bors
14b96659e4 Auto merge of #57088 - euclio:non-camel-case-early-lint, r=estebank
make non_camel_case_types an early lint

This allows us to catch these kinds of style violations much earlier, as evidenced by the large number of tests that had to be updated for this change.
2018-12-25 16:12:24 +00:00
Andy Russell
6474de904c
make non_camel_case_types an early lint 2018-12-24 12:58:52 -05:00
Mazdak Farrokhzad
0c1ba07a77
Rollup merge of #57020 - estebank:return-span, r=zackmdavis
Point to cause of `fn` expected return type

Fix #48136.
2018-12-23 23:09:09 +01:00
Esteban Küber
59f643fc5f Point to return span when writing return; on non-() fn 2018-12-20 14:00:30 -08:00
bors
96d1334e56 Auto merge of #56572 - kevgrasso:let_self_err_dev, r=estebank
Contexually dependent error message for E0424 when value is assigned to "self"

This is an improvement for pull request #54495 referencing issue #54369. If the "self" keyword is assigned a value as though it were a valid identifier, it will now report:
```
let self = "self";
    ^^^^ `self` value is a keyword and may not be bound to variables or shadowed
```
instead of
```
let self = "self";
    ^^^^ `self` value is a keyword only available in methods with `self` parameter
```
If anyone has a better idea for what the error should be I'd be happy to modify it appropriately.
2018-12-14 20:36:12 +00:00
Kevyn Grasso
9de6beeae2 debug logging, added conditional error message, tests updated 2018-12-13 20:16:03 -05:00
Alex Crichton
4c21a3bc2a std: Depend directly on crates.io crates
Ever since we added a Cargo-based build system for the compiler the
standard library has always been a little special, it's never been able
to depend on crates.io crates for runtime dependencies. This has been a
result of various limitations, namely that Cargo doesn't understand that
crates from crates.io depend on libcore, so Cargo tries to build crates
before libcore is finished.

I had an idea this afternoon, however, which lifts the strategy
from #52919 to directly depend on crates.io crates from the standard
library. After all is said and done this removes a whopping three
submodules that we need to manage!

The basic idea here is that for any crate `std` depends on it adds an
*optional* dependency on an empty crate on crates.io, in this case named
`rustc-std-workspace-core`. This crate is overridden via `[patch]` in
this repository to point to a local crate we write, and *that* has a
`path` dependency on libcore.

Note that all `no_std` crates also depend on `compiler_builtins`, but if
we're not using submodules we can publish `compiler_builtins` to
crates.io and all crates can depend on it anyway! The basic strategy
then looks like:

* The standard library (or some transitive dep) decides to depend on a
  crate `foo`.
* The standard library adds

  ```toml
  [dependencies]
  foo = { version = "0.1", features = ['rustc-dep-of-std'] }
  ```
* The crate `foo` has an optional dependency on `rustc-std-workspace-core`
* The crate `foo` has an optional dependency on `compiler_builtins`
* The crate `foo` has a feature `rustc-dep-of-std` which activates these
  crates and any other necessary infrastructure in the crate.

A sample commit for `dlmalloc` [turns out to be quite simple][commit].
After that all `no_std` crates should largely build "as is" and still be
publishable on crates.io! Notably they should be able to continue to use
stable Rust if necessary, since the `rename-dependency` feature of Cargo
is soon stabilizing.

As a proof of concept, this commit removes the `dlmalloc`,
`libcompiler_builtins`, and `libc` submodules from this repository. Long
thorns in our side these are now gone for good and we can directly
depend on crates.io! It's hoped that in the long term we can bring in
other crates as necessary, but for now this is largely intended to
simply make it easier to manage these crates and remove submodules.

This should be a transparent non-breaking change for all users, but one
possible stickler is that this almost for sure breaks out-of-tree
`std`-building tools like `xargo` and `cargo-xbuild`. I think it should
be relatively easy to get them working, however, as all that's needed is
an entry in the `[patch]` section used to build the standard library.
Hopefully we can work with these tools to solve this problem!

[commit]: 28ee12db81
2018-12-11 21:08:22 -08:00
Guillaume Gomez
05cea31c8d fix span for invalid number of parameters in trait method 2018-12-08 20:04:14 +01:00
Oliver Scherer
61efc3b71b Update tests 2018-12-04 10:06:05 +01:00
Alexander Regueiro
d609fdf775 Updated ui tests. 2018-11-30 22:12:39 +00:00
Guillaume Gomez
aebf07e3eb
Rollup merge of #56114 - varkor:nonexhaustive-backticks, r=nikomatsakis
Enclose type in backticks for "non-exhaustive patterns" error

This makes the error style consistent with the convention in error messages.
2018-11-29 13:10:33 +01:00
bors
b51632e3f0 Auto merge of #56070 - oli-obk:const_let, r=eddyb
Allow assignments in const contexts

fixes https://github.com/rust-lang/rust/issues/54098
fixes https://github.com/rust-lang/rust/issues/51251
fixes https://github.com/rust-lang/rust/issues/52613
2018-11-26 08:17:36 +00:00
Esteban Küber
a5d35631fe Reword and fix test 2018-11-22 14:14:27 -08:00
Esteban Küber
48fa974211 Suggest correct syntax when writing type arg instead of assoc type
When confusing an associated type with a type argument, suggest the
appropriate syntax.

Given `Iterator<isize>`, suggest `Iterator<Item = isize>`.
2018-11-22 14:14:27 -08:00
Esteban Küber
b6f4b29c6d Point at the associated type's def span 2018-11-22 14:14:27 -08:00
Esteban Küber
286f7ae1dd Join multiple E0191 errors in the same location under a single diagnostic 2018-11-22 14:14:27 -08:00
Esteban Küber
abdcb868ff Point at every unexpected lifetime and type argument in E0107 2018-11-22 14:14:27 -08:00
varkor
f039872766 Enclose type in backticks for "reached the recursion limit while auto-dereferencing" error 2018-11-21 16:06:24 +00:00
varkor
b99f9f775c Enclose type in backticks for "non-exhaustive patterns" error
This makes the error style consistent with the convention in error messages.
2018-11-20 21:48:13 +00:00
Oliver Scherer
7d5b5ff24d Update nll stderr files 2018-11-19 19:03:03 +01:00
Oliver Scherer
59eff14120 Also catch static mutation at evaluation time 2018-11-19 16:46:03 +01:00
bors
9e8a982a23 Auto merge of #56051 - pietroalbini:rollup, r=pietroalbini
Rollup of 25 pull requests

Successful merges:

 - #55562 (Add powerpc- and powerpc64-unknown-linux-musl targets)
 - #55564 (test/linkage-visibility: Ignore on musl targets)
 - #55827 (A few tweaks to iterations/collecting)
 - #55834 (Forward the ABI of the non-zero sized fields of an union if they have the same ABI)
 - #55857 (remove unused dependency)
 - #55862 (in which the E0618 "expected function" diagnostic gets a makeover)
 - #55867 (do not panic just because cargo failed)
 - #55894 (miri enum discriminant handling: Fix treatment of pointers, better error when it is undef)
 - #55916 (Make miri value visitor useful for mutation)
 - #55919 (core/tests/num: Simplify `test_int_from_str_overflow()` test code)
 - #55923 (reword #[test] attribute error on fn items)
 - #55949 (ty: return impl Iterator from Predicate::walk_tys)
 - #55952 (Update to Clang 7 on CI.)
 - #55953 (#53488 Refactoring UpvarId)
 - #55962 (rustdoc: properly calculate spans for intra-doc link resolution errors)
 - #55963 (Stress test for MPSC)
 - #55968 (Clean up some non-mod-rs stuff.)
 - #55970 (Miri backtrace improvements)
 - #56007 (CTFE: dynamically make sure we do not call non-const-fn)
 - #56011 (Replace data.clone() by Arc::clone(&data) in mutex doc.)
 - #56012 (avoid shared ref in UnsafeCell::get)
 - #56016 (Add VecDeque::resize_with)
 - #56027 (docs: Add missing backtick in object_safety.rs docs)
 - #56043 (remove "approx env bounds" if we already know from trait)
 - #56059 (Increase `Duration` approximate equal threshold to 1us)
2018-11-19 14:07:45 +00:00
Pietro Albini
9577734ff3
Rollup merge of #55862 - zackmdavis:but_will_they_come_when_you_call_them, r=estebank
in which the E0618 "expected function" diagnostic gets a makeover

A woman of wisdom once told me, "Better late than never." (Can't reopen the previously-closed pull request from six months ago [due to GitHub limitations](https://github.com/rust-lang/rust/pull/51098#issuecomment-437647157).)

Now the main span focuses on the erroneous not-a-function callee, while showing the entire call expression is relegated to a secondary span. In the case where the erroneous callee is itself a call, we
point out the definition, and, if the call expression spans multiple lines, tentatively suggest a semicolon (because we suspect that the "outer" call is actually supposed to be a tuple).

![not_a_fn_1](https://user-images.githubusercontent.com/1076988/48309935-96755000-e538-11e8-9390-02a048abb0c2.png)

![not_a_fn_2](https://user-images.githubusercontent.com/1076988/48309936-98d7aa00-e538-11e8-8b9b-257bc77d6261.png)

The new `bug!` assertion is, in fact, safe (`confirm_builtin_call` is only called by `check_call`, which is only called with a first arg of kind `ExprKind::Call` in `check_expr_kind`).

Resolves #51055.

r? @estebank
2018-11-18 23:24:37 +01:00
Vadim Petrochenkov
4fc3c13e32 resolve: Avoid sentence breaks in diagnostics 2018-11-18 13:58:36 +03:00
Vadim Petrochenkov
cfd762954b resolve: Tweak some articles in ambiguity diagnostics 2018-11-18 13:57:03 +03:00
Vadim Petrochenkov
f0ea1c6f1e resolve: Improve diagnostics for resolution ambiguities 2018-11-18 13:51:40 +03:00
Zack M. Davis
f3e9b1a703 in which the E0618 "expected function" diagnostic gets a makeover
Now the main span focuses on the erroneous not-a-function callee,
while showing the entire call expression is relegated to a secondary
span. In the case where the erroneous callee is itself a call, we
point out the definition, and, if the call expression spans multiple
lines, tentatively suggest a semicolon (because we suspect that the
"outer" call is actually supposed to be a tuple).

The new `bug!` assertion is, in fact, safe (`confirm_builtin_call` is
only called by `check_call`, which is only called with a first arg of
kind `ExprKind::Call` in `check_expr_kind`).

Resolves #51055.
2018-11-10 22:12:33 -08:00
Alexander Regueiro
7d9ee0314a Only do check for trait objects, not trait or trait alias definitions. 2018-11-07 21:57:45 +00:00
Alexander Regueiro
6d3ee4170d Added error for duplicate bindings of associated type. 2018-11-07 21:57:45 +00:00
Alexander Regueiro
0e89f570d2 Added tests. 2018-11-07 21:57:40 +00:00
varkor
8277ba2d30 Make "all possible cases" help message uniform with existing help messages
Specifically no capitalisation or trailing full stops.
2018-11-03 23:53:10 +00:00
Michael Hewson
b5b25f8196 Put backticks around field names, types and paths in error messages
Added to `DispatchFromDyn` and `CoerceUnsized` error messages
2018-11-01 18:16:59 -04:00
Matthew Jasper
42a541e0f1 Don't emit cannot move errors twice in migrate mode 2018-10-29 20:22:01 +00:00
Vadim Petrochenkov
acdbd0643c resolve: More precise spans for privacy errors 2018-10-28 02:56:12 +03:00
bors
fa45602b71 Auto merge of #54929 - csmoe:cfg_lint, r=petrochenkov
Suggest to remove prefix `b` in cfg attribute lint string

Closes #54926
r? @estebank
2018-10-26 21:46:13 +00:00
Oliver Schneider
7fdf06cdde Report const eval error inside the query 2018-10-25 16:46:19 +02:00
bors
7cfe5de214 Auto merge of #55113 - mockersf:master, r=estebank
#45829 when a renamed import conflict with a previous import

Fix the suggestion when a renamed import conflict.

It check if the snipped contains `" as "`, and if so uses everything before for the suggestion.
2018-10-23 08:17:18 +00:00
csmoe
a76690f6a4 optimize unsupported literal diag message 2018-10-22 20:28:37 +08:00
csmoe
fb7c76bad5 update meta item checking test 2018-10-20 11:11:31 +08:00
bors
42dde960f9 Auto merge of #55162 - nikomatsakis:issue-54902-underscore-bound, r=tmandry
handle underscore bounds in unexpected places

Per the discussion on #54902, I made it a hard error to use lifetime bounds in various places where they used to be permitted:

- `where Foo: Bar<'_>` for example

I also moved error reporting to HIR lowering and added `Error` variants to let us suppress downstream errors that result.

I (imo) improved the error message wording to be clearer, as well.

In the process, I fixed the ICE in #52098.

Fixes #54902
Fixes #52098
2018-10-19 22:54:14 +00:00
bors
45088b11f5 Auto merge of #54979 - estebank:path-unsized, r=nikomatsakis
Custom E0277 diagnostic for `Path`

r? @nikomatsakis we have a way to target `Path` exclusively, we need to identify the correct text to show to consider #23286 fixed.
2018-10-18 21:42:21 +00:00
Niko Matsakis
1f4d100472 move E0637 to lowering and improve output, add more tests 2018-10-17 17:15:24 -04:00
François Mockers
2ba567fc27 fix other tests failing due to change in case or new suggestion for extern crate 2018-10-17 01:21:40 +02:00
David Wood
539404b77d
Update output for borrowck=migrate compare mode.
This commit updates the test output for the updated NLL compare mode
that uses `-Z borrowck=migrate` rather than `-Z borrowck=mir`. The
previous commit changes `compiletest` and this commit only updates
`.nll.stderr` files.
2018-10-17 00:57:32 +02:00
bors
24faa97589 Auto merge of #54997 - davidtwco:issue-54896, r=nagisa
The #[panic_handler] attribute can be applied to non-functions

Fixes #54896.

This commit extends the existing lang items functionality to assert
that the `#[lang_item]` attribute is only found on the appropriate item
for any given lang item. That is, language items representing traits
must only ever have their corresponding attribute placed on a trait, for
example.

r? @nagisa
2018-10-13 11:52:49 +00:00
Zack M. Davis
a5de379b55 structured suggestion for E0223 ambiguous associated type
It looks like we tend to use angle-brackets around the placeholder in
the few other places we use `Applicability::HasPlaceholders`, but that
would be confusing here, so ...
2018-10-11 21:10:35 -07:00
David Wood
2ecce7ccc5
Extend lang items to assert correct target.
This commit extends the existing lang items functionality to assert
that the `#[lang_item]` attribute is only found on the appropriate item
for any given lang item. That is, language items representing traits
must only ever have their corresponding attribute placed on a trait, for
example.
2018-10-11 19:36:51 +02:00
Esteban Küber
ed10a3faae Custom E0277 diagnostic for Path 2018-10-10 17:30:10 -07:00
Felix S. Klock II
37f1003121 Updates to .stderr output in ui tests from earlier changes. 2018-10-05 12:04:53 +02:00