Commit Graph

210 Commits

Author SHA1 Message Date
Mohit Agarwal
11e9b8de7d Update E0445 and E0454 to new error format
Fixes #35922.
Fixes #35930.
Part of #35233.

r? @GuillaumeGomez
2016-08-24 17:43:51 +05:30
bors
e25542cb02 Auto merge of #35162 - canndrew:bang_type_coerced, r=nikomatsakis
Implement the `!` type

This implements the never type (`!`) and hides it behind the feature gate `#[feature(never_type)]`. With the feature gate off, things should build as normal (although some error messages may be different). With the gate on, `!` is usable as a type and diverging type variables (ie. types that are unconstrained by anything in the code) will default to `!` instead of `()`.
2016-08-16 00:12:12 -07:00
Andrew Cann
ed02344fbc Remove obsolete divergence related stuff
Replace FnOutput with Ty
Replace FnConverging(ty) with ty
Purge FnDiverging, FunctionRetTy::NoReturn and FunctionRetTy::None
2016-08-13 21:37:09 +08:00
Vadim Petrochenkov
737961b6c6 Make private_in_public compatibility lint deny-by-default 2016-08-11 23:19:04 +03:00
petrochenkov
d43b9cb487 privacy: Move private-in-public diagnostics for type aliases to the public interface location 2016-08-11 00:32:07 +03:00
Vadim Petrochenkov
b7db9e88bf privacy: Substitute type aliases in private-in-public checker 2016-08-11 00:32:07 +03:00
Michael Woerister
415fde498a intravisit: Fold functionality of IdVisitor into the regular Visitor. 2016-07-29 04:55:31 -04:00
Vadim Petrochenkov
ba419a78f3 Cleanup of some pattern related code 2016-07-08 12:36:45 +03:00
Jeffrey Seyfried
542ba8c5f7 Fix Cargo.tomls 2016-06-27 18:30:46 +00:00
Jonathan Turner
6ae3502134 Move errors from libsyntax to its own crate 2016-06-23 08:07:35 -04:00
bors
4ba60aba38 Auto merge of #34186 - GuillaumeGomez:err-code-check, r=alexcrichton
Implementation of #34168

r? @brson

cc @alexcrichton
cc @steveklabnik
cc @jonathandturner

I only updated `librustc_privacy/diagnostics.rs`, and I already found a case where the code doesn't throw the expected error code (E0448).

Fixes #34168.
2016-06-20 15:54:17 -07:00
Guillaume Gomez
ddfaf10f6b Add error code flag 2016-06-20 19:38:26 +02:00
Vadim Petrochenkov
ee4e55398b Introduce TyCtxt::expect_def/expect_resolution helpers and use them where possible 2016-06-10 01:03:54 +03:00
bors
c2cab1fd58 Auto merge of #33794 - petrochenkov:sanity, r=nrc
Add AST validation pass and move some checks to it

The purpose of this pass is to catch constructions that fit into AST data structures, but not permitted by the language. As an example, `impl`s don't have visibilities, but for convenience and uniformity with other items they are represented with a structure `Item` which has `Visibility` field.

This pass is intended to run after expansion of macros and syntax extensions (and before lowering to HIR), so it can catch erroneous constructions that were generated by them. This pass allows to remove ad hoc semantic checks from the parser, which can be overruled by syntax extensions and occasionally macros.

The checks can be put here if they are simple, local, don't require results of any complex analysis like name resolution or type checking and maybe don't logically fall into other passes. I expect most of errors generated by this pass to be non-fatal and allowing the compilation to proceed.

I intend to move some more checks to this pass later and maybe extend it with new checks, like, for example, identifier validity. Given that syntax extensions are going to be stabilized in the measurable future, it's important that they would not be able to subvert usual language rules.

In this patch I've added two new checks - a check for labels named `'static` and a check for lifetimes and labels named `'_`. The first one gives a hard error, the second one - a future compatibility warning.
Fixes https://github.com/rust-lang/rust/issues/33059 ([breaking-change])
cc https://github.com/rust-lang/rfcs/pull/1177

r? @nrc
2016-06-01 06:21:53 -07:00
Manish Goregaokar
10e1e6a7a2 Rollup merge of #33793 - GuillaumeGomez:compile_fail, r=GuillaumeGomez
Fix compile_fail tag

Fixes #33780

r? @steveklabnik
2016-05-30 15:18:59 +05:30
Vadim Petrochenkov
c02c6e88e6 Move some other checks to AST sanity pass 2016-05-28 20:27:57 +03:00
Guillaume Gomez
abe9961283 * Fix compile_fail tag (in some cases, it compiled whereas it wasn't expected to and was still considered 'ok')
* Fix error explanations tests/tags
2016-05-27 00:39:57 +02:00
Vadim Petrochenkov
35ef09c38b Replace pat_adjust_pos with an iterator adapter 2016-05-26 11:11:58 +03:00
Vadim Petrochenkov
d69aeaf662 Implement .. in tuple (struct) patterns 2016-05-26 11:11:58 +03:00
Vadim Petrochenkov
766f9b5a2f Remove ExplicitSelf from HIR 2016-05-14 13:26:40 +03:00
Eduard Burtescu
76affa5d6f rustc: Split 'tcx into 'gcx and 'tcx for InferCtxt and its users. 2016-05-11 04:14:58 +03:00
Eduard Burtescu
513d392f7e rustc: Replace &'a TyCtxt<'tcx> with a TyCtxt<'a, 'tcx> wrapper. 2016-05-11 04:14:58 +03:00
Seo Sanghyeon
7ad1900e1c Remove unused trait imports flagged by lint 2016-05-03 18:48:34 +09:00
Jeffrey Seyfried
daec3fe4e6 Always report PRIVATE_IN_PUBLIC violations as hard errors when
the feature `pub_restricted` is enabled.
2016-04-16 21:27:20 +00:00
Jeffrey Seyfried
35204025be Improve PrivateItemsInPublicInterfacesVisitor 2016-04-07 04:33:14 +00:00
Jeffrey Seyfried
0d34c5dd8a Use the node id from the Restricted variant when checking accessibility
in `typeck` and in `privacy::PrivacyVisitor`.
2016-04-07 04:33:06 +00:00
Jeffrey Seyfried
bb66d91c98 Make hir::Visibility non-copyable and add ty::Visibility 2016-04-07 04:31:45 +00:00
Eduard Burtescu
ffca6c3e15 rustc: move middle::{def,def_id,pat_util} to hir. 2016-04-06 09:14:21 +03:00
Eduard Burtescu
8b0937293b rustc: move rustc_front to rustc::hir. 2016-04-06 09:01:55 +03:00
Benjamin Herr
487219ccb1 librustc_privacy: use bug!(), span_bug!() 2016-03-31 22:06:52 +02:00
Vadim Petrochenkov
38bef43652 privacy: Cleanup check_field 2016-03-30 21:26:35 +00:00
Jeffrey Seyfried
48b048deb7 Clean up the privacy visitor 2016-03-30 21:26:35 +00:00
Eduard Burtescu
5efdde0de1 rustc: move cfg, infer, traits and ty from middle to top-level. 2016-03-27 01:05:54 +02:00
bors
bcda58f491 Auto merge of #31710 - eddyb:reify, r=nikomatsakis
Distinguish fn item types to allow reification from nothing to fn pointers.

The first commit is a rebase of #26284, except for files that have moved since.

This is a [breaking-change], due to:
* each FFI function has a distinct type, like all other functions currently do
* all generic parameters on functions are recorded in their item types, e.g.:
`size_of::<u8>` & `size_of::<i8>`'s types differ despite their identical signature.
* function items are zero-sized, which will stop transmutes from working on them

The first two cases are handled in most cases with the new coerce-unify logic,
which will combine incompatible function item types into function pointers,
at the outer-most level of if-else chains, match arms and array literals.

The last case is specially handled during type-checking such that transmutes
from a function item type to a pointer or integer type will continue to work for
another release cycle, but are being linted against. To get rid of warnings and
ensure your code will continue to compile, cast to a pointer before transmuting.
2016-03-09 20:16:20 -08:00
Eduard Burtescu
ffa0860467 Track fn type and lifetime parameters in TyFnDef. 2016-03-09 16:45:28 +02:00
Eli Friedman
b423a0f9ef Split TyBareFn into TyFnDef and TyFnPtr.
There's a lot of stuff wrong with the representation of these types:
TyFnDef doesn't actually uniquely identify a function, TyFnPtr is used to
represent method calls, TyFnDef in the sub-expression of a cast isn't
correctly reified, and probably some other stuff I haven't discovered yet.
Splitting them seems like the right first step, though.
2016-03-09 16:45:28 +02:00
Jeffrey Seyfried
2998564615 Refactor away ExternalExports 2016-03-06 05:46:49 +00:00
Jeffrey Seyfried
cbae67aea7 Fix #21670 2016-03-06 05:46:47 +00:00
Jeffrey Seyfried
d908ff1759 Don't treat associated types specially in def_privacy
Improve trait privacy error message
2016-03-04 18:30:24 +00:00
Jeffrey Seyfried
13f5fca0f2 privacy: change def_privacy so that it checks for visiblity instead of nameability 2016-03-04 18:30:22 +00:00
Jeffrey Seyfried
37ba66a66e Rename middle::ty::ctxt to TyCtxt 2016-03-03 07:37:56 +00:00
bors
7cee8b9ffb Auto merge of #31824 - jseyfried:privacy_in_resolve, r=nikomatsakis
This PR privacy checks paths as they are resolved instead of in `librustc_privacy` (fixes #12334 and fixes #31779). This removes the need for the `LastPrivate` system introduced in PR #9735, the limitations of which cause #31779.

This PR also reports privacy violations in paths to intra- and inter-crate items the same way -- it always reports the first inaccessible segment of the path.

Since it fixes #31779, this is a [breaking-change]. For example, the following code would break:
```rust
mod foo {
    pub use foo::bar::S;
    mod bar { // `bar` should be private to `foo`
        pub struct S;
    }
}

impl foo::S {
    fn f() {}
}

fn main() {
    foo::bar::S::f(); // This is now a privacy error
}
```

r? @alexcrichton
2016-03-03 02:21:28 +00:00
Vadim Petrochenkov
9047b201bf Move span into StructField
+ some cleanup in rustdoc
2016-03-02 10:32:04 +03:00
Vadim Petrochenkov
8b60b948d9 Get rid of hir::StructFieldKind 2016-03-02 10:31:19 +03:00
Vadim Petrochenkov
fa427266ee Some drive-by improvements to SanePrivacyVisitor
Check that variant fields are not marked public by syntax extensions
2016-02-26 22:06:39 +03:00
Vadim Petrochenkov
df4821698e Permit pub items in blocks 2016-02-26 21:20:56 +03:00
Jeffrey Seyfried
8f32fdecfb Remove LastPrivate 2016-02-26 00:37:27 +00:00
Jeffrey Seyfried
ec0fdd5a4a Lay the groundwork for privacy checking in typeck 2016-02-26 00:37:14 +00:00
Jeffrey Seyfried
5172745da7 Warn instead of error when using an inaccessable extern crate 2016-02-24 01:34:39 +00:00
Steve Klabnik
206e86b947 Rollup merge of #31721 - rphmeier:err_tuplestruct_count, r=Manishearth
Fixes #31706

Also fixes a phrasing error in the diagnostic.
2016-02-19 14:23:28 -05:00