summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2020-10-05Add regression test for SimplifyBranchSame miscompilationTomasz Miąsko-0/+21
2020-10-03repairing broken error message and rustfix application for the new testAurélien Deharbe-9/+23
case
2020-10-03add non-regression test for issue #76597Aurélien Deharbe-0/+21
2020-10-03Better handling for exponential-sized types in misc placesValerii Lashmanov-11/+15
Mostly to fix ui/issues/issue-37311-type-length-limit/issue-37311.rs. Most parts of the compiler can handle deeply nested types with a lot of duplicates just fine, but some parts still attempt to naively traverse type tree. Before such problems were caught by type length limit check, but now these places will have to be changed to handle duplicated types gracefully.
2020-10-03Only visit types once when walking the type treeValerii Lashmanov-7/+70
This fixes #72408. Nested closures were resulting in exponential compilation time. As a performance optimization this change introduces MiniSet, which is a simple small storage optimized set.
2020-10-02Revert "Promote missing_fragment_specifier to hard error"Mark Rousskov-16/+37
This reverts commit 02eae432e7476a0686633a8c2b7cb1d5aab1bd2c.
2020-10-02Revert "Move macro test to ui/macros"Mark Rousskov-0/+0
This reverts commit 84fcd0dc991e2f5b9035d118d8c016f35ab37d0a.
2020-09-28revert const_type_id stabilizationAshley Mannix-4/+7
This reverts commit e3856616ee2a894c7811a7017d98fafa7ba84dd8.
2020-09-28[mir-opt] Disable the `ConsideredEqual` logic in SimplifyBranchSame optWesley Wiser-15/+31
The logic is currently broken and we need to disable it to fix a beta regression (see #76803)
2020-09-17Account for async functions when suggesting new named lifetimeEsteban Küber-12/+36
Fix #75850.
2020-09-17Account for version number in NtIdent hackAaron Hill-7/+43
Issue #74616 tracks a backwards-compatibility hack for certain macros. This has is implemented by hard-coding the filenames and macro names of certain code that we want to continue to compile. However, the initial implementation of the hack was based on the directory structure when building the crate from its repository (e.g. `js-sys/src/lib.rs`). When the crate is build as a dependency, it will include a version number from the clone from the cargo registry (e.g. `js-sys-0.3.17/src/lib.rs`), which would fail the check. This commit modifies the backwards-compatibility hack to check that desired crate name (`js-sys` or `time-macros-impl`) is a prefix of the proper part of the path. See https://github.com/rust-lang/rust/issues/76070#issuecomment-687215646 for more details.
2020-09-17Add ui test for 74672 and 76571Lzu Tao-0/+46
These tests will fall without the next commit.
2020-08-24Stabilize Range[Inclusive]::is_emptyScott McMurray-1/+0
I would like to propose these two simple methods for stabilization: - Knowing that a range is exhaused isn't otherwise trivial - Clippy would like to suggest them, but had to do extra work to disable that path <https://github.com/rust-lang/rust-clippy/issues/3807> because they're unstable - These work on `PartialOrd`, consistently with now-stable `contains`, and are thus more general than iterator-based approaches that need `Step` - They've been unchanged for some time, and have picked up uses in the compiler - Stabilizing them doesn't block any future iterator-based is_empty plans, as the inherent ones are preferred in name resolution
2020-08-24Auto merge of #75815 - jyn514:ambiguous-primitives, r=guillaumegomezbors-8/+91
Report an ambiguity if both modules and primitives are in scope for intra-doc links Closes https://github.com/rust-lang/rust/issues/75381 - Add a new `prim@` disambiguator, since both modules and primitives are in the same namespace - Refactor `report_ambiguity` into a closure Additionally, I noticed that rustdoc would previously allow `[struct@char]` if `char` resolved to a primitive (not if it had a DefId). I fixed that and added a test case. I also need to update libstd to use `prim@char` instead of `type@char`. If possible I would also like to refactor `ambiguity_error` to use `Disambiguator` instead of its own hand-rolled match - that ran into issues with `prim@` (I updated one and not the other) and it would be better for them to be in sync.
2020-08-24Rollup merge of #75831 - lzutao:https, r=Dylan-DPCYuki Okushi-1/+1
doc: Prefer https link for wikipedia URLs A tiny changes.
2020-08-23Update primitive test to match the new behaviorJoshua Nelson-8/+8
2020-08-23Report an ambiguity if both modules and primitives are in scopeJoshua Nelson-0/+83
- Add a new `prim@` disambiguator, since both modules and primitives are in the same namespace - Refactor `report_ambiguity` into a closure Additionally, I noticed that rustdoc would previously allow `[struct@char]` if `char` resolved to a primitive (not if it had a DefId). I fixed that and added a test case.
2020-08-23Auto merge of #74489 - jyn514:assoc-items, r=manishearth,petrochenkovbors-0/+123
Fix intra-doc links for associated items @Manishearth and I found that links of the following sort are broken: ```rust $ cat str_from.rs /// [`String::from`] pub fn foo() {} $ rustdoc str_from.rs warning: `[String::from]` cannot be resolved, ignoring it. --> str_from.rs:4:6 | 4 | /// [`String::from`] | ^^^^^^^^^^^^^^ cannot be resolved, ignoring ``` It turns out this is because the current implementation only looks at inherent impls (`impl Bar {}`) and traits _for the item being documented_. Note that this is not the same as the item being _linked_ to. So this code would work: ```rust pub trait T1 { fn method(); } pub struct S; impl T1 for S { /// [S::method] on method fn method() {} } ``` but putting the documentation on `trait T1` would not. ~~I realized that writing it up that my fix is only partially correct: It removes the inherent impls code when it should instead remove the `trait_item` code.~~ Fixed. Additionally, I discovered while writing this there is some ambiguity: you could have multiple methods with the same name, but for different traits: ```rust pub trait T1 { fn method(); } pub trait T2 { fn method(); } /// See [S::method] pub struct S; ``` Rustdoc should give an ambiguity error here, but since there is currently no way to disambiguate the traits (https://github.com/rust-lang/rust/issues/74563) it does not (https://github.com/rust-lang/rust/pull/74489#issuecomment-673878404). There is a _third_ ambiguity that pops up: What if the trait is generic and is implemented multiple times with different generic parameters? In this case, my fix does not do very well: it thinks there is only one trait instantiated and links to that trait: ``` /// [`String::from`] -- this resolves to https://doc.rust-lang.org/nightly/alloc/string/struct.String.html#method.from pub fn foo() {} ``` However, every `From` implementation has a method called `from`! So the browser picks a random one. This is not the desired behavior, but it's not clear how to avoid it. To be consistent with the rest of intra-doc links, this only resolves associated items from traits that are in scope. This required changes to rustc_resolve to work cross-crate; the relevant commits are prefixed with `resolve: `. As a bonus, considering only traits in scope is slightly faster. To avoid re-calculating the traits over and over, rustdoc uses a cache to store the traits in scope for a given module.
2020-08-23Auto merge of #75656 - tirr-c:match-suggest-semi, r=estebankbors-0/+116
Provide better spans for the match arm without tail expression Resolves #75418. Applied the same logic in the `if`-`else` type mismatch case. r? @estebank
2020-08-23Auto merge of #72449 - ecstatic-morse:const-float-bitcast, r=RalfJungbors-0/+170
Const floating point bitcasts and classification Makes the `f32` and `f64` methods described in #72447 and #72505 unstably const. r? @RalfJung
2020-08-23Fix `compile-flags` directiveecstatic-morse-2/+2
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-08-23Auto merge of #74238 - RalfJung:offset_from, r=oli-obkbors-15/+10
stabilize ptr_offset_from This stabilizes ptr::offset_from, and closes https://github.com/rust-lang/rust/issues/41079. It also removes the deprecated `wrapping_offset_from`. This function was deprecated 19 days ago and was never stable; given an FCP of 10 days and some waiting time until FCP starts, that leaves at least a month between deprecation and removal which I think is fine for a nightly-only API. Regarding the open questions in https://github.com/rust-lang/rust/issues/41079: * Should offset_from abort instead of panic on ZSTs? -- As far as I know, there is no precedent for such aborts. We could, however, declare this UB. Given that the size is always known statically and the check thus rather cheap, UB seems excessive. * Should there be more methods like this with different restrictions (to allow nuw/nsw, perhaps) or that return usize (like how isize-taking offset is more conveniently done with usize-taking add these days)? -- No reason to block stabilization on that, we can always add such methods later. Also nominating the lang team because this exposes an intrinsic. The stabilized method is best described [by its doc-comment](https://github.com/RalfJung/rust/blob/56d4b2d69abb93e4f0ca79471deca7aaaaeca214/src/libcore/ptr/const_ptr.rs#L227). The documentation forgot to mention the requirement that both pointers must "have the same provenance", aka "be derived from pointers to the same allocation", which I am adding in this PR. This is a precondition that [Miri already implements](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=a3b9d0a07a01321f5202cd99e9613480) and that, should LLVM ever obtain a `psub` operation to subtract pointers, will likely be required for that operation (following the semantics in [this paper](https://people.mpi-sws.org/~jung/twinsem/twinsem.pdf)).
2020-08-23Prefer https link for wikipedia URLsLzu Tao-1/+1
2020-08-23Auto merge of #75465 - Aaron1011:feature/short-fn-def-span, r=estebankbors-543/+252
Use smaller def span for functions Currently, the def span of a function encompasses the entire function signature and body. However, this is usually unnecessarily verbose - when we are pointing at an entire function in a diagnostic, we almost always want to point at the signature. The actual contents of the body tends to be irrelevant to the diagnostic we are emitting, and just takes up additional screen space. This commit changes the `def_span` of all function items (freestanding functions, `impl`-block methods, and `trait`-block methods) to be the span of the signature. For example, the function ```rust pub fn foo<T>(val: T) -> T { val } ``` now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T` (everything before the opening curly brace). Trait methods without a body have a `def_span` which includes the trailing semicolon. For example: ```rust trait Foo { fn bar(); } ``` the function definition `Foo::bar` has a `def_span` of `fn bar();` This makes our diagnostic output much shorter, and emphasizes information that is relevant to whatever diagnostic we are reporting. We continue to use the full span (including the body) in a few of places: * MIR building uses the full span when building source scopes. * 'Outlives suggestions' use the full span to sort the diagnostics being emitted. * The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]` attribute points the entire scope body. All of these cases work only with local items, so we don't need to add anything extra to crate metadata.
2020-08-23Auto merge of #73526 - cuviper:rust-llvm11, r=nikicbors-18/+20
Upgrade to LLVM 11 (rc2) This builds on #73525 to try actually moving rust-lang/llvm-project to LLVM 11.
2020-08-23Auto merge of #73084 - Aaron1011:feature/new-recursive-expand, r=petrochenkovbors-62/+172
Re-land PR #72388: Recursively expand `TokenKind::Interpolated` in `probably_equal_for_proc_macro` PR #72388 allowed us to preserve the original `TokenStream` in more cases during proc-macro expansion, but had to be reverted due to a large number of regressions (See #72545 and #72622). These regressions fell into two categories 1. Missing handling for `Group`s with `Delimiter::None`, which are inserted during `macro_rules!` expansion (but are lost during stringification and re-parsing). A large number of these regressions were due to `syn` and `proc-macro-hack`, but several crates needed changes to their own proc-macro code. 2. Legitimate hygiene issues that were previously being masked by stringification. Some of these were relatively benign (e.g. [a compiliation error](https://github.com/paritytech/parity-scale-codec/pull/210) caused by misusing `quote_spanned!`). However, two crates had intentionally written unhygenic `macro_rules!` macros, which were able to access identifiers that were not passed as arguments (see https://github.com/rust-lang/rust/issues/72622#issuecomment-636402573). All but one of the Crater regressions have now been fixed upstream (see https://hackmd.io/ItrXWRaSSquVwoJATPx3PQ?both). The remaining crate (which has a PR pending at https://github.com/sammhicks/face-generator/pull/1) is not on `crates.io`, and is a Yew application that seems unlikely to have any reverse dependencies. As @petrochenkov mentioned in https://github.com/rust-lang/rust/issues/72545#issuecomment-638632434, not re-landing PR #72388 allows more crates to write unhygenic `macro_rules!` macros, which will eventually stop compiling. Since there is only one Crater regression remaining, since additional crates could write unhygenic `macro_rules!` macros in the time it takes that PR to be merged.
2020-08-22Use smaller def span for functionsAaron Hill-543/+252
Currently, the def span of a funtion encompasses the entire function signature and body. However, this is usually unnecessarily verbose - when we are pointing at an entire function in a diagnostic, we almost always want to point at the signature. The actual contents of the body tends to be irrelevant to the diagnostic we are emitting, and just takes up additional screen space. This commit changes the `def_span` of all function items (freestanding functions, `impl`-block methods, and `trait`-block methods) to be the span of the signature. For example, the function ```rust pub fn foo<T>(val: T) -> T { val } ``` now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T` (everything before the opening curly brace). Trait methods without a body have a `def_span` which includes the trailing semicolon. For example: ```rust trait Foo { fn bar(); }``` the function definition `Foo::bar` has a `def_span` of `fn bar();` This makes our diagnostic output much shorter, and emphasizes information that is relevant to whatever diagnostic we are reporting. We continue to use the full span (including the body) in a few of places: * MIR building uses the full span when building source scopes. * 'Outlives suggestions' use the full span to sort the diagnostics being emitted. * The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]` attribute points the entire scope body. * The 'unconditional recursion' lint uses the full span to show additional context for the recursive call. All of these cases work only with local items, so we don't need to add anything extra to crate metadata.
2020-08-22Add backwards-compat hack for certain '$name' tokensAaron Hill-0/+60
See issue #74616
2020-08-22Recursively expand `TokenKind::Interpolated` (take 2)Aaron Hill-62/+112
Fixes #68430 This is a re-attempt of PR #72388, which was previously reverted due to a large number of breakages. All of the known breakages should now be patched upstream.
2020-08-22Write coverage filenames in Version3 formatJosh Stone-1/+1
2020-08-22Match scalar-pair-bool more flexibly for LLVM 11Josh Stone-2/+3
LLVM 11 started using `phi` and `select` for `fn pair_i32_bool`, which is still valid, but harder to match than the simple instructions we were getting before. We'll just check that the unpacked args are directly referenced in any way, and call it good.
2020-08-22Expand RISCV pseudo-instructions to match LLVM 11Josh Stone-15/+16
2020-08-22Test new floating point bit castsDylan MacKenzie-0/+170
2020-08-22Auto merge of #74566 - lzutao:guard, r=petrochenkovbors-0/+430
Gate if-let guard feature Enhanced on #74315. That PR is in crater queue so I don't want to push to it. Close #74232 cc #51114
2020-08-22remove feature gate from testsRalf Jung-15/+10
2020-08-22Auto merge of #75776 - ↵bors-5/+54
GuillaumeGomez:missing-doc-examples-lint-improvements, r=jyn514 Missing doc examples lint improvements Fixes #75719. To be merged after #75718 (only the two last commits are from this PR). Since you already reviewed #75718, I'll set you as reviewer here as well. :) r? @jyn514
2020-08-22rustdoc: Only resolve traits in scopeJoshua Nelson-0/+37
2020-08-22rustdoc: Add support for associated items even outside the impl itselfJoshua Nelson-0/+86
Previously, associated items would only be available for linking directly on the `impl Trait for Type`. Now they can be used anywhere. - Make `item` for resolve mandatory - Refactor resolving associated items into a separate function - Remove broken trait_item logic - Don't skip the type namespace for associated items - Only call `variant_field` for `TypeNS` - Add test for associated items - Use exhaustive matches instead of wildcards Wildcards caused several bugs while implementing this.
2020-08-22Rollup merge of #75781 - Amanieu:asm-fix, r=nagisaDylan DPC-0/+5
More inline asm register name fixups for LLVM Fixes #75761 r? @nagisa
2020-08-22Rollup merge of #75771 - tmiasko:const-eval-query-stack-normalize, ↵Dylan DPC-2/+3
r=jonas-schievink Extend normalization in const-eval-query-stack test Builds with debuginfo have additional information in backtrace.
2020-08-22Rollup merge of #75718 - GuillaumeGomez:coverage-ui-doc-examples-count, r=jyn514Dylan DPC-59/+111
Don't count variants/fields/consts/associated types in doc-coverage doc examples Fixes #75714. I think I'll need to update the equivalent lint too. Creating an issue for that! r? @jyn514
2020-08-21Add regression testAmanieu d'Antras-0/+5
2020-08-21Strenghten tests for missing_doc_code_examples lintGuillaume Gomez-5/+54
2020-08-21Auto merge of #75697 - lzutao:mir-dumb-const-prefix, r=oli-obkbors-128/+128
Suppress "const" prefix of FnDef constants in MIR dump I [was asked][1] to suppress the `const` infront of `FnDef`. I tried to suppress comments for other types, but turned out that `const ()` and `()` is different: https://github.com/rust-lang/rust/pull/75697#discussion_r473892806 [1]: https://github.com/rust-lang/rust/pull/75670#issuecomment-675574333
2020-08-21Rollup merge of #75532 - tmiasko:rfc-1014, r=nikomatsakisYuki Okushi-2/+4
Fix RFC-1014 test Use two printlns when testing that writing to a closed stdout does not panic. Otherwise the test is ineffective, since the current implementation silently ignores the error during first println regardless.
2020-08-21Auto merge of #74846 - Aaron1011:fix/pat-token-capture, r=petrochenkovbors-2/+56
Capture tokens for Pat used in macro_rules! argument This extends PR #73293 to handle patterns (Pat). Unlike expressions, patterns do not support custom attributes, so we only need to capture tokens during macro_rules! argument parsing.
2020-08-21Suppress "const" prefix of FnDef in MIR dumpLzu Tao-128/+128
2020-08-21Extend normalization in const-eval-query-stack testTomasz Miąsko-2/+3
Builds with debuginfo have additional information in backtrace.
2020-08-20Auto merge of #75494 - matthewjasper:defer-recursive-projection-error, ↵bors-47/+103
r=nikomatsakis Don't immediately error for cycles during normalization #73452 meant some normalization cycles could be detected earlier, breaking some code. This PR makes defers errors for normalization cycles to fulfillment, fixing said code. Fixes #74868 r? @nikomatsakis
2020-08-20Update how doc examples are countedGuillaume Gomez-8/+31