about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2021-04-15Rollup merge of #84201 - jyn514:primitive-warnings, r=cuviperDylan DPC-0/+5
rustdoc: Note that forbidding anchors in links to primitives is a bug cc https://github.com/rust-lang/rust/issues/83083, https://github.com/rust-lang/rust/pull/84147#discussion_r613518820 r? `@cuviper`
2021-04-15Rollup merge of #84185 - hi-rustin:rustin-patch-macro, r=nikomatsakisDylan DPC-0/+113
add more pat2021 tests close https://github.com/rust-lang/rust/issues/84138 r? ```@nikomatsakis```
2021-04-14Auto merge of #84130 - Aaron1011:fix/none-delim-lookahead, r=petrochenkovbors-0/+15
Fix lookahead with None-delimited group Fixes https://github.com/rust-lang/rust/issues/84162, a regression introduced by https://github.com/rust-lang/rust/pull/82608.
2021-04-14rustdoc: Note that forbidding anchors in links to primitives is a bugJoshua Nelson-0/+5
2021-04-14Auto merge of #83948 - ABouttefeux:lint-nullprt-deref, r=RalfJungbors-0/+109
add lint deref_nullptr detecting when a null ptr is dereferenced fixes #83856 changelog: add lint that detect code like ```rust unsafe { &*core::ptr::null::<i32>() }; unsafe { addr_of!(std::ptr::null::<i32>()) }; let x: i32 = unsafe {*core::ptr::null()}; let x: i32 = unsafe {*core::ptr::null_mut()}; unsafe {*(0 as *const i32)}; unsafe {*(core::ptr::null() as *const i32)}; ``` ``` warning: Dereferencing a null pointer causes undefined behavior --> src\main.rs:5:26 | 5 | let x: i32 = unsafe {*core::ptr::null()}; | ^^^^^^^^^^^^^^^^^^ | | | a null pointer is dereferenced | this code causes undefined behavior when executed | = note: `#[warn(deref_nullptr)]` on by default ``` Limitation: It does not detect code like ```rust const ZERO: usize = 0; unsafe {*(ZERO as *const i32)}; ``` or code where `0` is not directly a literal
2021-04-14test: add reasonable casehi-rustin-2/+2
2021-04-14test: add more caseshi-rustin-3/+69
2021-04-14Auto merge of #83068 - mockersf:method-trait-foreign-impl, r=GuillaumeGomezbors-0/+65
rustdoc: links from items in a trait impl are inconsistent Depending on where the struct implementing a trait is coming from, or the current page, the items in a trait impl are not linking to the same thing: |item| trait page, implementors| trait page, implementations on Foreign Types|struct page, trait implementations| |-|-|-|-| |function| link to current impl|link to first impl in the list|link to trait def |default function | not present |not present |link to trait def |default function with custom impl|link to current impl|link to trait def |link to trait def |constant| link to current impl|link to trait def |link to trait def |associated type| link to current impl|link to trait def |link to trait def ||*missing link to trait def*|*function link wrong + missing link to current impl*|*missing link to current impl*| <details> <summary>rust code with those cases</summary> ```rust pub trait MyTrait { type Assoc; const VALUE: u32; fn trait_function(&self); fn defaulted(&self) {} fn defaulted_override(&self) {} } impl MyTrait for String { /// will link to trait def type Assoc = (); /// will link to trait def const VALUE: u32 = 5; /// will link to first foreign implementor fn trait_function(&self) {} /// will link to trait def fn defaulted_override(&self) {} } impl MyTrait for Vec<u8> { /// will link to trait def type Assoc = (); /// will link to trait def const VALUE: u32 = 5; /// will link to first foreign implementor fn trait_function(&self) {} /// will link to trait def fn defaulted_override(&self) {} } impl MyTrait for MyStruct { /// in trait page, will link to current impl /// /// in struct page, will link to trait def type Assoc = bool; /// in trait page, will link to current impl /// /// in struct page, will link to trait def const VALUE: u32 = 20; /// in trait page, will link to current impl /// /// in struct page, will link to trait def fn trait_function(&self) {} /// in trait page, will link to current impl /// /// in struct page, will link to trait def fn defaulted_override(&self) {} } pub struct MyStruct; ``` </details> In this PR, I fixed all links to target the trait definition, and added an anchor-link to the current implementation appearing on mouse hover.
2021-04-14add macro-or-patterns-2021 testhi-rustin-0/+47
2021-04-14Auto merge of #83762 - camelid:bare-urls-note, r=jyn514bors-0/+34
Add explanatory note to `bare_urls` lint I think the lint is confusing otherwise since it doesn't fully explain what the problem is.
2021-04-13remove line length ignoreFrançois Mockers-2/+0
2021-04-13forgot test assertions for default methodFrançois Mockers-0/+2
2021-04-13add testFrançois Mockers-0/+65
2021-04-13Auto merge of #84153 - Dylan-DPC:rollup-5jiqrwu, r=Dylan-DPCbors-3/+64
Rollup of 6 pull requests Successful merges: - #83438 (Update RELEASES.md) - #83707 (Remove `T: Debug` bound on UnsafeCell Debug impl) - #84084 (Stabilize duration_zero.) - #84121 (Stabilize BTree{Map,Set}::retain) - #84140 (Don't call bump in check_mistyped_turbofish_with_multiple_type_params) - #84141 (Fix typo in error message) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-04-13Rollup merge of #84141 - camelid:fix-typo, r=Dylan-DPCDylan DPC-3/+6
Fix typo in error message Also tweaked the message a bit by - removing the hyphen, because in my opinion the hyphen makes the message a bit harder to read, especially combined with the backticks; - adding the word "be", because I think it's a bit clearer that way.
2021-04-13Rollup merge of #84140 - b-naber:parser_past_eof, r=varkorDylan DPC-0/+58
Don't call bump in check_mistyped_turbofish_with_multiple_type_params Fixes https://github.com/rust-lang/rust/issues/84117
2021-04-13Auto merge of #84099 - tmiasko:asm-only-x86_64, r=Amanieubors-5/+7
Check for asm support in UI tests that require it Add `needs-asm-support` compiletest directive, and use it in asm tests that require asm support without relying on any architecture specific features. Closes #84038.
2021-04-12Add explanatory note to `bare_urls` lintCamelid-0/+34
I think the lint is confusing otherwise since it doesn't fully explain what the problem is.
2021-04-13Auto merge of #84082 - andjo403:stabilize_nonzero_leading_trailing_zeros, ↵bors-1/+32
r=m-ou-se Stabilize nonzero_leading_trailing_zeros Stabilizing nonzero_leading_trailing_zeros and due to this also stabilizing the intrinsic cttz_nonzero FCP finished here: https://github.com/rust-lang/rust/issues/79143#issuecomment-817216153 `@rustbot` modify labels: +T-libs Closes #79143
2021-04-13Check for asm support in UI tests that require itTomasz Miąsko-5/+7
Add `needs-asm-support` compiletest directive, and use it in asm tests that require asm support without relying on any architecture specific features.
2021-04-12Fix typo in error messageCamelid-3/+6
Also tweaked the message a bit by - removing the hyphen, because in my opinion the hyphen makes the message a bit harder to read, especially combined with the backticks; - adding the word "be", because I think it's a bit clearer that way.
2021-04-12add testb-naber-0/+58
2021-04-12Turn old edition lints (anonymous-parameters, keyword-idents) into ↵Manish Goregaokar-77/+84
warn-by-default on 2015
2021-04-12Fix lookahead with None-delimited groupAaron Hill-0/+15
2021-04-12Auto merge of #84068 - Amanieu:fix_lint, r=lcnrbors-12/+15
Add `bad_asm_style` to HardwiredLints This was missed when the lint was added, which prevents the lint from being ignored with `#[allow]`.
2021-04-12Rollup merge of #84101 - jyn514:early-pass, r=ManishearthDylan DPC-1/+14
rustdoc: Move crate loader to collect_intra_doc_links::early This groups the similar code together, and also allows making most of collect_intra_doc_links private again. This builds on https://github.com/rust-lang/rust/pull/84066, but it wouldn't be too hard to base it off master if you want this to land first. Helps with https://github.com/rust-lang/rust/issues/83761. r? manishearth Fixes https://github.com/rust-lang/rust/issues/84046
2021-04-12Rollup merge of #84079 - camelid:improve-bare-urls-test, r=jyn514Dylan DPC-18/+80
Improve test for `rustdoc::bare_urls` lint - Rename `url-improvements` test to `bare-urls` - Run rustfix for `bare-urls` test
2021-04-12Rollup merge of #84014 - estebank:cool-bears-hot-tip, r=varkorDylan DPC-31/+155
Improve trait/impl method discrepancy errors * Use more accurate spans * Clean up some code by removing previous hack * Provide structured suggestions Structured suggestions are particularly useful for cases where arbitrary self types are used, like in custom `Future`s, because the way to write `self: Pin<&mut Self>` is not necessarily self-evident when first encountered.
2021-04-12Rollup merge of #83669 - kwj2104:issue-81508-fix, r=varkorDylan DPC-0/+43
Issue 81508 fix Fix #81508 **Problem**: When variable name is used incorrectly as path, error and warning point to undeclared/unused name, when in fact the name is used, just incorrectly (should be used as a variable, not part of a path). **Summary for fix**: When path resolution errs, diagnostics checks for variables in ```ValueNS``` that have the same name (e.g., variable rather than path named Foo), and adds additional suggestion that user may actually intend to use the variable name rather than a path. The fix does not suppress or otherwise change the *warning* that results. I did not find a straightforward way in the code to modify this, but would love to make changes here as well with any guidance.
2021-04-11stabilize const_cttzAndreas Jonson-1/+32
2021-04-11Allow using `-C force-unwind-tables=no` when `panic=unwind`hyd-dev-11/+65
2021-04-11Add test to allow bad_asm_styleAmanieu d'Antras-12/+15
2021-04-11Auto merge of #82608 - Aaron1011:feature/final-preexp-tts, r=petrochenkovbors-713/+725
Implement token-based handling of attributes during expansion This PR modifies the macro expansion infrastructure to handle attributes in a fully token-based manner. As a result: * Derives macros no longer lose spans when their input is modified by eager cfg-expansion. This is accomplished by performing eager cfg-expansion on the token stream that we pass to the derive proc-macro * Inner attributes now preserve spans in all cases, including when we have multiple inner attributes in a row. This is accomplished through the following changes: * New structs `AttrAnnotatedTokenStream` and `AttrAnnotatedTokenTree` are introduced. These are very similar to a normal `TokenTree`, but they also track the position of attributes and attribute targets within the stream. They are built when we collect tokens during parsing. An `AttrAnnotatedTokenStream` is converted to a regular `TokenStream` when we invoke a macro. * Token capturing and `LazyTokenStream` are modified to work with `AttrAnnotatedTokenStream`. A new `ReplaceRange` type is introduced, which is created during the parsing of a nested AST node to make the 'outer' AST node aware of the attributes and attribute target stored deeper in the token stream. * When we need to perform eager cfg-expansion (either due to `#[derive]` or `#[cfg_eval]`), we tokenize and reparse our target, capturing additional information about the locations of `#[cfg]` and `#[cfg_attr]` attributes at any depth within the target. This is a performance optimization, allowing us to perform less work in the typical case where captured tokens never have eager cfg-expansion run.
2021-04-11Implement token-based handling of attributes during expansionAaron Hill-713/+725
This PR modifies the macro expansion infrastructure to handle attributes in a fully token-based manner. As a result: * Derives macros no longer lose spans when their input is modified by eager cfg-expansion. This is accomplished by performing eager cfg-expansion on the token stream that we pass to the derive proc-macro * Inner attributes now preserve spans in all cases, including when we have multiple inner attributes in a row. This is accomplished through the following changes: * New structs `AttrAnnotatedTokenStream` and `AttrAnnotatedTokenTree` are introduced. These are very similar to a normal `TokenTree`, but they also track the position of attributes and attribute targets within the stream. They are built when we collect tokens during parsing. An `AttrAnnotatedTokenStream` is converted to a regular `TokenStream` when we invoke a macro. * Token capturing and `LazyTokenStream` are modified to work with `AttrAnnotatedTokenStream`. A new `ReplaceRange` type is introduced, which is created during the parsing of a nested AST node to make the 'outer' AST node aware of the attributes and attribute target stored deeper in the token stream. * When we need to perform eager cfg-expansion (either due to `#[derive]` or `#[cfg_eval]`), we tokenize and reparse our target, capturing additional information about the locations of `#[cfg]` and `#[cfg_attr]` attributes at any depth within the target. This is a performance optimization, allowing us to perform less work in the typical case where captured tokens never have eager cfg-expansion run.
2021-04-11Auto merge of #83806 - JohnTitor:issue-51446, r=estebankbors-0/+34
Add a regression test for issue-51446 Closes #51446 r? `@estebank`
2021-04-10Preprocess intra-doc links consistentlyJoshua Nelson-1/+14
Previously, rustdoc would panic on links to external crates if they were surrounded by backticks.
2021-04-10Run rustfix for `bare-urls` testCamelid-18/+80
This will help us ensure that it emits valid suggestions.
2021-04-10Rename `url-improvements` test to `bare-urls`Camelid-18/+18
The lint used to be called `non-autolinks`, and linted more than just bare URLs. Now, it is called `bare-urls` and only lints against bare URLs. So, `bare-urls` is a better name for the test.
2021-04-10Auto merge of #84023 - Aaron1011:derive-invoc-order, r=petrochenkovbors-62/+103
Expand derive invocations in left-to-right order While derives were being collected in left-to-order order, the corresponding `Invocation`s were being pushed in the wrong order.
2021-04-10Expand derive invocations in left-to-right orderAaron Hill-62/+103
While derives were being collected in left-to-order order, the corresponding `Invocation`s were being pushed in the wrong order.
2021-04-10Auto merge of #84016 - Aaron1011:new-preexp-tests, r=petrochenkovbors-66/+1199
Add some proc-macro attribute token handling tests Split out from https://github.com/rust-lang/rust/pull/82608 r? `@petrochenkov`
2021-04-10Add some proc-macro attribute token handling testsAaron Hill-66/+1199
2021-04-10remove redundant testAliénore Bouttefeux-20/+12
2021-04-10add test offset of a fieldAliénore Bouttefeux-38/+52
2021-04-10Auto merge of #84024 - estebank:unclosed-brace-use, r=jackh726bors-3/+42
Avoid `;` -> `,` recovery and unclosed `}` recovery from being too verbose Those two recovery attempts have a very bad interaction that causes too unnecessary output. Add a simple gate to avoid interpreting a `;` as a `,` when there are unclosed braces. Fix #83498.
2021-04-09Avoid `;` -> `,` recovery and unclosed `}` recovery from being too verboseEsteban Küber-144/+18
Those two recovery attempts have a very bad interaction that causes too unnecessary output. Add a simple gate to avoid interpreting a `;` as a `,` when there are unclosed braces.
2021-04-09Auto merge of #81942 - the8472:reduce-ui-test-threads, r=Mark-Simulacrumbors-5/+16
reduce threads spawned by ui-tests The test harness already spawns enough tests to keep all cores busy. Individual tests should keep their own threading to a minimum to avoid context switch overhead. When running ui tests with lld enabled this shaves about 10% off that testsuite on my machine. Resolves #81946
2021-04-09changes based on reviewAliénore Bouttefeux-60/+30
2021-04-09Auto merge of #84030 - jyn514:no-blanket-impls, r=GuillaumeGomezbors-9/+9
rustdoc: Don't generate blanket impls when running --show-coverage `get_blanket_impls` is the slowest part of rustdoc, and the coverage pass completely ignores blanket impls. This stops running it at all, and also removes some unnecessary checks in `calculate_doc_coverage` that ignored the impl anyway. We don't currently measure --show-coverage in perf.rlo, but I tested this locally on cargo and it brought the time down from 2.9 to 1.6 seconds. This also adds back a commented-out test; Rustdoc has been able to deal with `impl trait` for almost a year now. r? `@GuillaumeGomez`
2021-04-09Add back missing trait testJoshua Nelson-9/+8
Rustdoc has been able to deal with `impl trait` for almost a year now.