about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2020-06-26Auto merge of #73513 - oli-obk:const_binop_overflow, r=estebankbors-870/+972
Show the values and computation that would overflow a const evaluation or propagation Fixes #71134 In contrast to the example in the issue it doesn't use individual spans for each operand. The effort required to implement that is quite high compared to the little (if at all) benefit it would bring to diagnostics. cc @shepmaster The way this is implemented it is also fairly easy to do the same for overflow panics at runtime, but that should be done in a separate PR since it may have runtime performance implications.
2020-06-26Show the values and computation that would overflow a const evaluation or ↵Oliver Scherer-870/+972
propagation
2020-06-26Rollup merge of #73681 - jackh726:chalk-0.14, r=nikomatsakisManish Goregaokar-38/+85
Update Chalk to 0.14 Not a ton here. Notable changes: - Update to `0.14.0` - New dependency on `tracing`, in `librustc_traits` only - `FnAbi` from Chalk is `rustc_target::spec::abi::Abi` - `Dynamic` actually lowers region - Actually lower closures, with some tests. This doesn't 100% work, but can't confirm that's *only* because of closure lowering. - Use `FxIndexSet` instead of `FxHashSet` in `chalk_fulfill`, which seems to have fixed the non-deterministic test error ordering. Guess we'll see on CI - Actually implement `opaque_ty_data`, though I don't think this is sufficient for tests for them (I haven't added any) - Uncomment some of the chalk tests that now work r? @nikomatsakis
2020-06-26Rollup merge of #72620 - tmiasko:linkage-name, r=eddybManish Goregaokar-0/+42
Omit DW_AT_linkage_name when it is the same as DW_AT_name The DWARF standard suggests that it might be useful to include `DW_AT_linkage_name` when it is *distinct* from the identifier name. Fixes #46487. Fixes #59422.
2020-06-26Auto merge of #73746 - Manishearth:rollup-80jnynm, r=Manishearthbors-37/+725
Rollup of 14 pull requests Successful merges: - #72617 (Add a fast path for `std::thread::panicking`.) - #72738 (Self contained linking option) - #72770 (Implement mixed script confusable lint.) - #73418 (Add unstable `core::mem::variant_count` intrinsic) - #73460 (Emit line info for generator variants) - #73534 (Provide suggestions for some moved value errors) - #73538 (make commented examples use valid syntax, and be more consistent ) - #73581 (Create 0766 error code) - #73619 (Document the mod keyword) - #73621 (Document the mut keyword) - #73648 (Document the return keyword) - #73673 (Fix ptr doc warnings.) - #73674 (Tweak binop errors) - #73687 (Clean up E0701 explanation) Failed merges: - #73708 (Explain move errors that occur due to method calls involving `self` (take two)) r? @ghost
2020-06-25Rollup merge of #73674 - estebank:op-trait-bound-suggestion, r=davidtwcoManish Goregaokar-4/+77
Tweak binop errors * Suggest potentially missing binop trait bound (fix #73416) * Use structured suggestion for dereference in binop
2020-06-25Rollup merge of #73581 - GuillaumeGomez:add-0766, r=varkorManish Goregaokar-1/+2
Create 0766 error code
2020-06-25Rollup merge of #73534 - estebank:borrowck-suggestions, r=matthewjasperManish Goregaokar-0/+264
Provide suggestions for some moved value errors When encountering an used moved value where the previous move happened in a `match` or `if let` pattern, suggest using `ref`. Fix #63988. When encountering a `&mut` value that is used in multiple iterations of a loop, suggest reborrowing it with `&mut *`. Fix #62112.
2020-06-25Rollup merge of #73460 - tmandry:variant-lineinfo, r=oli-obkManish Goregaokar-2/+234
Emit line info for generator variants Debuggers should be able to read a generator / async fn state machine and show the line it's suspended at. Eventually, this could grow into an "async stack trace" feature of sorts. While no debugger support this for Rust today, this PR adds the debuginfo necessary for that support to exist. [This gist](https://gist.github.com/tmandry/6d7004fa008684f76809208847459f9b) shows the resulting debuginfo for a simple example. Here's a snippet: ``` 0x00000986: DW_TAG_variant DW_AT_discr_value (0x03) 0x00000988: DW_TAG_member DW_AT_name ("3") DW_AT_type (0x000009bc "Suspend0") DW_AT_decl_file ("/home/tmandry/code/playground/generator-simple.rs") DW_AT_decl_line (6) DW_AT_alignment (8) DW_AT_data_member_location (0x00) ``` The file and line have been added here. The line currently points to the beginning of the statement containing the yield (or await), because that's what the MIR source info points to for the yield terminator. (We may want to point to the yield or await line specifically, but that can be done independently of this change.) Debuggers don't know how to use this kind of info yet. However, we're hoping to experiment with adding such support to Fuchsia's debugger. It would be exciting if someone were interested in adding similar to support to gdb/lldb. r? @oli-obk cc @eddyb @jonas-schievink Part of #73524.
2020-06-25Rollup merge of #73418 - doctorn:variants-intrinsic, r=kennytmManish Goregaokar-0/+47
Add unstable `core::mem::variant_count` intrinsic Adds a new `const fn` intrinsic which can be used to determine the number of variants in an `enum`. I've shown this to a couple of people and they invariably ask 'why on earth?', but there's actually a very neat use case: At the moment, if you want to create an opaque array type that's indexed by an `enum` with one element for each variant, you either have to hard-code the number of variants, add a `LENGTH` variant or use a `Vec`, none of which are suitable in general (number of variants could change; pattern matching `LENGTH` becomes frustrating; might not have `alloc`). By including this intrinsic, it becomes possible to write the following: ```rust #[derive(Copy, Clone)] enum OpaqueIndex { A = 0, B, C, } struct OpaqueVec<T>(Box<[T; std::mem::num_variants::<OpaqueIndex>()]>); impl<T> std::ops::Index<OpaqueIndex> for OpaqueVec<T> { type Output = T; fn index(&self, idx: OpaqueIndex) -> &Self::Output { &self.0[idx as usize] } } ``` (We even have a use cases for this in `rustc` and I plan to use it to re-implement the lang-items table.)
2020-06-25Rollup merge of #72770 - crlf0710:mixed_script_confusable, r=ManishearthManish Goregaokar-30/+101
Implement mixed script confusable lint. This implements the mixed script confusable lint defined in RFC 2457. This is blocked on #72069 and https://github.com/unicode-rs/unicode-security/pull/13, and will need a Cargo.toml version bump after those are resolved. The lint message warning is sub-optimal for now. We'll need a mechanism to properly output `AugmentScriptSet` to screen, this is to be added in `unicode-security` crate. r? @Manishearth
2020-06-25Auto merge of #71858 - petrochenkov:env, r=Mark-Simulacrumbors-0/+14
Print environment variables accessed by rustc as special comments into depinfo files So cargo (and perhaps others tools) can use them for linting (at least) or for actually rebuilding crates on env var changes. --- I've recently observed one more forgotten environment variable in a build script https://github.com/rust-lang/rust/pull/71314/commits/8a77d1ca3fc2df789157f7986ddbaf2a377ff0fe and thought it would be nice to provide the list of accessed variables to cargo automatically as a part of depinfo. Unsurprisingly, I wasn't the first who had this idea - cc https://github.com/rust-lang/rust/issues/70517 https://github.com/rust-lang/rust/issues/40364 https://github.com/rust-lang/rust/issues/44074. Also, there are dozens of uses of `(option_)env!` in rustc repo and, like, half of them are not registered in build scripts. --- Description: - depinfo files are extended with special comments containing info about environment variables accessed during compilation. - Comment format for environment variables with successfully retrieved value: `# env-dep:KEY=VALUE`. - Comment format for environment variables without successfully retrieved value: `# env-dep:KEY` (can happen with `option_env!`). - `KEY` and `VALUE` are minimally escaped (`\n`, `\r`, `\\`) so they don't break makefile comments and can be unescaped by anything that can unescape standard `escape_default` and friends. FCP report: https://github.com/rust-lang/rust/pull/71858#issuecomment-633071488 Closes https://github.com/rust-lang/rust/issues/70517 Closes https://github.com/rust-lang/rust/issues/40364 Closes https://github.com/rust-lang/rust/issues/44074 A new issue in the cargo repo will be needed to track the cargo side of this feature. r? @ehuss
2020-06-26Implement mixed script confusable lint.Charles Lew-5/+76
2020-06-25Auto merge of #73711 - Dylan-DPC:rollup-kzx15of, r=Dylan-DPCbors-0/+466
Rollup of 6 pull requests Successful merges: - #72700 (`improper_ctypes_definitions` lint) - #73516 (Allow dynamic linking for iOS/tvOS targets) - #73616 (Liballoc minor hash import tweak) - #73634 (Add UI test for issue 73592) - #73688 (Document the self keyword) - #73698 (Add procedure for prioritization notifications on Zulip) Failed merges: r? @ghost
2020-06-25Update UI testGuillaume Gomez-1/+2
2020-06-24Provide suggestions for some moved value errorsEsteban Küber-0/+264
When encountering an used moved value where the previous move happened in a `match` or `if let` pattern, suggest using `ref`. Fix #63988. When encountering a `&mut` value that is used in multiple iterations of a loop, suggest reborrowing it with `&mut *`. Fix #62112.
2020-06-25Rollup merge of #73634 - nbdd0121:typeck, r=nikomatsakisDylan DPC-0/+82
Add UI test for issue 73592 It happens that #72280 accidentally fixed a bug which is later discovered in #73592. This PR adds a UI test to prevent future regression. Closes #73592
2020-06-25Rollup merge of #72700 - davidtwco:issue-66220-improper-ctypes-declarations, ↵Dylan DPC-0/+384
r=lcnr,varkor `improper_ctypes_definitions` lint Addresses #19834, #66220, and #66373. This PR takes another attempt at #65134 (reverted in #66378). Instead of modifying the existing `improper_ctypes` lint to consider `extern "C" fn` definitions in addition to `extern "C" {}` declarations, this PR adds a new lint - `improper_ctypes_definitions` - which only applies to `extern "C" fn` definitions. In addition, the `improper_ctype_definitions` lint differs from `improper_ctypes` by considering `*T` and `&T` (where `T: Sized`) FFI-safe (addressing #66220). There wasn't a clear consensus in #66220 (where the issues with #65134 were primarily discussed) on the approach to take, but there has [been some discussion in Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.2366220.20improper_ctypes.20definitions.20vs.20declarations/near/198903086). I fully expect that we'll want to iterate on this before landing. cc @varkor + @shepmaster (from #19834) @hanna-kruppe (active in discussing #66220), @SimonSapin (#65134 caused problems for Servo, want to make sure that this PR doesn't)
2020-06-24Suggest type param trait bound for binop only when appropriateEsteban Küber-28/+33
Verify that the binop trait *is* implemented for the types *if* all the involved type parameters are replaced with fresh inferred types. When this is the case, it means that the type parameter was indeed missing a trait bound. If this is not the case, provide a generic `note` refering to the type that doesn't implement the expected trait.
2020-06-24Implement associated lang itemsAaron Hill-0/+48
Fixes #70718 This commit allows making associated items (e.g. associated functions and types) into lang items via the `#[lang]` attribute. This allows such items to be accessed directly, rather than by iterating over the parent item's associated items. I've added `FnOnce::Output` as a lang item, and updated one old usage to use the new lang item. The remaining uses can be updated separately.
2020-06-24Split out async fn and generator testTyler Mandry-72/+102
This keeps FileCheck from tripping over unimportant differences in codegen.
2020-06-24Give up on checking filenameTyler Mandry-8/+4
2020-06-24Add generator-debug test for MSVCTyler Mandry-0/+88
..which doesn't use variant types.
2020-06-24Generalize generator-debug test a bitTyler Mandry-21/+19
Don't be so reliant on particular line ordering (though FileCheck makes this hard in general, IMO). Also disable for MSVC.
2020-06-24Improve GeneratorLayout debug outputTyler Mandry-2/+28
2020-06-24Add test for generator debuginfoTyler Mandry-0/+94
2020-06-24Emit line info for generator variantsTyler Mandry-2/+2
2020-06-24review comments: clean up codeEsteban Küber-1/+1
* deduplicate logic * fix typos * remove unnecessary state
2020-06-24Fix testsNathan Corbyn-0/+1
2020-06-24Implement intrinsicNathan Corbyn-0/+46
2020-06-24Rollup merge of #73652 - da-x:add-reexported-to-use-suggestions, r=petrochenkovDylan DPC-9/+20
Add re-exports to use suggestions In the following example, an inaccessible path is suggested via `use foo::bar::X;` whereas an accessible public exported path can be suggested instead. ```rust mod foo { mod bar { pub struct X; } pub use self::bar::X; } fn main() { X; } ``` This fixes the issue.
2020-06-24Rollup merge of #73646 - JohnTitor:add-tests, r=Dylan-DPCDylan DPC-0/+152
Add some regression tests Closes #44861 Closes #51506 Closes #59435 Closes #69840
2020-06-24Rollup merge of #73639 - ayazhafiz:i/73553, r=davidtwcoDylan DPC-0/+43
Change heuristic for determining range literal Currently, rustc uses a heuristic to determine if a range expression is not a literal based on whether the expression looks like a function call or struct initialization. This fails for range literals whose lower/upper bounds are the results of function calls. A possibly-better heuristic is to check if the expression contains `..`, required in range literals. Of course, this is also not perfect; for example, if the range expression is a struct which includes some text with `..` this will fail, but in general I believe it is a better heuristic. A better alternative altogether is to add the `QPath::LangItem` enum variant suggested in #60607. I would be happy to do this as a precursor to this patch if someone is able to provide general suggestions on how usages of `QPath` need to be changed later in the compiler with the `LangItem` variant. Closes #73553
2020-06-24improper_ctypes: allow pointers to sized typesDavid Wood-84/+24
This commit changes the improper ctypes lint (when operating on definitions) to consider raw pointers or references to sized types as FFI-safe. Signed-off-by: David Wood <david@davidtw.co>
2020-06-24lints: add `improper_ctypes_definitions`David Wood-0/+444
This commit adds a new lint - `improper_ctypes_definitions` - which functions identically to `improper_ctypes`, but on `extern "C" fn` definitions (as opposed to `improper_ctypes`'s `extern "C" {}` declarations). Signed-off-by: David Wood <david@davidtw.co>
2020-06-24Update ChalkJack Huey-38/+85
2020-06-24Auto merge of #73293 - Aaron1011:feature/macro-rules-arg-capture, r=petrochenkovbors-0/+179
Always capture tokens for `macro_rules!` arguments When we invoke a proc-macro, the `TokenStream` we pass to it may contain 'interpolated' AST fragments, represented by `rustc_ast::token::Nonterminal`. In order to correctly, pass a `Nonterminal` to a proc-macro, we need to have 'captured' its `TokenStream` at the time the AST was parsed. Currently, we perform this capturing when attributes are present on items and expressions, since we will end up using a `Nonterminal` to pass the item/expr to any proc-macro attributes it is annotated with. However, `Nonterminal`s are also introduced by the expansion of metavariables in `macro_rules!` macros. Since these metavariables may be passed to proc-macros, we need to have tokens available to avoid the need to pretty-print and reparse (see https://github.com/rust-lang/rust/issues/43081). This PR unconditionally performs token capturing for AST items and expressions that are passed to a `macro_rules!` invocation. We cannot know in advance if captured item/expr will be passed to proc-macro, so this is needed to ensure that tokens will always be available when they are needed. This ensures that proc-macros will receive tokens with proper `Spans` (both location and hygiene) in more cases. Like all work on https://github.com/rust-lang/rust/issues/43081, this will cause regressions in proc-macros that were relying on receiving tokens with dummy spans. In this case, Crater revealed only one regression: the [Pear](https://github.com/SergioBenitez/Pear) crate (a helper for [rocket](https://github.com/SergioBenitez/Rocket)), which was previously [fixed](https://github.com/SergioBenitez/Pear/pull/25) as part of https://github.com/rust-lang/rust/pull/73084. This regression manifests itself as the following error: ``` [INFO] [stdout] error: proc macro panicked [INFO] [stdout] --> /opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/rocket_http-0.4.5/src/parse/uri/parser.rs:119:34 [INFO] [stdout] | [INFO] [stdout] 119 | let path_and_query = pear_try!(path_and_query(is_pchar)); [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = help: message: called `Option::unwrap()` on a `None` value [INFO] [stdout] = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) ``` It can be fixed by running `cargo update -p pear`, which updates your `Cargo.lock` to use the latest version of Pear (which includes a bugfix for the regression). Split out from https://github.com/rust-lang/rust/pull/73084/
2020-06-23Tweak binop errorsEsteban Küber-3/+71
* Suggest potentially missing binop trait bound (fix #73416) * Use structured suggestion for dereference in binop
2020-06-23Auto merge of #73669 - Manishearth:rollup-0n4u7vq, r=Manishearthbors-73/+302
Rollup of 11 pull requests Successful merges: - #72780 (Enforce doc alias check) - #72876 (Mention that BTreeMap::new() doesn't allocate) - #73244 (Check for assignments between non-conflicting generator saved locals) - #73488 (code coverage foundation for hash and num_counters) - #73523 (Fix -Z unpretty=everybody_loops) - #73587 (Move remaining `NodeId` APIs from `Definitions` to `Resolver`) - #73601 (Point at the call span when overflow occurs during monomorphization) - #73613 (The const propagator cannot trace references.) - #73614 (fix `intrinsics::needs_drop` docs) - #73630 (Provide context on E0308 involving fn items) - #73665 (rustc: Modernize wasm checks for atomics) Failed merges: r? @ghost
2020-06-23Rollup merge of #73630 - estebank:fn-item-e0308, r=davidtwcoManish Goregaokar-10/+55
Provide context on E0308 involving fn items Fix #73487.
2020-06-23Rollup merge of #73613 - oli-obk:const_prop_miscompile, r=wesleywiserManish Goregaokar-40/+166
The const propagator cannot trace references. Thus we avoid propagation of a local the moment we encounter references to it. fixes #73609 cc @RalfJung r? @wesleywiser
2020-06-23Rollup merge of #73601 - Aaron1011:fix/better-mono-overflow-err, ↵Manish Goregaokar-23/+52
r=ecstatic-morse Point at the call span when overflow occurs during monomorphization This improves the output for issue #72577, but there's still more work to be done. Currently, an overflow error during monomorphization results in an error that points at the function we were unable to monomorphize. However, we don't point at the call that caused the monomorphization to happen. In the overflow occurs in a large recursive function, it may be difficult to determine where the issue is. This commit tracks and `Span` information during collection of `MonoItem`s, which is used when emitting an overflow error. `MonoItem` itself is unchanged, so this only affects `src/librustc_mir/monomorphize/collector.rs`
2020-06-23Rollup merge of #72780 - GuillaumeGomez:enforce-doc-alias-check, r=ollie27Manish Goregaokar-0/+29
Enforce doc alias check Part of #50146. r? @ollie27
2020-06-23review comments: wording and styleEsteban Küber-20/+20
2020-06-23Auto merge of #73644 - ollie27:rustdoc_alias_filter, r=GuillaumeGomezbors-0/+37
rustdoc: Fix doc aliases with crate filtering Fix a crash when searching for an alias contained in the currently selected filter crate. Also remove alias search results for crates that should be filtered out. The test suite needed to be fixed to actually take into account the crate filtering and check that there are no results when none are expected. Needs to be backported to beta to fix the `std` docs. Fixes #73620 r? @GuillaumeGomez
2020-06-23Add re-exports to use suggestionsDan Aloni-9/+20
In the following example, an inaccessible path is suggested via `use foo::bar::X;` whereas an accessible public exported path can be suggested instead. ``` mod foo { mod bar { pub struct X; } pub use self::bar::X; } fn main() { X; } ``` This fixes the issue.
2020-06-23Add test for issue-69840Yuki Okushi-0/+16
2020-06-23Add test for issue-59435Yuki Okushi-0/+29
2020-06-23Add test for issue-51506Yuki Okushi-0/+55
2020-06-23Add test for issue-44861Yuki Okushi-0/+52