about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-02-23./x.py test --blessTomasz Miąsko-6/+4
2023-02-23Emit diff instead of after mir in ElaborateDrops testsTomasz Miąsko-326/+347
to make it easy to understand chnages made by elaboration.
2023-02-23Rollup merge of #108349 - GuillaumeGomez:fix-duplicated-imports2, r=notriddleMatthias Krüger-0/+26
rustdoc: Prevent duplicated imports Fixes #108163. Interestingly enough, the AST is providing us an import for each corresponding item, even though the `Res` links to multiple ones each time, which leaded to the same import being duplicated. So in this PR, I decided to prevent the add of the import before the clean pass. However, I originally took a different path by instead filtering after cleaning the path. You can see it [here](https://github.com/rust-lang/rust/compare/master...GuillaumeGomez:rust:fix-duplicated-imports?expand=1). Only the second commit differs. I think this approach is better though, but at least we can compare both if we want. The first commit adds the check for duplicated items in the rustdoc-json output as asked in #108163. cc `@aDotInTheVoid` r? `@notriddle`
2023-02-23Rollup merge of #108208 - cjgillot:flood-enum, r=oli-obkMatthias Krüger-2/+102
Correctly handle aggregates in DataflowConstProp The previous implementation from https://github.com/rust-lang/rust/pull/107411 flooded target of an aggregate assignment with `Bottom`, corresponding to the `deinit` that the interpreter does. As a consequence, when assigning `target = Enum::Variant#i(...)` all the `(target as Variant#j)` were at `Bottom` while they should have been `Top`. This PR replaces that flooding with `Top`. Aside, it corrects a second bug where the wrong place would be used to assign to enum variant fields, resulting to nothing happening. Fixes https://github.com/rust-lang/rust/issues/108166
2023-02-23Rollup merge of #108063 - ↵Matthias Krüger-172/+136
compiler-errors:associated-type-bounds-in-bad-position, r=cjgillot Ban associated type bounds in bad positions We should not try to lower associated type bounds into TAITs in positions where `impl Trait` is not allowed (except for in `where` clauses, like `where T: Trait<Assoc: Bound>`). This is achieved by using the same `rustc_ast_lowering` machinery as impl-trait does to characterize positions as universal/existential/disallowed. Fixes #106077 Split out the first commit into #108066, since it's not really related.
2023-02-23Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, ↵bors-640/+662
r=compiler-errors,davidtwco,estebank,oli-obk diagnostics: if AssocFn has self argument, describe as method Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods. For anyone not sure why this is being done, see the Reference definitions of these terms in <https://doc.rust-lang.org/1.67.1/reference/items/associated-items.html#methods> > Associated functions whose first parameter is named `self` are called methods and may be invoked using the [method call operator](https://doc.rust-lang.org/1.67.1/reference/expressions/method-call-expr.html), for example, `x.foo()`, as well as the usual function call notation. In particular, while this means it's technically correct for rustc to refer to a method as an associated function (and there are a few cases where it'll still do so), rustc *must never* use the term "method" to refer to an associated function that does not have a `self` parameter.
2023-02-22pluralize stuffMichael Goulet-80/+80
2023-02-22Suppress duplicated errors for associated type bounds in object typesMichael Goulet-104/+10
2023-02-22Auto merge of #108357 - matthiaskrgr:rollup-ceo3q2s, r=matthiaskrgrbors-2/+75
Rollup of 6 pull requests Successful merges: - #107736 ( Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref #66893) ) - #108176 (Don't delay `ReError` bug during lexical region resolve) - #108315 (Lint dead code in closures and generators) - #108342 (apply query response: actually define opaque types) - #108344 (Fix test filename for #105700) - #108353 (resolve: Remove `ImportResolver`) Failed merges: - #107911 (Add check for invalid #[macro_export] arguments) r? `@ghost` `@rustbot` modify labels: rollup
2023-02-22Move associated type bounds check to ast loweringMichael Goulet-91/+149
This makes the check for when associated type bounds more accurate
2023-02-22Rollup merge of #108344 - Alexendoo:test-105700, r=compiler-errorsMatthias Krüger-2/+2
Fix test filename for #105700 The test is for #105700 rather than #21102
2023-02-22Rollup merge of #108315 - clubby789:dead-code-in-closure, r=compiler-errorsMatthias Krüger-0/+36
Lint dead code in closures and generators Fixes #108296 I think this might be a potentially breaking change, but restores the behaviour of pre-1.64. `@rustbot` label +A-lint
2023-02-22Rollup merge of #108176 - compiler-errors:bad-lexical-region-resolve-bug, ↵Matthias Krüger-0/+37
r=oli-obk Don't delay `ReError` bug during lexical region resolve Lexical region resolution returns a list of `RegionResolutionError` which don't necessarily correspond to diagnostics being emitted. The compiler may, validly, throw away these resolution errors and do something else. Therefore it's not valid to use `ReError` during lifetime resolution, since we may actually be on a totally fine compilation path. For example, the `implied_bounds_entailment` lint runs region resolution twice, and only emits an error if it fails both times. If we delay a bug and create a `ReError` during this first run, then we will ICE. Fixes #108170 ---- Side-note: this is conceptually equivalent to how we can't necessarily delay bugs or create `ty::Error` during trait solving/fulfillment, since the compiler is allowed to throw away these fulfillment errors to do other things. It's only once we actually emit an error (`report_region_errors` / `report_fulfillment_errors`)
2023-02-22Auto merge of #108340 - eggyal:remove_traversal_trait_aliases, r=oli-obkbors-1/+2
Remove type-traversal trait aliases #107924 moved the type traversal (folding and visiting) traits into the type library, but created trait aliases in `rustc_middle` to minimise both the API churn for trait consumers and the arising boilerplate. As mentioned in that PR, an alternative approach of defining subtraits with blanket implementations of the respective supertraits was also considered at that time but was ruled out as not adding much value. Unfortunately, it has since emerged that rust-analyzer has difficulty with these trait aliases at present, resulting in a degraded contributor experience (see the recent [r-a has become useless](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/r-a.20has.20become.20useless) topic on the #t-compiler/help Zulip stream). This PR removes the trait aliases, and accordingly the underlying type library traits are now used directly; they are parameterised by `TyCtxt<'tcx>` rather than just the `'tcx` lifetime, and imports have been updated to reflect the fact that the trait aliases' explicitly named traits are no longer automatically brought into scope. These changes also roll-back the (no-longer required) workarounds to #107747 that were made in b409329c624b9e3bbd7d8e07697e2e9f861a45b6. Since this PR is just a find+replace together with the changes necessary for compilation & tidy to pass, it's currently just one mega-commit. Let me know if you'd like it broken up. r? `@oli-obk`
2023-02-22Normalize line+col in normalize-tait-in-const testAlan Egerton-1/+2
2023-02-22Remove type-traversal trait aliasesAlan Egerton-1/+1
2023-02-22Add test to ensure there are no duplicated importsGuillaume Gomez-0/+26
2023-02-22rustdoc: update test case with intra-doc link pointing to methodMichael Howell-4/+12
2023-02-22diagnostics: update test cases to refer to assoc fn with `self` as methodMichael Howell-636/+650
2023-02-22Lint dead code in closuresclubby789-0/+36
2023-02-22Auto merge of #103042 - davidtwco:translation-distributed-ftl, r=oli-obkbors-651/+648
errors: generate typed identifiers in each crate Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. There are advantages and disadvantages to this change.. #### Advantages - Changing a diagnostic now only recompiles the crate for that diagnostic and those crates that depend on it, rather than `rustc_error_messages` and all crates thereafter. - This approach can be used to support first-party crates that want to supply translatable diagnostics (e.g. `rust-lang/thorin` in https://github.com/rust-lang/rust/pull/102612#discussion_r985372582, cc `@JhonnyBillM)` - We can extend this a little so that tools built using rustc internals (like clippy or rustdoc) can add their own diagnostic resources (much more easily than those resources needing to be available to `rustc_error_messages`) #### Disadvantages - Crates can only refer to the diagnostic messages defined in the current crate (or those from dependencies), rather than all diagnostic messages. - `rustc_driver` (or some other crate we create for this purpose) has to directly depend on *everything* that has error messages. - It already transitively depended on all these crates. #### Pending work - [x] I don't know how to make `rustc_codegen_gcc`'s translated diagnostics work with this approach - because `rustc_driver` can't depend on that crate and so can't get its resources to provide to the diagnostic emission. I don't really know how the alternative codegen backends are actually wired up to the compiler at all. - [x] Update `triagebot.toml` to track the moved FTL files. r? `@compiler-errors` cc #100717
2023-02-22Fix test filename for #105700Alex Macleod-2/+2
2023-02-22Rollup merge of #108310 - ↵Guillaume Gomez-0/+25
GuillaumeGomez:fix-reexports-duplicated-attributes, r=notriddle rustdoc: Fix duplicated attributes for first reexport Fixes #108281. r? ``@notriddle``
2023-02-22Rollup merge of #108246 - saethlin:instcombine-redundant-casts, ↵Guillaume Gomez-0/+71
r=compiler-errors Add an InstCombine for redundant casts `@rustbot` label +A-mir-opt
2023-02-22Rollup merge of #108239 - clubby789:overlapping-spans, r=compiler-errorsGuillaume Gomez-26/+66
Fix overlapping spans in removing extra arguments Fixes #108225 Each span is already extended to include the previous comma, so extending to the *next* comma is unecessary and causes an ICE with assertions on. ``@rustbot`` label +A-diagnostics
2023-02-22Rollup merge of #108230 - LittleFall:enhance/warning, r=estebankGuillaume Gomez-99/+72
Convert a hard-warning about named static lifetimes into lint "unused_lifetimes" Fixes https://github.com/rust-lang/rust/issues/96956. Some changes are ported from https://github.com/rust-lang/rust/pull/98079, thanks to jeremydavis519. r? `@estebank` `@petrochenkov` Any feedback is appreciated! ## Actions - [x] resolve conflicts - [x] fix build - [x] address review comments in last pr - [x] update tests
2023-02-22Rollup merge of #108168 - clubby789:recursive-type-alias, r=compiler-errorsGuillaume Gomez-0/+25
Fix ICE on type alias in recursion Fixes #108160
2023-02-22various: translation resources from cg backendDavid Wood-6/+7
Extend `CodegenBackend` trait with a function returning the translation resources from the codegen backend, which can be added to the complete list of resources provided to the emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22errors: fix translation's run-make testDavid Wood-7/+11
`run-make/translation` had some targets that weren't listed in `all` and thus weren't being tested - the behaviour that should have been being tested was basically correct fortunately. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22errors: generate typed identifiers in each crateDavid Wood-644/+636
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22Convert a hard-warning about named static lifetimes into lint "unused_lifetimes"Zhi Qi-99/+72
Define the `named_static_lifetimes` lint This lint will replace the existing hard-warning. Replace the named static lifetime hard-warning with the new lint Update the UI tests for the `named_static_lifetimes` lint Remove the direct dependency on `rustc_lint_defs` fix build Signed-off-by: Zhi Qi <qizhi@pingcap.com> use "UNUSED_LIFETIMES" instead Signed-off-by: Zhi Qi <qizhi@pingcap.com> update 1 test and fix typo Signed-off-by: Zhi Qi <qizhi@pingcap.com> update tests Signed-off-by: Zhi Qi <qizhi@pingcap.com> fix tests: add extra blank line Signed-off-by: Zhi Qi <qizhi@pingcap.com>
2023-02-21Rollup merge of #108295 - compiler-errors:wtf-is-this, r=cjgillotMatthias Krüger-186/+186
Use DefKind to give more item kind information during BindingObligation note The current label says "required by a bound in this". When I see that label, my immediate impression is "this... **what**?". It feels like it was cut short. Alternative to this would be saying "in this item", but adding the item kind is strictly more informational and adds very little overhead to the existing error presentation.
2023-02-21Rollup merge of #108202 - ↵Matthias Krüger-0/+25
compiler-errors:non_lifetime_binders-type-match-ice, r=davidtwco Make sure `test_type_match` doesn't ICE with late-bound types Fixes #108190 (in a kind of hacky way, anyways doesn't really matter)
2023-02-21Auto merge of #108311 - oli-obk:invert_defines, r=lcnrbors-0/+14
Make hidden type registration opt-in, so that each site can be reviewed on its own and we have the right defaults for trait solvers r? `@lcnr` pulled out of https://github.com/rust-lang/rust/pull/107891 as it is the uncontroversial part
2023-02-21Add regression test for #108281Guillaume Gomez-0/+25
2023-02-21Make hidden type registration opt-in, so that each site can be reviewed on ↵Oli Scherer-0/+14
its own and we have the right defaults for trait solvers
2023-02-21Fix overlapping spans in removing extra argumentsclubby789-26/+66
2023-02-21Auto merge of #108138 - compiler-errors:malformed-fn-trait, r=TaKO8Kibors-21/+202
Move `Fn*` traits malformedness protections to typeck I found it strange that we were doing a custom well-formedness check just for the `Fn*` traits' `call_*` fn items. My understanding from the git history is that this is just to avoid ICEs later on in typeck. Well, that well-formedness check isn't even implemented correctly for `FnOnce::call_once`, or `FnMut::call_mut` for that matter. Instead, this PR just makes the typeck checks more robust, and leaves it up to the call-site to report errors when lang items are implemented in funny ways. This coincidentally fixes another ICE where a the `Add` lang item is implemented with a `add` item that's a const instead of a method.
2023-02-21Auto merge of #108301 - Dylan-DPC:rollup-70zpkt0, r=Dylan-DPCbors-233/+223
Rollup of 7 pull requests Successful merges: - #108000 (lint: don't suggest MaybeUninit::assume_init for uninhabited types) - #108105 (Explain the default panic hook better) - #108141 (Add rpitit queries) - #108272 (docs: wrong naming convention in struct keyword doc) - #108285 (remove unstable `pick_stable_methods_before_any_unstable` flag) - #108289 (Name placeholder in some region errors) - #108290 (Add a test for default trait method with RPITITs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-21Rollup merge of #108290 - compiler-errors:rpitit-trait-default-constraint, ↵Dylan DPC-0/+28
r=oli-obk Add a test for default trait method with RPITITs This didn't work in #107013, but now that #108203 has landed, let's make sure we don't regress it. r? types
2023-02-21Rollup merge of #108289 - compiler-errors:name-placeholder, r=petrochenkovDylan DPC-0/+5
Name placeholder in some region errors Also don't print `ReVar` or `ReLateBound` as debug... these error messages are super uncommon anyways, but in the case they do trigger, let's be slightly more helpful.
2023-02-21Rollup merge of #108285 - BoxyUwU:remove_pick_stable_before_unstable_flag, ↵Dylan DPC-177/+176
r=oli-obk remove unstable `pick_stable_methods_before_any_unstable` flag This flag was only added in #90329 in case there was any issue with the impl so that it would be easy to tell nightly users to use the flag to disable the new logic to fix their code. It's now been enabled for two years and also I can't find any issues corresponding to this new functionality? This flag made it way harder to understand how this code works so it would be nice to remove it and simplify what's going on. cc `@nbdd0121` r? `@oli-obk`
2023-02-21Rollup merge of #108000 - y21:no-zero-init-for-uninhabited, r=jackh726Dylan DPC-56/+14
lint: don't suggest MaybeUninit::assume_init for uninhabited types Creating a zeroed uninhabited type such as `!` or an empty enum with `mem::zeroed()` (or transmuting `()` to `!`) currently triggers this lint: ```rs warning: the type `!` does not permit zero-initialization --> test.rs:5:23 | 5 | let _val: ! = mem::zeroed(); | ^^^^^^^^^^^^^ | | | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | = note: the `!` type has no valid value ``` The `MaybeUninit` suggestion in the help message seems confusing/useless for uninhabited types, as such a type cannot be fully initialized in the first place (as the note implies). This PR limits this help message to inhabited types which can be initialized
2023-02-21Auto merge of #104754 - nnethercote:more-ThinVec-in-ast, r=the8472bors-111/+111
Use `ThinVec` more in the AST r? `@ghost`
2023-02-21Specify what 'this' actually isMichael Goulet-186/+186
2023-02-21Auto merge of #107728 - RalfJung:miri-dyn-star, r=RalfJung,oli-obkbors-9/+17
Miri: basic dyn* support As usual I am very unsure about the dynamic dispatch stuff, but it passes even the `Pin<&mut dyn* Trait>` test so that is something. TBH I think it was a mistake to make `dyn Trait` and `dyn* Trait` part of the same `TyKind` variant. Almost everywhere in Miri this lead to the wrong default behavior, resulting in strange ICEs instead of nice "unimplemented" messages. The two types describe pretty different runtime data layout after all. Strangely I did not need to do the equivalent of [this diff](https://github.com/rust-lang/rust/pull/106532#discussion_r1087095963) in Miri. Maybe that is because the unsizing logic matches on `ty::Dynamic(.., ty::Dyn)` already? In `unsized_info` I don't think the `target_dyn_kind` can be `DynStar`, since then it wouldn't be unsized! r? `@oli-obk` Cc `@eholk` (dyn-star) https://github.com/rust-lang/rust/issues/102425
2023-02-21Add a test for default trait method with RPITITsMichael Goulet-0/+28
2023-02-21Auto merge of #105462 - oli-obk:feeding_full, r=cjgillot,petrochenkovbors-22/+21
give the resolver access to TyCtxt The resolver is now created after TyCtxt is created. Then macro expansion and name resolution are run and the results fed into queries just like before this PR. Since the resolver had (before this PR) mutable access to the `CStore` and the source span table, these two datastructures are now behind a `RwLock`. To ensure that these are not mutated anymore after the resolver is done, a read lock to them is leaked right after the resolver finishes. ### PRs split out of this one and leading up to it: * https://github.com/rust-lang/rust/pull/105423 * https://github.com/rust-lang/rust/pull/105357 * https://github.com/rust-lang/rust/pull/105603 * https://github.com/rust-lang/rust/pull/106776 * https://github.com/rust-lang/rust/pull/106810 * https://github.com/rust-lang/rust/pull/106812 * https://github.com/rust-lang/rust/pull/108032
2023-02-21Fix a test.Nicholas Nethercote-3/+3
2023-02-21Use `ThinVec` in a few more AST types.Nicholas Nethercote-44/+44