about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2022-05-30Auto merge of #96964 - oli-obk:const_trait_mvp, r=compiler-errorsbors-142/+34
Replace `#[default_method_body_is_const]` with `#[const_trait]` pulled out of #96077 related issues: #67792 and #92158 cc `@fee1-dead` This is groundwork to only allowing `impl const Trait` for traits that are marked with `#[const_trait]`. This is necessary to prevent adding a new default method from becoming a breaking change (as it could be a non-const fn).
2022-05-30Remove `#[default..]` and add `#[const_trait]`Deadbeef-142/+34
2022-05-30Auto merge of #97489 - GuillaumeGomez:settings-js-disabled, r=notriddlebors-0/+6
Add sentence in case JS is disabled on settings.html page Instead of having an empty page, it'll look like this: ![Screenshot from 2022-05-28 17-46-23](https://user-images.githubusercontent.com/3050060/170833333-e1a59c2b-27ca-47da-9c08-2356e4a689cb.png) r? `@notriddle`
2022-05-29Rollup merge of #97493 - compiler-errors:issue-97490, r=oli-obkMichael Goulet-0/+12
Use `type_is_copy_modulo_regions` check in intrisicck This one canoncalizes region variables correctly, preventing an ICE Fixes #97490
2022-05-29Use type_is_copy_modulo_regions check in intrisicckMichael Goulet-0/+12
2022-05-29Auto merge of #94214 - nikic:rust-opaque-pointers, r=cuviperbors-285/+252
Prepare Rust for opaque pointers Fix one codegen bug with opaque pointers, and update our IR tests to accept both typed pointer and opaque pointer IR. This is a bit annoying, but unavoidable if we want decent test coverage on both LLVM 14 and LLVM 15. This prepares Rust for when LLVM will enable opaque pointers by default.
2022-05-29Auto merge of #97456 - Bryysen:issue-97319-fix, r=compiler-errorsbors-60/+139
Improve error message for E0081 Closes #97319
2022-05-29Auto merge of #97287 - compiler-errors:type-interner, r=jackh726,oli-obkbors-88/+120
Move things to `rustc_type_ir` Finishes some work proposed in https://github.com/rust-lang/compiler-team/issues/341. r? `@ghost`
2022-05-29Auto merge of #96652 - notriddle:notriddle/self, r=GuillaumeGomezbors-0/+92
rustdoc: include impl generics / self in search index Fixes #92205
2022-05-29Rollup merge of #97479 - JohnTitor:make-check-pass, r=compiler-errorsGuillaume Gomez-13/+11
Make some tests check-pass This touches the tests related to lint, parser, and importing, all of them should be fine with `check-pass`. r? ``@compiler-errors``
2022-05-29Rollup merge of #97028 - ridwanabdillahi:pretty-printer, r=michaelwoeristerGuillaume Gomez-81/+242
Add support for embedding pretty printers via `#[debugger_visualizer]` attribute Initial support for [RFC 3191](https://github.com/rust-lang/rfcs/pull/3191) in PR https://github.com/rust-lang/rust/pull/91779 was scoped to supporting embedding NatVis files using a new attribute. This PR implements the pretty printer support as stated in the RFC mentioned above. This change includes embedding pretty printers in the `.debug_gdb_scripts` just as the pretty printers for rustc are embedded today. Also added additional tests for embedded pretty printers. Additionally cleaned up error checking so all error checking is done up front regardless of the current target. RFC: https://github.com/rust-lang/rfcs/pull/3191
2022-05-29Rollup merge of #96950 - JohnTitor:issue-96395, r=compiler-errors,oli-obkGuillaume Gomez-0/+3
Add regression test for #96395 Closes #96395 This repeats "fixed" and "ICE", see https://github.com/rust-lang/glacier/pull/1243#issuecomment-1123768138 I think it's good to add a test before regressing again. r? ``@compiler-errors`` for quick reviiew cc ``@oli-obk`` you might want to check as you're familiar with MIR
2022-05-28Improve error message for E0081Bryysen-60/+139
Previously whenever a duplicate discriminant was detected for an Enum, we would print the discriminant bits in the diagnostic without any casting. This caused us to display incorrect values for negative discriminants. After this PR we format the discriminant signedness correctly. Also reworded some of the original error messages.
2022-05-28Fix TyKind lint, make consts no longer fn, etcMichael Goulet-88/+120
2022-05-28Add GUI test for javascript disabled display of settings pageGuillaume Gomez-0/+6
2022-05-28Auto merge of #97461 - eddyb:proc-macro-less-payload, r=bjorn3bors-9/+12
proc_macro: don't pass a client-side function pointer through the server. Before this PR, `proc_macro::bridge::Client<F>` contained both: * the C ABI entry-point `run`, that the server can call to start the client * some "payload" `f: F` passed to that entry-point * in practice, this was always a (client-side Rust ABI) `fn` pointer to the actual function the proc macro author wrote, i.e. `#[proc_macro] fn foo(input: TokenStream) -> TokenStream` In other words, the client was passing one of its (Rust) `fn` pointers to the server, which was passing it back to the client, for the client to call (see later below for why that was ever needed). I was inspired by `@nnethercote's` attempt to remove the `get_handle_counters` field from `Client` (see https://github.com/rust-lang/rust/pull/97004#issuecomment-1139273301), which combined with removing the `f` ("payload") field, could theoretically allow for a `#[repr(transparent)]` `Client` that mostly just newtypes the C ABI entry-point `fn` pointer <sub>(and in the context of e.g. wasm isolation, that's *all* you want, since you can reason about it from outside the wasm VM, as just a 32-bit "function table index", that you can pass to the wasm VM to call that function)</sub>. <hr/> So this PR removes that "payload". But it's not a simple refactor: the reason the field existed in the first place is because monomorphizing over a function type doesn't let you call the function without having a value of that type, because function types don't implement anything like `Default`, i.e.: ```rust extern "C" fn ffi_wrapper<A, R, F: Fn(A) -> R>(arg: A) -> R { let f: F = ???; // no way to get a value of `F` f(arg) } ``` That could be solved with something like this, if it was allowed: ```rust extern "C" fn ffi_wrapper< A, R, F: Fn(A) -> R, const f: F // not allowed because the type is a generic param >(arg: A) -> R { f(arg) } ``` Instead, this PR contains a workaround in `proc_macro::bridge::selfless_reify` (see its module-level comment for more details) that can provide something similar to the `ffi_wrapper` example above, but limited to `F` being `Copy` and ZST (and requiring an `F` value to prove the caller actually can create values of `F` and it's not uninhabited or some other unsound situation). <hr/> Hopefully this time we don't have a performance regression, and this has a chance to land. cc `@mystor` `@bjorn3`
2022-05-28Auto merge of #97158 - JakobDegen:dse, r=tmiasko,cjgillotbors-341/+403
Split dead store elimination off dest prop This splits off a part of #96451 . I've added this in as its own pass for now, so that it actually runs, can be tested, etc. In the dest prop PR, I'll stop invoking this as its own pass, so that it doesn't get invoked twice. r? `@tmiasko`
2022-05-28Make some tests check-passYuki Okushi-13/+11
2022-05-28Rollup merge of #97327 - ↵Dylan DPC-0/+109
davidtwco:diagnostic-translation-compile-time-validation, r=oli-obk macros: introduce `fluent_messages` macro Adds a new `fluent_messages` macro which performs compile-time validation of the compiler's Fluent resources (i.e. that the resources parse and don't multiply define the same messages) and generates constants that make using those messages in diagnostics more ergonomic. For example, given the following invocation of the macro.. ```rust fluent_messages! { typeck => "./typeck.ftl", } ``` ..where `typeck.ftl` has the following contents.. ```fluent typeck-field-multiply-specified-in-initializer = field `{$ident}` specified more than once .label = used more than once .label-previous-use = first use of `{$ident}` ``` ...then the macro parse the Fluent resource, emitting a diagnostic if it fails to do so... ```text error: could not parse Fluent resource --> $DIR/test.rs:35:28 | LL | missing_message => "./missing-message.ftl", | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: see additional errors emitted error: expected a message field for "missing-message" --> ./missing-message.ftl:1:1 | 1 | missing-message = | ^^^^^^^^^^^^^^^^^^ | ``` ...or generating the following code if it succeeds: ```rust pub static DEFAULT_LOCALE_RESOURCES: &'static [&'static str] = &[ include_str!("./typeck.ftl"), ]; mod fluent_generated { mod typeck { pub const field_multiply_specified_in_initializer: DiagnosticMessage = DiagnosticMessage::fluent("typeck-field-multiply-specified-in-initializer"); pub const field_multiply_specified_in_initializer_label_previous_use: DiagnosticMessage = DiagnosticMessage::fluent_attr( "typeck-field-multiply-specified-in-initializer", "previous-use-label" ); } } ``` When emitting a diagnostic, the generated constants can be used as follows: ```rust let mut err = sess.struct_span_err( span, fluent::typeck::field_multiply_specified_in_initializer ); err.span_label( span, fluent::typeck::field_multiply_specified_in_initializer_label ); err.span_label( previous_use_span, fluent::typeck::field_multiply_specified_in_initializer_label_previous_use ); err.emit(); ``` I'd like to reduce the verbosity of referring to labels/notes/helps with this scheme (though it wasn't much better before), but I'll leave that for a follow-up. r? `@oli-obk` cc `@pvdrz` `@compiler-errors`
2022-05-28Auto merge of #97284 - b-naber:constraint-dyn-impl-suggestion, r=estebankbors-31/+82
Add suggestion for relaxing static lifetime bounds on dyn trait impls in NLL This PR introduces suggestions for relaxing static lifetime bounds on impls of dyn trait items for NLL similar to what is already available in lexical region diagnostics. Fixes https://github.com/rust-lang/rust/issues/95701 r? `@estebank`
2022-05-27Switch incremental/hashes tests to all use optimizations.Jakob Degen-39/+39
2022-05-28Rollup merge of #97458 - estebank:use-self-in-derive-macro, r=compiler-errorsMatthias Krüger-0/+21
Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant error Reduce verbosity in #97343.
2022-05-27proc_macro: don't pass a client-side function pointer through the server.Eduard-Mihai Burtescu-9/+12
2022-05-27Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant errorEsteban Küber-12/+3
#97343
2022-05-27Add test for #97343Esteban Küber-0/+30
2022-05-28Add regression test for #81899Yuki Okushi-0/+30
2022-05-27Auto merge of #96046 - oli-obk:const_typeck, r=cjgillotbors-397/+759
Move various checks to typeck so them failing causes the typeck result to get tainted Fixes #69487 fixes #79047 cc `@RalfJung` this gets rid of the `Transmute` invalid program error variant
2022-05-27Update tests on aarch64Oli Scherer-127/+183
2022-05-27Auto merge of #97442 - hafeoz:master, r=GuillaumeGomezbors-0/+17
Fix multiline attributes processing in doctest Fixes #97440. It seems like the call to `check_if_attr_is_complete` is not provided with the correct argument: the pending attribute should be passed, while the current line is actually being passed. This causes any attribute with more than 2 lines to fail and produces ICE when running through doctest.
2022-05-27libcore: Add `iter::from_generator` which is like `iter::from_fn`, but for ↵Vadim Petrochenkov-7/+7
coroutines instead of functions
2022-05-26Remove few characters for tidy check to passhafeoz-1/+1
2022-05-26Add testshafeoz-0/+17
2022-05-26Rollup merge of #97317 - GuillaumeGomez:gui-settings-text-click, r=jshaGuillaume Gomez-2/+8
Allow to click on setting text You can test it [here](https://rustdoc.crud.net/imperio/gui-settings-text-click/doc/foo/index.html). This PR allows to click on the text alongside the toggle to change it. r? `@jsha`
2022-05-25Adjust test case to account for 6c8a2d4Michael Howell-2/+2
2022-05-25rustdoc: include impl generics / self in search indexMichael Howell-0/+92
2022-05-25Auto merge of #97401 - Dylan-DPC:rollup-fh9e61o, r=Dylan-DPCbors-7/+109
Rollup of 5 pull requests Successful merges: - #97302 (Do writeback of Closure params before visiting the parent expression) - #97328 (rustc: Fix ICE in native library error reporting) - #97351 (Output correct type responsible for structural match violation) - #97398 (Add regression test for #82830) - #97400 (Fix a typo on Struct `Substructure`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-05-25bless existing test with compare-mode=nll and remove testb-naber-237/+66
2022-05-25update testsb-naber-15/+237
2022-05-25Rollup merge of #97398 - JohnTitor:issue-82830, r=compiler-errorsDylan DPC-0/+31
Add regression test for #82830 Closes #82830 r? `@compiler-errors`
2022-05-25Rollup merge of #97351 - ↵Dylan DPC-2/+25
b-naber:adt-const-params-structural-match-violation, r=michaelwoerister Output correct type responsible for structural match violation Previously we included the outermost type that caused a structural match violation in the error message and stated that that type must be annotated with `#[derive(Eq, PartialEq)]` even if it already had that annotation. This PR outputs the correct type in the error message. Fixes https://github.com/rust-lang/rust/issues/97278
2022-05-25Rollup merge of #97328 - petrochenkov:nativice, r=michaelwoeristerDylan DPC-0/+11
rustc: Fix ICE in native library error reporting Fixes https://github.com/rust-lang/rust/issues/97299
2022-05-25Rollup merge of #97302 - compiler-errors:writeback-ascending, r=cjgillotDylan DPC-5/+42
Do writeback of Closure params before visiting the parent expression This means that given the expression: ``` let x = |a: Vec<_>| {}; ``` We will visit the HIR node for `a` before `x`, and report the ambiguity on the former instead of the latter. This also moves writeback for struct field ids and const blocks before, but the ordering of this and walking the expr doesn't seem to matter.
2022-05-25Update some codegen tests for opaque pointersNikita Popov-284/+251
2022-05-25Fix stack protector basic testNikita Popov-1/+1
This is a >= condition, so we need a maximum size of 7 to not create a stack protector in basic mode. The reason this still worked is that the alloca type was converted into an integer (rather than an array). The way these heuristics are implemented in LLVM is rather questionable and not resilient to optimization.
2022-05-25Auto merge of #94954 - SimonSapin:null-thin3, r=yaahcbors-1/+1
Extend ptr::null and null_mut to all thin (including extern) types Fixes https://github.com/rust-lang/rust/issues/93959 This change was accepted in https://rust-lang.github.io/rfcs/2580-ptr-meta.html Note that this changes the signature of **stable** functions. The change should be backward-compatible, but it is **insta-stable** since it cannot (easily, at all?) be made available only through a `#![feature(…)]` opt-in. The RFC also proposed the same change for `NonNull::dangling`, which makes sense it terms of its signature but not in terms of its implementation. `dangling` uses `align_of()` as an address. But what `align_of()` should be for extern types or whether it should be allowed at all remains an open question. This commit depends on https://github.com/rust-lang/rust/pull/93977, which is not yet part of the bootstrap compiler. So `#[cfg]` is used to only apply the change in stage 1+. As far a I know bounds cannot be made conditional with `#[cfg]`, so the entire functions are duplicated. This is unfortunate but temporary. Since this duplication makes it less obvious in the diff, the new definitions differ in: * More permissive bounds (`Thin` instead of implied `Sized`) * Different implementation * Having `rustc_allow_const_fn_unstable(const_fn_trait_bound)` * Having `rustc_allow_const_fn_unstable(ptr_metadata)`
2022-05-25Add regression test for #82830Yuki Okushi-0/+31
2022-05-25Rollup merge of #97370 - compiler-errors:else-no-if-2, r=Dylan-DPCDylan DPC-10/+2
Minor improvement on else-no-if diagnostic Don't suggest wrapping in block since it's highly likely to be a missing `if` after `else`. Also rework message a bit (open to further suggestions). cc: https://github.com/rust-lang/rust/pull/97298#discussion_r880933431 r? `@estebank`
2022-05-25Rollup merge of #96913 - Urgau:rfc3239-part2, r=petrochenkovDylan DPC-0/+152
RFC3239: Implement `cfg(target)` - Part 2 This pull-request implements the compact `cfg(target(..))` part of [RFC 3239](https://github.com/rust-lang/rust/issues/96901). I recommend reviewing this PR on a per commit basics, because of some moving parts. cc `@GuillaumeGomez` r? `@petrochenkov`
2022-05-25Rollup merge of #95953 - JakobDegen:repeat-leak, r=oli-obkDylan DPC-0/+164
Modify MIR building to drop repeat expressions with length zero Closes #74836 . Previously, when a user wrote `[foo; 0]` we used to simply leak `foo`. The goal is to fix that. This PR changes MIR building to make `[foo; 0]` equivalent to `{ drop(foo); [] }` in all cases. Of course, this is a breaking change (see below). A crater run did not indicate any regressions though, and given that the previous behavior was almost definitely not what any user wanted, it seems unlikely that anyone was relying on this. Note that const generics are in general unaffected by this. Inserting the extra `drop` is only meaningful/necessary when `foo` is of a non-`Copy` type, and array repeat expressions with const generic repetition count must always be `Copy`. Besides the obvious change to behavior associated with the additional drop, there are three categories of examples where this also changes observable behavior. In all of these cases, the new behavior is consistent with what you would get by replacing `[foo; 0]` with `{ drop(foo); [] }`. As such, none of these give the user new powers to express more things. **No longer allowed in const (breaking)**: ```rust const _: [String; 0] = [String::new(); 0]; ``` This compiles on stable today. Because we now introduce the drop of `String`, this no longer compiles as `String` may not be dropped in a const context. **Reduced dataflow (non-breaking)**: ```rust let mut x: i32 = 0; let r = &x; let a = [r; 0]; x = 5; let _b = a; ``` Borrowck rejects this code on stable because it believes there is dataflow between `a` and `r`, and so the lifetime of `r` has to extend to the last statement. This change removes the dataflow and the above code is allowed to compile. **More const promotion (non-breaking)**: ```rust let _v: &'static [String; 0] = &[String::new(); 0]; ``` This does not compile today because `String` having drop glue keeps it from being const promoted (despite that drop glue never being executed). After this change, this is allowed to compile. ### Alternatives A previous attempt at this tried to reduce breakage by various tricks. This is still a possibility, but given that crater showed no regressions it seems unclear why we would want to introduce this complexity. Disallowing `[foo; 0]` completely is also an option, but obviously this is more of a breaking change. I do not know how often this is actually used though. r? `@oli-obk`
2022-05-25Rollup merge of #97323 - 5225225:strict_init_checks, r=oli-obkDylan DPC-6/+38
Introduce stricter checks for might_permit_raw_init under a debug flag This is intended to be a version of the strict checks tried out in #79296, but also checking number validity (under the assumption that `let _ = std::mem::uninitialized::<u32>()` is UB, which seems to be what https://github.com/rust-lang/unsafe-code-guidelines/issues/71 is leaning towards.)