Commit Graph

108 Commits

Author SHA1 Message Date
Vadim Petrochenkov
4d2d0bad4e Remove compile-fail test suite 2020-12-29 23:39:56 +03:00
Camelid
810324d1f3 Rename optin_builtin_traits to auto_traits
They were originally called "opt-in, built-in traits" (OIBITs), but
people realized that the name was too confusing and a mouthful, and so
they were renamed to just "auto traits". The feature flag's name wasn't
updated, though, so that's what this PR does.

There are some other spots in the compiler that still refer to OIBITs,
but I don't think changing those now is worth it since they are internal
and not particularly relevant to this PR.

Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.
2020-11-23 14:14:06 -08:00
Bastian Kauschke
69b43c209c improve error message for const ty param mismatch 2020-11-16 16:07:59 +01:00
Tim Diekmann
06e4497a04 Merge remote-tracking branch 'upstream/master' into box-alloc 2020-10-25 16:32:28 +01:00
Vadim Petrochenkov
cee5521a03 Calculate visibilities once in resolve
Then use them through a query based on resolver outputs
2020-10-19 11:57:50 +03:00
Tim Diekmann
f288cd2e17 Support custom allocators in Box
Remove `Box::leak_with_alloc`


Add leak-test for box with allocator


Rename `AllocErr` to `AllocError` in leak-test


Add `Box::alloc` and adjust examples to use the new API
2020-10-07 03:07:02 +02:00
Matthew Jasper
022c148fcd Fix tests from rebase 2020-10-06 11:19:33 +01:00
Matthew Jasper
f958e6c246 Separate bounds and predicates for associated/opaque types 2020-10-06 11:19:29 +01:00
aticu
1c1bb1309f Improve E0118 description 2020-09-11 19:48:43 +02:00
Dan Aloni
07e7823c01 pretty: trim paths of unique symbols
If a symbol name can only be imported from one place for a type, and
as long as it was not glob-imported anywhere in the current crate, we
can trim its printed path and print only the name.

This has wide implications on error messages with types, for example,
shortening `std::vec::Vec` to just `Vec`, as long as there is no other
`Vec` importable anywhere.

This adds a new '-Z trim-diagnostic-paths=false' option to control this
feature.

On the good path, with no diagnosis printed, we should try to avoid
issuing this query, so we need to prevent trimmed_def_paths query on
several cases.

This change also relies on a previous commit that differentiates
between `Debug` and `Display` on various rustc types, where the latter
is trimmed and presented to the user and the former is not.
2020-09-02 22:26:37 +03:00
Aaron Hill
e3cd43eb00
Use smaller def span for functions
Currently, the def span of a funtion encompasses the entire function
signature and body. However, this is usually unnecessarily verbose - when we are
pointing at an entire function in a diagnostic, we almost always want to
point at the signature. The actual contents of the body tends to be
irrelevant to the diagnostic we are emitting, and just takes up
additional screen space.

This commit changes the `def_span` of all function items (freestanding
functions, `impl`-block methods, and `trait`-block methods) to be the
span of the signature. For example, the function

```rust
pub fn foo<T>(val: T) -> T { val }
```

now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T`
(everything before the opening curly brace).

Trait methods without a body have a `def_span` which includes the
trailing semicolon. For example:

```rust
trait Foo {
    fn bar();
}```

the function definition `Foo::bar` has a `def_span` of `fn bar();`

This makes our diagnostic output much shorter, and emphasizes
information that is relevant to whatever diagnostic we are reporting.

We continue to use the full span (including the body) in a few of
places:

* MIR building uses the full span when building source scopes.
* 'Outlives suggestions' use the full span to sort the diagnostics being
  emitted.
* The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]`
attribute points the entire scope body.
* The 'unconditional recursion' lint uses the full span to show
  additional context for the recursive call.

All of these cases work only with local items, so we don't need to
add anything extra to crate metadata.
2020-08-22 18:41:49 -04:00
Esteban Küber
089810a1cb Do not suggest similarly named enclosing item 2020-08-10 12:04:10 -07:00
Aaron Hill
48bc398207
Handle fieldless tuple structs in diagnostic code
Fixes #75062
2020-08-05 07:59:26 -04:00
Dan Aloni
fea5ab12c2 Prefer accessible paths in 'use' suggestions
This fixes an issue with the following sample:

    mod foo {
	mod inaccessible {
	    pub struct X;
	}
	pub mod avail {
	    pub struct X;
	}
    }

    fn main() { X; }

Instead of suggesting both `use crate::foo::inaccessible::X;` and `use
crate::foo::avail::X;`, it should only suggest the latter.

It is done by trimming the list of suggestions from inaccessible paths
if accessible paths are present.

Visibility is checked with `is_accessible_from` now instead of being
hard-coded.

-

Some tests fixes are trivial, and others require a bit more explaining,
here are my comments:

src/test/ui/issues/issue-35675.stderr: Only needs to make the enum
public to have the suggestion make sense.

src/test/ui/issues/issue-42944.stderr: Importing the tuple struct won't
help because its constructor is not visible, so the attempted
constructor does not work. In that case, it's better not to suggest it.
The case where the constructor is public is covered in `issue-26545.rs`.
2020-06-21 18:49:39 +03:00
Matthew Jasper
4e49e67c44 Stop special casing top level TAIT 2020-06-11 16:24:01 +01:00
Andy Russell
9f88d75710
reword "possible candidate" import suggestion 2020-05-07 00:33:25 -04:00
RoccoDev
b85c64c3ea
rustc: Add a warning count upon completion 2020-04-11 16:15:24 +02:00
Esteban Küber
a3e54b59f9 Do not suggest adding type param when use is already suggested
Fix #70365, cc #70572.
2020-04-07 18:07:26 -07:00
Dylan DPC
7041efcfc3
Rollup merge of #70344 - Centril:hir-pretty, r=eddyb
Decouple `rustc_hir::print` into `rustc_hir_pretty`

High level summary:
- The HIR pretty printer, `rustc_hir::print` is moved into a new crate `rustc_hir_pretty`.
- `rustc_ast_pretty` and `rustc_errors` are dropped as `rustc_hir` dependencies.
- The dependence on HIR pretty is generally reduced, leaving `rustc_save_analysis`, `rustdoc`, `rustc_metadata`, and `rustc_driver` as the remaining clients.

The main goal here is to reduce `rustc_hir`'s dependencies and its size such that it can start and finish earlier, thereby working towards https://github.com/rust-lang/rust/issues/65031.

r? @Zoxc
2020-03-27 01:23:53 +01:00
Niko Matsakis
0d0702623f wip pacify the merciless ui tests 2020-03-26 07:41:26 -04:00
Niko Matsakis
fda3378e3f introduce negative_impls feature gate and document
They used to be covered by `optin_builtin_traits` but negative impls
are now applicable to all traits, not just auto traits.

This also adds docs in the unstable book for the current state of auto traits.
2020-03-26 06:52:55 -04:00
Mazdak Farrokhzad
92885e3a5b rustc_typeck: remove rustc_hir_pretty usage 2020-03-24 08:38:32 +01:00
Mazdak Farrokhzad
ee9094869c
Rollup merge of #69740 - mark-i-m:describe-it-3, r=eddyb
Replace some desc logic in librustc_lint with article_and_desc

r? @eddyb @Centril @matthewjasper

Followup to https://github.com/rust-lang/rust/pull/69674

Blocked on #69498
2020-03-24 00:49:37 +01:00
Mazdak Farrokhzad
906b399583
Rollup merge of #69942 - estebank:sized-verbose-sugg, r=matthewjasper
Increase verbosity when suggesting subtle code changes

Do not suggest changes that are actually quite small inline, to minimize the likelihood of confusion.

Fix #69243.
2020-03-23 10:29:09 +01:00
Esteban Küber
9175940c92 Use more targetted span for error label 2020-03-22 16:09:42 -07:00
Esteban Küber
854b78fe22 Normalize wording of privacy access labels 2020-03-22 15:36:54 -07:00
Esteban Küber
94bbd46682 Add span label to primary error span 2020-03-22 11:18:06 -07:00
mark
1661a0a99b convert a couple more errors 2020-03-21 19:47:23 -05:00
LeSeulArtichaut
cb7a2c16aa Bless tests 2020-03-21 15:03:58 +01:00
Mazdak Farrokhzad
b691145bd4
Rollup merge of #69811 - petrochenkov:privdiag2, r=estebank
resolve: Print import chains on privacy errors

A part of https://github.com/rust-lang/rust/pull/67951 that doesn't require hacks.
r? @estebank
2020-03-17 03:05:10 +01:00
Mark Mansi
b6518f0f66 update tests 2020-03-12 15:47:36 -05:00
Vadim Petrochenkov
580c6a29d4 resolve: Print import chains on privacy errors 2020-03-11 21:17:32 +03:00
Jonas Schievink
a323ff2c86 Implement RFC 2532 – Associated Type Defaults 2020-02-21 19:41:21 +01:00
Mazdak Farrokhzad
75afd0b0cf use dyn Trait more in tests 2020-02-10 17:42:09 +01:00
Eduard-Mihai Burtescu
4c7eb59e81 rustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros. 2020-02-06 21:46:38 +02:00
Eduard-Mihai Burtescu
f6fc80206e rustc: rename -Zexternal-macro-backtrace to -Zmacro-backtrace. 2020-02-06 21:32:07 +02:00
bors
5371ddf8c6 Auto merge of #68080 - varkor:declared-here, r=petrochenkov
Address inconsistency in using "is" with "declared here"

"is" was generally used for NLL diagnostics, but not other diagnostics. Using "is" makes the diagnostics sound more natural and readable, so it seems sensible to commit to them throughout.

r? @Centril
2020-01-31 15:13:51 +00:00
Esteban Küber
697fdc568e Suggest defining type parameter when appropriate
```
error[E0412]: cannot find type `T` in this scope
 --> file.rs:3:12
  |
3 | impl Trait<T> for Struct {}
  |     -      ^ not found in this scope
  |     |
  |     help: you might be missing a type parameter: `<T>`
```

Fix #64298.
2020-01-26 10:57:18 -08:00
varkor
24a2929ed1 Normalise notes with the/is 2020-01-24 16:24:50 +00:00
Vadim Petrochenkov
c84efe9b6c resolve: Say "import" when reporting private imports 2020-01-16 21:59:11 +03:00
Vadim Petrochenkov
28c3f6eb40 resolve: Point at the private item definitions in privacy errors 2020-01-16 21:59:11 +03:00
Vadim Petrochenkov
642669c74d Update tests 2020-01-09 21:23:12 +03:00
Eric Huss
60d4e20ff0 compiletest: add aux-crate directive 2019-12-09 08:08:27 -08:00
Gabriel Smith
0207a15fa1 test: Update tests with fallout of changes
The error messages of the two tests effected degraded in quality. The
errors no longer suggest types in other modules as they now assume that
the arguments are const args, not type args.
2019-11-18 17:23:22 -05:00
Mazdak Farrokhzad
7ab50e4006
Rollup merge of #65785 - Centril:compat-to-error-2, r=oli-obk
Transition future compat lints to {ERROR, DENY} - Take 2

Follow up to https://github.com/rust-lang/rust/pull/63247 implementing https://github.com/rust-lang/rust/pull/63247#issuecomment-536295992.

- `legacy_ctor_visibility` (ERROR) -- closes #39207
- `legacy_directory_ownership` (ERROR) -- closes #37872
- `safe_extern_static` (ERROR) -- closes #36247
- `parenthesized_params_in_types_and_modules` (ERROR) -- closes #42238
- `duplicate_macro_exports` (ERROR)
- `nested_impl_trait` (ERROR) -- closes #59014
- `ill_formed_attribute_input` (DENY) -- transitions #57571
- `patterns_in_fns_without_body` (DENY) -- transitions #35203

r? @varkor
cc @petrochenkov
2019-11-08 16:50:33 +01:00
Mazdak Farrokhzad
c0056c04f6 legacy_ctor_visibility -> error 2019-11-06 11:08:23 +01:00
Tomasz Miąsko
f736de5dbc Apply review suggestions 2019-11-06 00:00:00 +00:00
Tomasz Miąsko
045fdd9fa9 Use build-pass in ui tests where appropriate 2019-11-04 16:03:46 +01:00
Tyler Mandry
b7416348c8
Rollup merge of #65914 - estebank:type-alias-bounds-sugg, r=davidtwco
Use structured suggestion for unnecessary bounds in type aliases
2019-11-01 11:20:15 -07:00
Guillaume Gomez
9869e5b969 Change E0741 into E0742 2019-10-29 13:59:40 +01:00