about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src
AgeCommit message (Collapse)AuthorLines
2022-03-05Change syntax for TyAlias where clausesJack Huey-0/+5
2022-03-04Downgrade `#[test]` on macro call to warningEsteban Kuber-8/+12
Follow up to #92959. Address #94508.
2022-03-03Adjusted diagnostic output so that if there is no `use` in a item sequence,Felix S. Klock II-3/+2
then we just suggest the first legal position where you could inject a use. To do this, I added `inject_use_span` field to `ModSpans`, and populate it in parser (it is the span of the first token found after inner attributes, if any). Then I rewrote the use-suggestion code to utilize it, and threw out some stuff that is now unnecessary with this in place. (I think the result is easier to understand.) Then I added a test of issue 87613.
2022-03-03Associate multiple with a crate too.Felix S. Klock II-1/+1
2022-03-03refactor: prepare to associate multiple spans with a module.Felix S. Klock II-1/+3
2022-03-03Rollup merge of #94433 - Urgau:check-cfg-allowness, r=petrochenkovDylan DPC-4/+16
Improve allowness of the unexpected_cfgs lint This pull-request improve the allowness (`#[allow(...)]`) of the `unexpected_cfgs` lint. Before this PR only crate level `#![allow(unexpected_cfgs)]` worked, now with this PR it also work when put around `cfg!` or if it is in a upper level. Making it work ~for the attributes `cfg`, `cfg_attr`, ...~ for the same level is awkward as the current code is design to give "Some parent node that is close to this macro call" (cf. https://doc.rust-lang.org/nightly/nightly-rustc/rustc_expand/base/struct.ExpansionData.html) meaning that allow on the same line as an attribute won't work. I'm note even sure if this would be possible. Found while working on https://github.com/rust-lang/rust/pull/94298. r? ````````@petrochenkov````````
2022-03-01Improve allowness of the unexpected_cfgs lintLoïc BRANSTETT-4/+16
2022-03-01compiler: fix some typoscuishuang-1/+1
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1
2022-02-25Rollup merge of #92714 - yanganto:ignore-message, r=Mark-SimulacrumMatthias Krüger-0/+23
Provide ignore message in the result of test Provide ignore the message in the result of the test. This PR does not need RFC, because it is about the presentation of the report of `cargo test`. However, the following document listed here helps you to know about PR. - [RFC](https://github.com/rust-lang/rfcs/pull/3217) - [Rendered](https://github.com/yanganto/rfcs/blob/ignore-test-message/text/0000-ignore-test-message.md) - [Previous discussion on IRLO](https://internals.rust-lang.org/t/pre-rfc-provide-ignore-message-when-the-test-ignored/15904) If there is something improper, please let me know. Thanks.
2022-02-24Include ignore message in libtest outputAntonio Yang-0/+23
As an example: #[test] #[ignore = "not yet implemented"] fn test_ignored() { ... } Will now render as: running 2 tests test tests::test_ignored ... ignored, not yet implemented test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-25/+18
2022-02-20Rollup merge of #94146 - est31:let_else, r=cjgillotMatthias Krüger-63/+42
Adopt let else in more places Continuation of #89933, #91018, #91481, #93046, #93590, #94011. I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This is the biggest of these PRs and handles the changes outside of rustdoc, rustc_typeck, rustc_const_eval, rustc_trait_selection, which were handled in PRs #94139, #94142, #94143, #94144.
2022-02-19Adopt let else in more placesest31-63/+42
2022-02-18Rollup merge of #92959 - asquared31415:test-non-fn-help, r=estebankMatthias Krüger-6/+16
Add more info and suggestions to use of #[test] on invalid items This pr changes the diagnostics for using `#[test]` on an item that can't be used as a test to explain that the attribute has no meaningful effect on non-functions and suggests the use of `#[cfg(test)]` for conditional compilation instead. Example change: ```rs #[test] mod test {} ``` previously output ``` error: only functions may be used as tests --> src/lib.rs:2:1 | 2 | mod test {} | ^^^^^^^^^^^ ``` now outputs ``` error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/test-on-not-fn.rs:3:1 | LL | #[test] | ^^^^^^^ LL | mod test {} | ----------- expected a non-associated function, found a module | = note: the `#[test]` macro causes a a function to be run on a test and has no effect on non-functions help: replace with conditional compilation to make the item only exist when tests are being run | LL | #[cfg(test)] | ~~~~~~~~~~~~ ```
2022-02-18Rollup merge of #92933 - bjorn3:no_bin_lib_mixing, r=estebankMatthias Krüger-5/+0
Deny mixing bin crate type with lib crate types The produced library would get a main shim too which conflicts with the main shim of the executable linking the library. ``` $ cat > main1.rs <<EOF fn main() {} pub fn bar() {} EOF $ cat > main2.rs <<EOF extern crate main1; fn main() { main1::bar(); } EOF $ rustc --crate-type bin --crate-type lib main1.rs $ rustc -L. main2.rs error: linking with `cc` failed: exit status: 1 [...] = note: /usr/bin/ld: /tmp/crate_bin_lib/libmain1.rlib(main1.main1.707747aa-cgu.0.rcgu.o): in function `main': main1.707747aa-cgu.0:(.text.main+0x0): multiple definition of `main'; main2.main2.02a148fe-cgu.0.rcgu.o:main2.02a148fe-cgu.0:(.text.main+0x0): first defined here collect2: error: ld returned 1 exit status ```
2022-02-17Rollup merge of #94011 - est31:let_else, r=lcnrMatthias Krüger-3/+2
Even more let_else adoptions Continuation of #89933, #91018, #91481, #93046, #93590.
2022-02-17Rollup merge of #94030 - ChayimFriedman2:issue-94010, r=petrochenkovMatthias Krüger-15/+15
Correctly mark the span of captured arguments in `format_args!()` It should not include the braces, or misspelling suggestions will be wrong. Fixes #94010.
2022-02-16Adopt let_else in even more placesest31-3/+2
2022-02-16Rollup merge of #92366 - jhpratt:derive-default-enum, r=Mark-SimulacrumMatthias Krüger-3/+0
Resolve concern of `derive_default_enum` This resolves the concern in favor of prohibiting multiple instances of the attribute. This is similar to non-helper attributes as introduced in #88681. ``@rustbot`` label +S-waiting-on-review +T-libs-api
2022-02-16Correctly mark the span of captured arguments in `format_args!()`Chayim Refael Friedman-15/+15
It should only include the identifier, or misspelling suggestions will be wrong.
2022-02-11Remove the alt_std_name optionbjorn3-2/+1
This option introduced in #15820 allows a custom crate to be imported in the place of std, but with the name std. I don't think there is any value to this. At most it is confusing users of a driver that uses this option. There are no users of this option on github. If anyone still needs it, they can emulate it injecting #![no_core] in addition to their own prelude.
2022-02-08Rollup merge of #91950 - estebank:point-at-type-of-non-allocator, ↵Matthias Krüger-10/+12
r=matthewjasper Point at type when a `static` `#[global_allocator]` doesn't `impl` `GlobalAlloc`
2022-02-08Rollup merge of #93672 - lcnr:const-param-defaults-xx, r=matthewjasperMatthias Krüger-1/+1
update comment wrt const param defaults after #93669 i looked through all other uses of `GenericParamKind::Const` again to detect if we missed the `default` there as well, but afaict we really only missed lifetime resolution '^^ at least i found an outdated comment :3
2022-02-07Rollup merge of #93416 - name1e5s:chore/remove_allow_fail, r=m-ou-seMara Bos-9/+0
remove `allow_fail` test flag close #93345
2022-02-07Rollup merge of #93394 - m-ou-se:fix-93378, r=estebankMara Bos-11/+24
Don't allow {} to refer to implicit captures in format_args. Fixes #93378
2022-02-07Auto merge of #93179 - Urgau:unreachable-2021, r=m-ou-se,oli-obkbors-6/+28
Fix invalid special casing of the unreachable! macro This pull-request fix an invalid special casing of the `unreachable!` macro in the same way the `panic!` macro was solved, by adding two new internal only macros `unreachable_2015` and `unreachable_2021` edition dependent and turn `unreachable!` into a built-in macro that do dispatching. This logic is stolen from the `panic!` macro. ~~This pull-request also adds an internal feature `format_args_capture_non_literal` that allows capturing arguments from formatted string that expanded from macros. The original RFC #2795 mentioned this as a future possibility. This feature is [required](https://github.com/rust-lang/rust/issues/92137#issuecomment-1018630522) because of concatenation that needs to be done inside the macro:~~ ```rust $crate::concat!("internal error: entered unreachable code: ", $fmt) ``` **In summary** the new behavior for the `unreachable!` macro with this pr is: Edition 2021: ```rust let x = 5; unreachable!("x is {x}"); ``` ``` internal error: entered unreachable code: x is 5 ``` Edition <= 2018: ```rust let x = 5; unreachable!("x is {x}"); ``` ``` internal error: entered unreachable code: x is {x} ``` Also note that the change in this PR are **insta-stable** and **breaking changes** but this a considered as being a [bug](https://github.com/rust-lang/rust/issues/92137#issuecomment-998441613). If someone could start a perf run and then a crater run this would be appreciated. Fixes https://github.com/rust-lang/rust/issues/92137
2022-02-05update commentlcnr-1/+1
2022-02-01add a rustc::query_stability lintlcnr-0/+1
2022-01-31Fix invalid special casing of the unreachable! macroLoïc BRANSTETT-6/+28
2022-01-31Rollup merge of #93461 - dtolnay:fmtyield, r=davidtwcoMatthias Krüger-4/+51
Accommodate yield points in the format_args expansion Fixes #93274. For the case `println!("{} {:?}", "", async {}.await)` in the issue, the expansion before: ```rust ::std::io::_print( ::core::fmt::Arguments::new_v1( &["", " ", "\n"], &[ ::core::fmt::ArgumentV1::new(&"", ::core::fmt::Display::fmt), ::core::fmt::ArgumentV1::new(&async {}.await, ::core::fmt::Debug::fmt), ], ), ); ``` After: ```rust ::std::io::_print( ::core::fmt::Arguments::new_v1( &["", " ", "\n"], &match (&"", &async {}.await) { _args => [ ::core::fmt::ArgumentV1::new(_args.0, ::core::fmt::Display::fmt), ::core::fmt::ArgumentV1::new(_args.1, ::core::fmt::Debug::fmt), ], }, ), ); ```
2022-01-31Auto merge of #90891 - nbdd0121:format, r=Mark-Simulacrumbors-4/+14
Create `core::fmt::ArgumentV1` with generics instead of fn pointer Split from (and prerequisite of) #90488, as this seems to have perf implication. `@rustbot` label: +T-libs
2022-01-30Mac callsDavid Tolnay-3/+5
2022-01-30Accommodate yield points in the format_args expansionDavid Tolnay-4/+49
2022-01-29Rename _args -> args in format_args expansionDavid Tolnay-3/+3
2022-01-29Create `core::fmt::ArgumentV1` with generics instead of fn pointerGary Guo-4/+14
2022-01-28remove allow_fail test flagyuhaixin.hx-9/+0
2022-01-28Don't allow {} to refer to implicit captures in format_args.Mara Bos-11/+24
2022-01-17add more info to invalid use of #[test] on invalid itemsasquared31415-6/+16
2022-01-17Fix comment about spans during borrowck per PR 91359 reviewDavid Tolnay-1/+1
2022-01-17Replace confusing is_sorted_by in format_args implementationDavid Tolnay-13/+16
2022-01-17Emit simpler code from format_argsDavid Tolnay-61/+76
2022-01-17Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieubors-314/+0
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes #70173. Closes #92794. Closes #87612. Closes #82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
2022-01-15Deny mixing bin crate type with lib crate typesbjorn3-5/+0
The produced library would get a main shim too which conflicts with the main shim of the executable linking the library. ``` $ cat > main1.rs <<EOF fn main() {} pub fn bar() {} EOF $ cat > main2.rs <<EOF extern crate main1; fn main() { main1::bar(); } EOF $ rustc --crate-type bin --crate-type lib main1.rs $ rustc -L. main2.rs error: linking with `cc` failed: exit status: 1 [...] = note: /usr/bin/ld: /tmp/crate_bin_lib/libmain1.rlib(main1.main1.707747aa-cgu.0.rcgu.o): in function `main': main1.707747aa-cgu.0:(.text.main+0x0): multiple definition of `main'; main2.main2.02a148fe-cgu.0.rcgu.o:main2.02a148fe-cgu.0:(.text.main+0x0): first defined here collect2: error: ld returned 1 exit status ```
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-314/+0
2022-01-10Update AsmArgs field visibility for rustfmtYacin Tmimi-4/+4
To more easily allow rustfmt to format the asm! macro as specified in rust-dev-tools/fmt-rfcs#152 certain fields are made public.
2022-01-02Auto merge of #92066 - Smittyvb:concat_bytes-repeat, r=nagisabors-40/+65
Support [x; n] expressions in concat_bytes! Currently trying to use `concat_bytes!` with a repeating array value like `[42; 5]` results in an error: ``` error: expected a byte literal --> src/main.rs:3:27 | 3 | let x = concat_bytes!([3; 4]); | ^^^^^^ | = note: only byte literals (like `b"foo"`, `b's'`, and `[3, 4, 5]`) can be passed to `concat_bytes!()` ``` This makes it so repeating array syntax can be used the same way normal arrays can be. The RFC doesn't explicitly mention repeat expressions, but it seems reasonable to allow them as well, since normal arrays are allowed. It is possible to make the compiler get stuck compiling forever with `concat_bytes!([3; 999999999])`, but I don't think that's much of an issue since you can do that already with `const X: [u8; 999999999] = [3; 999999999];`. Contributes to #87555.
2021-12-31update testsDavid Renshaw-3/+3
2021-12-31[rustc_builtin_macros] add indices to ↵David Renshaw-16/+12
format_foreign::printf::Substitution::Escape
2021-12-28Remove FIXMEJacob Pratt-3/+0
This resolves the concern in favor of prohibiting multiple instances of the attribute. This is similar to non-helper attributes as introduced in #88681.