about summary refs log tree commit diff
path: root/compiler/rustc_error_codes/src
AgeCommit message (Collapse)AuthorLines
2020-10-27Rollup merge of #78332 - PoignardAzur:doc_E0308, r=camelidYuki Okushi-12/+20
Update description for error E0308 Fixes #76462 r? @camelid
2020-10-25Update description for error E0308Olivier FAURE-12/+20
As per #76462
2020-10-17Rollup merge of #77971 - jyn514:broken-intra-doc-links, r=mark-simulacrumYuki Okushi-5/+5
Deny broken intra-doc links in linkchecker Since rustdoc isn't warning about these links, check for them manually. This also fixes the broken links that popped up from the lint.
2020-10-15Deny broken intra-doc links in linkcheckerJoshua Nelson-5/+5
Since rustdoc isn't warning about these links, check for them manually.
2020-10-16Rollup merge of #76119 - Amjad50:stabilizing-move_ref_pattern, r=nikomatsakisDylan DPC-2/+6
Stabilize move_ref_pattern # Implementation - Initially the rule was added in the run-up to 1.0. The AST-based borrow checker was having difficulty correctly enforcing match expressions that combined ref and move bindings, and so it was decided to simplify forbid the combination out right. - The move to MIR-based borrow checking made it possible to enforce the rules in a finer-grained level, but we kept the rule in place in an effort to be conservative in our changes. - In #68376, @Centril lifted the restriction but required a feature-gate. - This PR removes the feature-gate. Tracking issue: #68354. # Description This PR is to stabilize the feature `move_ref_pattern`, which allows patterns containing both `by-ref` and `by-move` bindings at the same time. For example: `Foo(ref x, y)`, where `x` is `by-ref`, and `y` is `by-move`. The rules of moving a variable also apply here when moving *part* of a variable, such as it can't be referenced or moved before. If this pattern is used, it would result in *partial move*, which means that part of the variable is moved. The variable that was partially moved from cannot be used as a whole in this case, only the parts that are still not moved can be used. ## Documentation - The reference (rust-lang/reference#881) - Rust by example (rust-lang/rust-by-example#1377) ## Tests There are many tests, but I think one of the comperhensive ones: - [borrowck-move-ref-pattern-pass.rs](https://github.com/Centril/rust/blob/85fbf49ce0e2274d0acf798f6e703747674feec3/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs) - [borrowck-move-ref-pattern.rs](https://github.com/Centril/rust/blob/85fbf49ce0e2274d0acf798f6e703747674feec3/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs) # Examples ```rust #[derive(PartialEq, Eq)] struct Finished {} #[derive(PartialEq, Eq)] struct Processing { status: ProcessStatus, } #[derive(PartialEq, Eq)] enum ProcessStatus { One, Two, Three, } #[derive(PartialEq, Eq)] enum Status { Finished(Finished), Processing(Processing), } fn check_result(_url: &str) -> Status { // fetch status from some server Status::Processing(Processing { status: ProcessStatus::One, }) } fn wait_for_result(url: &str) -> Finished { let mut previous_status = None; loop { match check_result(url) { Status::Finished(f) => return f, Status::Processing(p) => { match (&mut previous_status, p.status) { (None, status) => previous_status = Some(status), // first status (Some(previous), status) if *previous == status => {} // no change, ignore (Some(previous), status) => { // Now it can be used // new status *previous = status; } } } } } } ``` Before, we would have used: ```rust match (&previous_status, p.status) { (Some(previous), status) if *previous == status => {} // no change, ignore (_, status) => { // new status previous_status = Some(status); } } ``` Demonstrating *partial move* ```rust fn main() { #[derive(Debug)] struct Person { name: String, age: u8, } let person = Person { name: String::from("Alice"), age: 20, }; // `name` is moved out of person, but `age` is referenced let Person { name, ref age } = person; println!("The person's age is {}", age); println!("The person's name is {}", name); // Error! borrow of partially moved value: `person` partial move occurs //println!("The person struct is {:?}", person); // `person` cannot be used but `person.age` can be used as it is not moved println!("The person's age from person struct is {}", person.age); } ```
2020-10-10Fix typo in error code descriptionNaoki Hayama-1/+1
s/abitrary/arbitrary/
2020-10-08Implement the instruction_set attributexd009642-0/+69
2020-10-07Auto merge of #77464 - ecstatic-morse:const-fn-impl-trait, r=oli-obkbors-12/+4
Give `impl Trait` in a `const fn` its own feature gate ...previously it was gated under `#![feature(const_fn)]`. I think we actually want to do this in all const-contexts? If so, this should be `#![feature(const_impl_trait)]` instead. I don't think there's any way to make use of `impl Trait` within a `const` initializer. cc #77463 r? `@oli-obk`
2020-10-06Update error code pageDylan MacKenzie-12/+4
2020-10-06Don't immediately error for recursive projectionsMatthew Jasper-1/+1
2020-10-06Fix toolsMatthew Jasper-23/+15
2020-10-01Create E0777 error code for "invalid literal in derive"Guillaume Gomez-0/+20
2020-10-01Auto merge of #77354 - ecstatic-morse:const-checking-moar-errors, r=oli-obkbors-37/+1
Overhaul const-checking diagnostics The primary purpose of this PR was to remove `NonConstOp::STOPS_CONST_CHECKING`, which causes any additional errors found by the const-checker to be silenced. I used this flag to preserve diagnostic parity with `qualify_min_const_fn.rs`, which has since been removed. However, simply removing the flag caused a deluge of errors in some cases, since an error would be emitted any time a local or temporary had a wrong type. To remedy this, I added an alternative system (`DiagnosticImportance`) to silence additional error messages that were likely to distract the user from the underlying issue. When an error of the highest importance occurs, all less important errors are silenced. When no error of the highest importance occurs, all less important errors are emitted after checking is complete. Following the suggestions from the important error is usually enough to fix the less important errors, so this should lead to better UX most of the time. There's also some unrelated diagnostics improvements in this PR isolated in their own commits. Splitting them out would be possible, but a bit of a pain. This isn't as tidy as some of my other PRs, but it should *only* affect diagnostics, never whether or not something passes const-checking. Note that there are a few trivial exceptions to this, like banning `Yield` in all const-contexts, not just `const fn`. As always, meant to be reviewed commit-by-commit. r? `@oli-obk`
2020-09-30Remove E0019, use E0015 for inline assembly in a constDylan MacKenzie-39/+1
2020-09-30Add more tests and check for ABIHugues de Valon-1/+15
Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
2020-09-30Add support for cmse_nonsecure_entry attributeHugues de Valon-0/+18
This patch adds support for the LLVM cmse_nonsecure_entry attribute. This is a target-dependent attribute that only has sense for the thumbv8m Rust targets. You can find more information about this attribute here: https://developer.arm.com/documentation/ecm0359818/latest/ Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
2020-09-29Rewrite E0019 exampleDylan MacKenzie-4/+6
Inline assembly is now the only user of E0019. What is it doing that E0015 is not?
2020-09-25Rollup merge of #76973 - lzutao:unstably-const-assume, r=oli-obkJonas Schievink-4/+4
Unstably allow assume intrinsic in const contexts Not sure much about this usage because there are concerns about [blocking optimization][1] and [slowing down LLVM][2] when using `assme` intrinsic in inline functions. But since Oli suggested in https://github.com/rust-lang/rust/issues/76960#issuecomment-695772221, here we are. [1]: https://github.com/rust-lang/rust/pull/54995#issuecomment-429302709 [2]: https://github.com/rust-lang/rust/issues/49572#issuecomment-589615423
2020-09-21Add explanation for E0756Guillaume Gomez-1/+30
2020-09-21Rollup merge of #76439 - GuillaumeGomez:add-error-explanation-e0755, ↵Ralf Jung-1/+29
r=pickfire,jyn514 Add error explanation for E0755 r? @pickfire
2020-09-20Correct file path after some restructures in compilerLzu Tao-4/+4
2020-09-15Adjust spellingNiclas Schwarzlose-2/+2
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-15Disabled error `E0007` from rustc_error_codesAmjad Alsharafi-2/+6
2020-09-11Improve E0118 descriptionaticu-3/+24
2020-09-09Rollup merge of #75984 - kornelski:typeormodule, r=matthewjasperTyler Mandry-3/+13
Improve unresolved use error message "use of undeclared type or module `foo`" doesn't mention that it could be a crate. This error can happen when users forget to add a dependency to `Cargo.toml`, so I think it's important to mention that it could be a missing crate. I've used a heuristic based on Rust's naming conventions. It complains about an unknown type if the ident starts with an upper-case letter, and crate or module otherwise. It seems to work very well. The expanded error help covers both an unknown type and a missing crate case.
2020-09-09Auto merge of #76406 - GuillaumeGomez:create-e0774, r=pickfire,jyn514bors-0/+25
Create E0774
2020-09-09Auto merge of #76463 - camelid:improve-E0607-explanation, r=jyn514bors-7/+7
Improve wording of E0607 explanation `@rustbot` modify labels: A-diagnostics C-enhancement
2020-09-08Create new E0774 code errorGuillaume Gomez-0/+25
2020-09-08Add error explanation for E0755Guillaume Gomez-1/+29
2020-09-07Add "For example,"Camelid-3/+3
2020-09-07Improve wording of E0607 explanationCamelid-7/+7
2020-09-08Auto merge of #75138 - jumbatm:session-diagnostic-derive, r=oli-obkbors-2/+2
Add derive macro for specifying diagnostics using attributes. Introduces `#[derive(SessionDiagnostic)]`, a derive macro for specifying structs that can be converted to Diagnostics using directions given by attributes on the struct and its fields. Currently, the following attributes have been implemented: - `#[code = "..."]` -- this sets the Diagnostic's error code, and must be provided on the struct iself (ie, not on a field). Equivalent to calling `code`. - `#[message = "..."]` -- this sets the Diagnostic's primary error message. - `#[label = "..."]` -- this must be applied to fields of type `Span`, and is equivalent to `span_label` - `#[suggestion(..)]` -- this allows a suggestion message to be supplied. This attribute must be applied to a field of type `Span` or `(Span, Applicability)`, and is equivalent to calling `span_suggestion`. Valid arguments are: - `message = "..."` -- this sets the suggestion message. - (Optional) `code = "..."` -- this suggests code for the suggestion. Defaults to empty. `suggestion`also comes with other variants: `#[suggestion_short(..)]`, `#[suggestion_hidden(..)]` and `#[suggestion_verbose(..)]` which all take the same keys. Within the strings passed to each attribute, fields can be referenced without needing to be passed explicitly into the format string -- eg, `#[error = "{ident} already declared"] ` will set the error message to `format!("{} already declared", &self.ident)`. Any fields on the struct can be referenced in this way. Additionally, for any of these attributes, Option fields can be used to only optionally apply the decoration -- for example: ```rust #[derive(SessionDiagnostic)] #[code = "E0123"] struct SomeKindOfError { ... #[suggestion(message = "informative error message")] opt_sugg: Option<(Span, Applicability)> ... } ``` will not emit a suggestion if `opt_sugg` is `None`. We plan on iterating on this macro further; this PR is a start. Closes #61132. r? `@oli-obk`
2020-09-01Rollup merge of #76143 - jyn514:duplicate-builtin-macros, r=petrochenkovTyler Mandry-0/+39
Give a better error message for duplicate built-in macros Minor follow-up to https://github.com/rust-lang/rust/pull/75176 giving a better error message for duplicate builtin macros. This would have made it a little easier to debug. r? @petrochenkov
2020-09-01Clarify message about unresolved useKornel-3/+13
2020-09-01Fix typos in E0224jumbatm-2/+2
2020-09-01Give a better error message for duplicate built-in macrosJoshua Nelson-0/+39
Previously, this would say no such macro existed, but this was misleading, since the macro _did_ exist, it was just already seen. - Say where the macro was previously defined - Add long-form error message
2020-08-31Rollup merge of #76103 - GuillaumeGomez:cleanup-e0769, r=Dylan-DPCTyler Mandry-7/+15
Clean up E0769 r? @pickfire cc @Dylan-DPC
2020-08-31Clean up E0764 explanationGuillaume Gomez-9/+13
2020-08-31Clean up E0769 explanationGuillaume Gomez-7/+15
2020-08-30mv compiler to compiler/mark-0/+15139