about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2017-11-05Auto merge of #44042 - LukasKalbertodt:ascii-methods-on-instrinsics, ↵bors-1/+0
r=alexcrichton Copy all `AsciiExt` methods to the primitive types directly in order to deprecate it later **EDIT:** [this PR is ready now](https://github.com/rust-lang/rust/pull/44042#issuecomment-333883548). I edited this post to reflect the current status of discussion, which is (apart from code review) pretty much settled. --- This is my current progress in order to prepare stabilization of #39658. As discussed there (and in #39659), the idea is to deprecated `AsciiExt` and copy all methods to the type directly. Apparently there isn't really a reason to have those methods in an extension trait¹. ~~This is **work in progress**: copy&pasting code while slightly modifying the documentation isn't the most exciting thing to do. Therefore I wanted to already open this WIP PR after doing basically 1/4 of the job (copying methods to `&[u8]`, `char` and `&str` is still missing) to get some feedback before I continue. Some questions possibly worth discussing:~~ 1. ~~Does everyone agree that deprecating `AsciiExt` is a good idea? Does everyone agree with the goal of this PR?~~ => apparently yes 2. ~~Are my changes OK so far? Did I do something wrong?~~ 3. ~~The issue of the unstable-attribute is currently set to 0. I would wait until you say "Ok" to the whole thing, then create a tracking issue and then insert the correct issue id. Is that ok?~~ 4. ~~I tweaked `eq_ignore_ascii_case()`: it now takes the argument `other: u8` instead of `other: &u8`. The latter was enforced by the trait. Since we're not bound to a trait anymore, we can drop the reference, ok?~~ => I reverted this, because the interface has to match the `AsciiExt` interface exactly. ¹ ~~Could it be that we can't write `impl [u8] {}`? This might be the reason for `AsciiExt`. If that is the case: is there a good reason we can't write such an impl block? What can we do instead?~~ => we couldn't at the time this PR was opened, but Simon made it possible. /cc @SimonSapin @zackw
2017-11-04rustc: Handle some libstd symbole exports betterAlex Crichton-0/+6
Right now symbol exports, particularly in a cdylib, are handled by assuming that `pub extern` combined with `#[no_mangle]` means "export this". This isn't actually what we want for some symbols that the standard library uses to implement itself, for example symbols related to allocation. Additionally other special symbols like `rust_eh_personallity` have no need to be exported from cdylib crate types (only needed in dylib crate types). This commit updates how rustc handles these special symbols by adding to the hardcoded logic of symbols like `rust_eh_personallity` but also adding a new attribute, `#[rustc_std_internal_symbol]`, which forces the export level to be considered the same as all other Rust functions instead of looking like a C function. The eventual goal here is to prevent functions like `__rdl_alloc` from showing up as part of a Rust cdylib as it's just an internal implementation detail. This then further allows such symbols to get gc'd by the linker when creating a cdylib.
2017-11-04Auto merge of #45711 - tirr-c:unicode-span, r=estebankbors-2/+41
Display spans correctly when there are zero-width or wide characters Hopefully... * fixes #45211 * fixes #8706 --- Before: ``` error: invalid width `7` for integer literal --> unicode_2.rs:12:25 | 12 | let _ = ("a̐éö̲", 0u7); | ^^^ | = help: valid widths are 8, 16, 32, 64 and 128 error: invalid width `42` for integer literal --> unicode_2.rs:13:20 | 13 | let _ = ("아あ", 1i42); | ^^^^ | = help: valid widths are 8, 16, 32, 64 and 128 error: aborting due to 2 previous errors ``` After: ``` error: invalid width `7` for integer literal --> unicode_2.rs:12:25 | 12 | let _ = ("a̐éö̲", 0u7); | ^^^ | = help: valid widths are 8, 16, 32, 64 and 128 error: invalid width `42` for integer literal --> unicode_2.rs:13:20 | 13 | let _ = ("아あ", 1i42); | ^^^^ | = help: valid widths are 8, 16, 32, 64 and 128 error: aborting due to 2 previous errors ``` Spans might display incorrectly on the browser. r? @estebank
2017-11-04Auto merge of #45394 - davidtwco:rfc-2008, r=petrochenkovbors-0/+9
RFC 2008: Future-proofing enums/structs with #[non_exhaustive] attribute This work-in-progress pull request contains my changes to implement [RFC 2008](https://github.com/rust-lang/rfcs/pull/2008). The related tracking issue is #44109. As of writing, enum-related functionality is not included and there are some issues related to tuple/unit structs. Enum related tests are currently ignored. WIP PR requested by @nikomatsakis [in Gitter](https://gitter.im/rust-impl-period/WG-compiler-middle?at=59e90e6297cedeb0482ade3e).
2017-11-04Rollup merge of #45639 - LaurentMazare:master, r=petrochenkovkennytm-1/+7
Add a nicer error message for missing in for loop, fixes #40782. As suggested by @estebank in issue #40782, this works in the same way as #42578: if the in keyword is missing, we continue parsing the expression and if this works correctly an adapted error message is produced. Otherwise we return the old error. A specific test case has also been added. This is my first PR on rust-lang/rust so any feedback is very welcome.
2017-11-03Copy `AsciiExt` methods to `str` directlyLukas Kalbertodt-1/+0
This is done in order to deprecate AsciiExt eventually. Note that this commit contains a bunch of `cfg(stage0)` statements. This is due to a new compiler feature this commit depends on: the `slice_u8` lang item. Once this lang item is available in the stage0 compiler, all those cfg flags (and more) can be removed.
2017-11-03Added feature gate for RFC 2008.David Wood-0/+9
2017-11-03Auto merge of #45247 - leodasvacas:implement-auto-trait-syntax, r=nikomatsakisbors-24/+71
[Syntax] Implement auto trait syntax Implements `auto trait Send {}` as a substitute for `trait Send {} impl Send for .. {}`. See the [internals thread](https://internals.rust-lang.org/t/pre-rfc-renaming-oibits-and-changing-their-declaration-syntax/3086) for motivation. Part of #13231. The first commit is just a rename moving from "default trait" to "auto trait". The rest is parser->AST->HIR work and making it the same as the current syntax for everything below HIR. It's under the `optin_builtin_traits` feature gate. When can we remove the old syntax? Do we need to wait for a new `stage0`? We also need to formally decide for the new form (even if the keyword is not settled yet). Observations: - If you `auto trait Auto {}` and then `impl Auto for .. {}` that's accepted even if it's redundant. - The new syntax is simpler internally which will allow for a net removal of code, for example well-formedness checks are effectively moved to the parser. - Rustfmt and clippy are broken, need to fix those. - Rustdoc just ignores it for now. ping @petrochenkov @nikomatsakis
2017-11-03Fix unsafe auto trait pretty print.leonardo.yvens-1/+1
It was being printed wrong as auto unsafe trait
2017-11-03Parse auto traits the same as traits.leonardo.yvens-49/+32
This moves the well formedness checks to the AST validation pass. Tests were adjusted. The auto keyword should be back-compat now.
2017-11-03Add tests for `auto trait`, fix parsing bugleonardo.yvens-32/+32
Now we can do the well formedness checks in the parser, yay!
2017-11-03Feature gate `auto trait` and ignore it in rustdocleonardo.yvens-0/+6
2017-11-03add `auto` keyword, parse `auto trait`, lower to HIRleonardo.yvens-7/+65
Adds an `IsAuto` field to `ItemTrait` which flags if the trait was declared as an `auto trait`. Auto traits cannot have generics nor super traits.
2017-11-03[Syntax Breaking] Rename DefaultImpl to AutoImplleonardo.yvens-11/+11
DefaultImpl is a highly confusing name for what we now call auto impls, as in `impl Send for ..`. The name auto impl is not formally decided but for sanity anything is better than `DefaultImpl` which refers neither to `default impl` nor to `impl Default`.
2017-11-03Display spans correctly when there are non-half-width charactersWonwoo Choi-2/+41
2017-11-02Make the difference between lint codes and error codes explicitOliver Schneider-13/+60
2017-11-01Remove the redundant span_label.laurent-1/+0
2017-11-01Auto merge of #45472 - michaelwoerister:incr-comp-caching-base, r=nikomatsakisbors-0/+37
incr.comp.: Implement compiler diagnostic persistence. This PR implements storing and loading diagnostics that the compiler generates and thus allows for emitting warnings during incremental compilation without actually re-evaluating the thing the warning originally came from. It also lays some groundwork for storing and loading type information and MIR in the incr. comp. cache. ~~It is still work in progress:~~ - ~~There's still some documentation to be added.~~ - ~~The way anonymous queries are handled might lead to duplicated emissions of warnings. Not sure if there is a better way or how frequent such duplication would be in practice.~~ Diagnostic message duplication is addressed separately in #45519. r? @nikomatsakis
2017-11-01Preserve original formatting.laurent-4/+1
2017-11-01Remove the parser snapshot hack.laurent-40/+16
2017-11-01Rollup merge of #45644 - zackmdavis:edit_disallowed_inner_attr_note, r=estebankkennytm-5/+4
edit and fix bad spacing of inner-attribute-not-allowed note This multiline string literal was missing a backslash, leaving an awkward newline and 35 spaces in the middle of the message. But while we're here, the existing message seems kind of long in comparison to similar notes: to cut it down, we excise the mentions of doc comments, which seems sensible because we know that this erroneous attribute is not a doc comment (notice the `is_sugared_doc: false` at the end of the function; if it had been a doc comment, that error would get set in the `token::DocComment` match branch of `parse_outer_attributes`).
2017-11-01Rollup merge of #45579 - ↵kennytm-1/+3
leodasvacas:document-that-call-can-be-adt-constructor, r=estebank Document that call expressions also represent ADT constructors. This is a rather obscure part of the language.
2017-10-31Formatting tweak.laurent-2/+1
2017-10-31Add some missing spaces.laurent-1/+1
2017-10-31Fix spans and error messages.laurent-13/+6
2017-10-30edit and fix bad spacing of inner-attribute-not-allowed noteZack M. Davis-5/+4
This multiline string literal was missing a backslash, leaving an awkward newline and 35 spaces in the middle of the message. But while we're here, the existing message seems kind of long in comparison to similar notes: to cut it down, we excise the mentions of doc comments, which seems sensible because we know that this erroneous attribute is not a doc comment (notice the `is_sugared_doc: false` at the end of the function; if it had been a doc comment, that error would get set in the `token::DocComment` match branch of `parse_outer_attributes`).
2017-10-30Add a nicer error message for missing in for loop, fixes #40782.laurent-6/+48
2017-10-28Auto merge of #45489 - oli-obk:json_diagnostics, r=petrochenkovbors-17/+9
Fix a quadradic duplication in json for multi-suggestions r? @petrochenkov
2017-10-28Auto merge of #44295 - plietar:extern-types, r=arielb1bors-8/+55
Implement RFC 1861: Extern types A few notes : - Type parameters are not supported. This was an unresolved question from the RFC. It is not clear how useful this feature is, and how variance should be treated. This can be added in a future PR. - `size_of_val` / `align_of_val` can be called with extern types, and respectively return 0 and 1. This differs from the RFC, which specified that they should panic, but after discussion with @eddyb on IRC this seems like a better solution. If/when a `DynSized` trait is added, this will be disallowed statically. - Auto traits are not implemented by default, since the contents of extern types is unknown. This means extern types are `!Sync`, `!Send` and `!Freeze`. This seems like the correct behaviour to me. Manual `unsafe impl Sync for Foo` is still possible. - This PR allows extern type to be used as the tail of a struct, as described by the RFC : ```rust extern { type OpaqueTail; } #[repr(C)] struct FfiStruct { data: u8, more_data: u32, tail: OpaqueTail, } ``` However this is undesirable, as the alignment of `tail` is unknown (the current PR assumes an alignment of 1). Unfortunately we can't prevent it in the general case as the tail could be a type parameter : ```rust #[repr(C)] struct FfiStruct<T: ?Sized> { data: u8, more_data: u32, tail: T, } ``` Adding a `DynSized` trait would solve this as well, by requiring tail fields to be bound by it. - Despite being unsized, pointers to extern types are thin and can be casted from/to integers. However it is not possible to write a `null<T>() -> *const T` function which works with extern types, as I've explained here : https://github.com/rust-lang/rust/issues/43467#issuecomment-321678621 - Trait objects cannot be built from extern types. I intend to support it eventually, although how this interacts with `DynSized`/`size_of_val` is still unclear. - The definition of `c_void` is unmodified
2017-10-28Auto merge of #45503 - thombles:tk/i44339-v5, r=petrochenkovbors-1/+27
Improve diagnostics when list of tokens has incorrect separators Make `parse_seq_to_before_tokens` more resilient to error conditions. Where possible it is better if it can consume up to the final bracket before returning. This change improves the diagnostics in a couple of situations: ``` struct S(pub () ()); // omitted separator use std::{foo. bar}; // used a similar but wrong separator ``` Fixes #44339 r? @petrochenkov
2017-10-27Implement RFC 1861: Extern typesPaul Lietar-8/+55
2017-10-27Document that call expressions also represent ADT constructors.leonardo.yvens-1/+3
This is a rather obscure part of the language.
2017-10-26Auto merge of #45464 - sinkuu:ice_44851, r=jseyfriedbors-1/+30
Visit attribute tokens in `DefCollector` and `BuildReducedGraphVisitor` Fixes #44851.
2017-10-26Add FIXMEsinkuu-0/+1
2017-10-25Auto merge of #44636 - GuillaumeGomez:little-error-msg, r=michaelwoeristerbors-2/+5
Add short error message-format Fixes #42653.
2017-10-25incr.comp.: Implement query diagnostic persistence.Michael Woerister-0/+37
2017-10-24Reduce the repetition in json error outputOliver Schneider-17/+9
2017-10-25Improve recovery after unexpected tokens parsing sequenceThomas Karpiniec-1/+27
2017-10-24Auto merge of #45401 - zackmdavis:crate_shorthand_visibility_modifier, ↵bors-4/+31
r=nikomatsakis `crate` shorthand visibility modifier cc #45388. r? @nikomatsakis
2017-10-24Auto merge of #44766 - sunjay:lift_generics, r=nikomatsakisbors-32/+38
Move Generics from MethodSig to TraitItem and ImplItem As part of `rust-impl-period/WG-compiler-traits`, we want to "lift" `Generics` from `MethodSig` into `TraitItem` and `ImplItem`. This is in preparation for adding associated type generics. (https://github.com/rust-lang/rust/issues/44265#issuecomment-331172238) Currently this change is only made in the AST. In the future, it may also impact the HIR. (Still discussing) To understand this PR, it's probably best to start from the changes to `ast.rs` and then work your way to the other files to understand the far reaching effects of this change. r? @nikomatsakis
2017-10-23Fix #44851 by visiting tokens in `DefCollector` and `BuildReducedGraphVisitor`sinkuu-1/+29
2017-10-22`crate` shorthand visibility modifierZack M. Davis-4/+31
With regrets, this breaks rustfmt and rls. This is in the matter of #45388.
2017-10-20Add short message-formatGuillaume Gomez-2/+5
2017-10-19Auto merge of #45232 - zackmdavis:moar_lint_suggestions, r=estebankbors-0/+11
code suggestions for non-shorthand field pattern, no-mangle lints continuing in the spirit of #44942 ![moar_lint_suggestions](https://user-images.githubusercontent.com/1076988/31485011-3b20cc80-aee7-11e7-993d-81267ab77732.png) r? @estebank
2017-10-17Removed Generics from FnKind::ItemFn in libsyntaxSunjay Varma-6/+6
2017-10-17Fixed tidy errorsSunjay Varma-2/+4
2017-10-17Lifting Generics from MethodSig to TraitItem and ImplItem since we want to ↵Sunjay Varma-26/+30
support generics in each variant of TraitItem and ImplItem
2017-10-16code suggestion for non-shorthand field patterns lintZack M. Davis-0/+11
We also edit the lint description to clarify that this is different from the struct field init shorthand.
2017-10-15don't issue "expected statement after outer attr." after inner attr.Zack M. Davis-2/+2
While an inner attribute here is in fact erroneous, that error ("inner attribute is not permitted in this context") successfully gets set earlier; this further admonition is nonsensical. Resolves #45296.
2017-10-14Implement `dyn Trait` syntaxVadim Petrochenkov-32/+67