about summary refs log tree commit diff
path: root/src/librustc/lint
AgeCommit message (Collapse)AuthorLines
2014-10-30rollup merge of #18398 : aturon/lint-conventions-2Alex Crichton-20/+18
Conflicts: src/libcollections/slice.rs src/libcore/failure.rs src/libsyntax/parse/token.rs src/test/debuginfo/basic-types-mut-globals.rs src/test/debuginfo/simple-struct.rs src/test/debuginfo/trait-pointers.rs
2014-10-30Remove `unused_extern_crate` and `unused_result` from the `unused` lint groupP1start-2/+2
These lints are allow by default because they are sometimes too sensitive.
2014-10-29Rename fail! to panic!Steve Klabnik-9/+9
https://github.com/rust-lang/rfcs/pull/221 The current terminology of "task failure" often causes problems when writing or speaking about code. You often want to talk about the possibility of an operation that returns a Result "failing", but cannot because of the ambiguity with task failure. Instead, you have to speak of "the failing case" or "when the operation does not succeed" or other circumlocutions. Likewise, we use a "Failure" header in rustdoc to describe when operations may fail the task, but it would often be helpful to separate out a section describing the "Err-producing" case. We have been steadily moving away from task failure and toward Result as an error-handling mechanism, so we should optimize our terminology accordingly: Result-producing functions should be easy to describe. To update your code, rename any call to `fail!` to `panic!` instead. Assuming you have not created your own macro named `panic!`, this will work on UNIX based systems: grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g' You can of course also do this by hand. [breaking-change]
2014-10-28Remove ty_bot from the type systemJakub Bukaj-1/+1
We now instead use a fresh variable for expressions that diverge.
2014-10-28Turn on warning for use of deprecated lint namesAaron Turon-8/+6
2014-10-28Update code with new lint namesAaron Turon-12/+12
2014-10-24Add a lint for not using field pattern shorthandsP1start-2/+37
Closes #17792.
2014-10-20Stability lint checker now handles nested macros.Victor Berger-16/+22
Closes #17185.
2014-10-19Remove a large amount of deprecated functionalityAlex Crichton-4/+4
Spring cleaning is here! In the Fall! This commit removes quite a large amount of deprecated functionality from the standard libraries. I tried to ensure that only old deprecated functionality was removed. This is removing lots and lots of deprecated features, so this is a breaking change. Please consult the deprecation messages of the deleted code to see how to migrate code forward if it still needs migration. [breaking-change]
2014-10-14rustc: Add deprecation/renaming support for lintsAaron Turon-6/+70
Since a large number of lints are being renamed for RFC 344, this commit adds some basic deprecation/renaming functionality to the pluggable lint system. It allows a simple mapping of old to new names, and can warn when old names are being used. This change needs to be rolled out in stages. In this commit, the deprecation warning is commented out, but the old name is forwarded to the new one. Once the commit lands and we have generated a new snapshot of the compiler, we can add the deprecation warning and rename all uses of the lints in the rust codebase.
2014-10-14rustc: Improve lint descriptionsAaron Turon-2/+2
Improves the description of `dead_code` and `unreachable_code` to clarify the difference between them.
2014-10-14rustc: Add missing lint registrationAaron Turon-1/+2
The pluggable lint changes apparently dropped the fat pointer transmute lint by accident. This commit registers the lint.
2014-10-14rustc: Rename lints per RFC 344Aaron Turon-108/+108
RFC 344 proposes a set of naming conventions for lints. This commit renames existing lints to follow the conventions. Use the following sed script to bring your code up to date: ``` s/unnecessary_typecast/unused_typecasts/g s/unsigned_negate/unsigned_negation/g s/type_limits/unused_comparisons/g s/type_overflow/overflowing_literals/g s/ctypes/improper_ctypes/g s/owned_heap_memory/box_pointers/g s/unused_attribute/unused_attributes/g s/path_statement/path_statements/g s/unused_must_use/unused_must_use/g s/unused_result/unused_results/g s/non_uppercase_statics/non_upper_case_globals/g s/unnecessary_parens/unused_parens/g s/unnecessary_import_braces/unused_import_braces/g s/unused_unsafe/unused_unsafe/g s/unsafe_block/unsafe_blocks/g s/unused_mut/unused_mut/g s/unnecessary_allocation/unused_allocation/g s/missing_doc/missing_docs/g s/unused_imports/unused_imports/g s/unused_extern_crate/unused_extern_crates/g s/unnecessary_qualification/unused_qualifications/g s/unrecognized_lint/unknown_lints/g s/unused_variable/unused_variables/g s/dead_assignment/unused_assignments/g s/unknown_crate_type/unknown_crate_types/g s/variant_size_difference/variant_size_differences/g s/transmute_fat_ptr/fat_ptr_transmutes/g ``` Closes #16545 Closes #17932 Due to deprecation, this is a: [breaking-change]
2014-10-10Handle `while let` desugaringJohn Gallagher-1/+2
2014-10-10auto merge of #17037 : kmcallister/rust/no-stack-check, r=thestingerbors-0/+1
r? @brson Fixes #16980.
2014-10-09Rename the no_split_stack attribute to no_stack_checkKeegan McAllister-0/+1
The old name is misleading as we haven't had segmented stacks in quite some time. But we still recognize it, with a deprecation warning.
2014-10-09rustc: Convert statics to constantsAlex Crichton-4/+4
2014-10-09rustc: Add `const` globals to the languageAlex Crichton-2/+3
This change is an implementation of [RFC 69][rfc] which adds a third kind of global to the language, `const`. This global is most similar to what the old `static` was, and if you're unsure about what to use then you should use a `const`. The semantics of these three kinds of globals are: * A `const` does not represent a memory location, but only a value. Constants are translated as rvalues, which means that their values are directly inlined at usage location (similar to a #define in C/C++). Constant values are, well, constant, and can not be modified. Any "modification" is actually a modification to a local value on the stack rather than the actual constant itself. Almost all values are allowed inside constants, whether they have interior mutability or not. There are a few minor restrictions listed in the RFC, but they should in general not come up too often. * A `static` now always represents a memory location (unconditionally). Any references to the same `static` are actually a reference to the same memory location. Only values whose types ascribe to `Sync` are allowed in a `static`. This restriction is in place because many threads may access a `static` concurrently. Lifting this restriction (and allowing unsafe access) is a future extension not implemented at this time. * A `static mut` continues to always represent a memory location. All references to a `static mut` continue to be `unsafe`. This is a large breaking change, and many programs will need to be updated accordingly. A summary of the breaking changes is: * Statics may no longer be used in patterns. Statics now always represent a memory location, which can sometimes be modified. To fix code, repurpose the matched-on-`static` to a `const`. static FOO: uint = 4; match n { FOO => { /* ... */ } _ => { /* ... */ } } change this code to: const FOO: uint = 4; match n { FOO => { /* ... */ } _ => { /* ... */ } } * Statics may no longer refer to other statics by value. Due to statics being able to change at runtime, allowing them to reference one another could possibly lead to confusing semantics. If you are in this situation, use a constant initializer instead. Note, however, that statics may reference other statics by address, however. * Statics may no longer be used in constant expressions, such as array lengths. This is due to the same restrictions as listed above. Use a `const` instead. [breaking-change] [rfc]: https://github.com/rust-lang/rfcs/pull/246
2014-10-03Move the lint for the stability lints to the method name onlyP1start-2/+5
Closes #17337.
2014-10-03Improve the `non_snake_case` lint to give better suggestionsP1start-1/+5
2014-10-03Update the `unused` lint group to include more lintsP1start-5/+6
2014-10-03Set the `non_uppercase_statics` lint to warn by defaultP1start-1/+2
2014-10-02rustc: remove support for Gc.Eduard Burtescu-19/+1
2014-10-02syntax: ast: remove TyBox and UnBox.Eduard Burtescu-1/+1
2014-09-30auto merge of #17634 : jakub-/rust/if_let, r=kballardbors-2/+5
Continuation of https://github.com/rust-lang/rust/pull/16741.
2014-09-30Produce a better error for irrefutable `if let` patternsKevin Ballard-2/+5
Modify ast::ExprMatch to include a new value of type ast::MatchSource, making it easy to tell whether the match was written literally or produced via desugaring. This allows us to customize error messages appropriately.
2014-09-30librustc: Stop looking in metadata in type contents.Patrick Walton-0/+1
4x improvement in pre-trans compile time for rustc.
2014-09-25auto merge of #17378 : Gankro/rust/hashmap-entry, r=aturonbors-2/+6
Deprecates the `find_or_*` family of "internal mutation" methods on `HashMap` in favour of the "external mutation" Entry API as part of RFC 60. Part of #17320, but this still needs to be done on the rest of the maps. However they don't have any internal mutation methods defined, so they can be done without deprecating or breaking anything. Work on `BTree` is part of the complete rewrite in #17334. The implemented API deviates from the API described in the RFC in two key places: * `VacantEntry.set` yields a mutable reference to the inserted element to avoid code duplication where complex logic needs to be done *regardless* of whether the entry was vacant or not. * `OccupiedEntry.into_mut` was added so that it is possible to return a reference into the map beyond the lifetime of the Entry itself, providing functional parity to `VacantEntry.set`. This allows the full find_or_insert functionality to be implemented using this API. A PR will be submitted to the RFC to amend this. [breaking-change]
2014-09-24handling fallout from entry apiAlexis Beingessner-2/+6
2014-09-24Remove unused enum variantsJakub Wieczorek-20/+6
2014-09-22librustc: Forbid private types in public APIs.Patrick Walton-4/+0
This breaks code like: struct Foo { ... } pub fn make_foo() -> Foo { ... } Change this code to: pub struct Foo { // note `pub` ... } pub fn make_foo() -> Foo { ... } The `visible_private_types` lint has been removed, since it is now an error to attempt to expose a private type in a public API. In its place a `#[feature(visible_private_types)]` gate has been added. Closes #16463. RFC #48. [breaking-change]
2014-09-22Lint stability now checks macro arguments.Victor Berger-2/+21
Closes #17185.
2014-09-19rollup merge of #17338 : nick29581/variants-namespaceAlex Crichton-3/+3
2014-09-19rollup merge of #17314 : eddyb/span-no-gcAlex Crichton-2/+2
2014-09-19Add enum variants to the type namespaceNick Cameron-3/+3
Change to resolve and update compiler and libs for uses. [breaking-change] Enum variants are now in both the value and type namespaces. This means that if you have a variant with the same name as a type in scope in a module, you will get a name clash and thus an error. The solution is to either rename the type or the variant.
2014-09-18rustc: remove BindingMode from DefLocal.Eduard Burtescu-1/+1
2014-09-18rustc: remove DefArg and DefBinding in favor of DefLocal.Eduard Burtescu-2/+1
2014-09-18rustc: fix fallout from removing the use of Gc for ExpnInfo.Eduard Burtescu-2/+2
2014-09-17librustc: Implement associated types behind a feature gate.Patrick Walton-7/+35
The implementation essentially desugars during type collection and AST type conversion time into the parameter scheme we have now. Only fully qualified names--e.g. `<T as Foo>::Bar`--are supported.
2014-09-17rollup merge of #17312 : Manishearth/builtin-shrinkAlex Crichton-5/+2
2014-09-17rollup merge of #16931 : omasanori/unnecessary-path-bracketsAlex Crichton-0/+36
2014-09-16Fallout from renamingAaron Turon-5/+5
2014-09-16Clean up code for unused_must_use lintManish Goregaokar-5/+2
2014-09-15trans -- stop tracking vtables precisely, instead recompute as needed.Niko Matsakis-5/+5
2014-09-14rustc: fix fallout from using ptr::P.Eduard Burtescu-42/+43
2014-09-12auto merge of #17134 : vberger/rust/lint_unused_extern_crate, r=alexcrichtonbors-1/+5
This PR creates a new lint : ``unused_extern_crate``, which do pretty much the same thing as ``unused_import``, but for ``extern crate`` statements. It is related to feature request #10385. I adapted the code tracking used imports so that it tracks extern crates usage as well. This was mainly trial and error and while I believe all cases are covered, there might be some code I added that is useless (long compile times didn't give me the opportunity to check this in detail). Also, I removed some unused ``extern crate`` statements from the libs, that where spotted by this new lint.
2014-09-12Track the visited AST's lifetime throughout Visitor.Eduard Burtescu-12/+12
2014-09-12Remove largely unused context from Visitor.Eduard Burtescu-67/+66
2014-09-12New lint : unused_extern_crate. #10385Victor Berger-1/+5
2014-09-10Add unnecessary_import_braces lint.OGINO Masanori-0/+36
The lint checks any unnecessary braces around one imported item like `use std::num::{abs};`. Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>