forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#113483 - Mark-Simulacrum:beta-backport, r=Mar…
…k-Simulacrum [beta] backport This PR backports: - rust-lang#113334: Revert the lexing of `c"…"` string literals - rust-lang#113231: Fix `dropping_copy_types` lint from linting in match-arm with side-effects - rust-lang#112794: Fix linker failures when #[global_allocator] is used in a dependency r? `@Mark-Simulacrum`
- Loading branch information
Showing
20 changed files
with
217 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# ignore-cross-compile | ||
include ../tools.mk | ||
|
||
all: | ||
rm -rf $(TMPDIR) && mkdir $(TMPDIR) | ||
$(RUSTC) my_lib.rs | ||
$(RUSTC) main.rs --test --extern my_lib=$(TMPDIR)/libmy_lib.rlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#![crate_type = "bin"] | ||
|
||
fn main() { | ||
my_lib::do_something(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#![crate_type = "lib"] | ||
|
||
use std::alloc::System; | ||
|
||
#[global_allocator] | ||
static ALLOCATOR: System = System; | ||
|
||
pub fn do_something() { | ||
format!("allocating a string!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error: prefix `c` is unknown | ||
--> $DIR/basic.rs:8:27 | ||
| | ||
LL | assert_eq!(b"test\0", c"test".to_bytes_with_nul()); | ||
| ^ unknown prefix | ||
| | ||
= note: prefixed identifiers and literals are reserved since Rust 2021 | ||
help: consider inserting whitespace here | ||
| | ||
LL | assert_eq!(b"test\0", c "test".to_bytes_with_nul()); | ||
| + | ||
|
||
error: no rules expected the token `"test"` | ||
--> $DIR/basic.rs:8:28 | ||
| | ||
LL | assert_eq!(b"test\0", c"test".to_bytes_with_nul()); | ||
| -^^^^^ | ||
| | | ||
| no rules expected this token in macro call | ||
| help: missing comma here | ||
| | ||
= note: while trying to match sequence start | ||
|
||
error: aborting due to 2 previous errors | ||
|
24 changes: 24 additions & 0 deletions
24
tests/ui/rfcs/rfc-3348-c-string-literals/edition-2015-2018-lexing.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Regression test for issue #113235. | ||
|
||
// check-pass | ||
// revisions: edition2015 edition2018 | ||
//[edition2015] edition: 2015 | ||
//[edition2018] edition: 2018 | ||
|
||
// Make sure that in pre-2021 editions we continue to parse the snippet | ||
// `c"hello"` as an identifier followed by a (normal) string literal and | ||
// allow the code below to compile. | ||
// Prefixes including `c` as used by C string literals are only reserved | ||
// in edition 2021 and onward. | ||
// | ||
// Consider checking out rust-2021/reserved-prefixes-migration.rs as well. | ||
|
||
macro_rules! parse { | ||
(c $e:expr) => { | ||
$e | ||
}; | ||
} | ||
|
||
fn main() { | ||
let _: &'static str = parse!(c"hello"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
// gate-test-c_str_literals | ||
// known-bug: #113333 | ||
// edition: 2021 | ||
|
||
macro_rules! m { | ||
($t:tt) => {} | ||
} | ||
|
||
fn main() { | ||
c"foo"; | ||
//~^ ERROR: `c".."` literals are experimental | ||
// FIXME(c_str_literals): This should be ``c".."` literals are experimental` | ||
|
||
m!(c"test"); | ||
//~^ ERROR: `c".."` literals are experimental | ||
// FIXME(c_str_literals): This should be ``c".."` literals are experimental` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,32 @@ | ||
error[E0658]: `c".."` literals are experimental | ||
--> $DIR/gate.rs:8:5 | ||
error: prefix `c` is unknown | ||
--> $DIR/gate.rs:10:5 | ||
| | ||
LL | c"foo"; | ||
| ^^^^^^ | ||
| ^ unknown prefix | ||
| | ||
= note: see issue #105723 <https://github.com/rust-lang/rust/issues/105723> for more information | ||
= help: add `#![feature(c_str_literals)]` to the crate attributes to enable | ||
= note: prefixed identifiers and literals are reserved since Rust 2021 | ||
help: consider inserting whitespace here | ||
| | ||
LL | c "foo"; | ||
| + | ||
|
||
error[E0658]: `c".."` literals are experimental | ||
--> $DIR/gate.rs:11:8 | ||
error: prefix `c` is unknown | ||
--> $DIR/gate.rs:13:8 | ||
| | ||
LL | m!(c"test"); | ||
| ^^^^^^^ | ||
| ^ unknown prefix | ||
| | ||
= note: prefixed identifiers and literals are reserved since Rust 2021 | ||
help: consider inserting whitespace here | ||
| | ||
= note: see issue #105723 <https://github.com/rust-lang/rust/issues/105723> for more information | ||
= help: add `#![feature(c_str_literals)]` to the crate attributes to enable | ||
LL | m!(c "test"); | ||
| + | ||
|
||
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"foo"` | ||
--> $DIR/gate.rs:10:6 | ||
| | ||
LL | c"foo"; | ||
| ^^^^^ expected one of 8 possible tokens | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
error: prefix `c` is unknown | ||
--> $DIR/non-ascii.rs:9:9 | ||
| | ||
LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), | ||
| ^ unknown prefix | ||
| | ||
= note: prefixed identifiers and literals are reserved since Rust 2021 | ||
help: consider inserting whitespace here | ||
| | ||
LL | c "\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), | ||
| + | ||
|
||
error: out of range hex escape | ||
--> $DIR/non-ascii.rs:9:11 | ||
| | ||
LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), | ||
| ^^^^ must be a character in the range [\x00-\x7f] | ||
|
||
error: out of range hex escape | ||
--> $DIR/non-ascii.rs:9:15 | ||
| | ||
LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), | ||
| ^^^^ must be a character in the range [\x00-\x7f] | ||
|
||
error: no rules expected the token `"\xEF\x80🦀\u{1F980}"` | ||
--> $DIR/non-ascii.rs:9:10 | ||
| | ||
LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), | ||
| -^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| no rules expected this token in macro call | ||
| help: missing comma here | ||
| | ||
note: while trying to match `,` | ||
--> $SRC_DIR/core/src/macros/mod.rs:LL:COL | ||
|
||
error: aborting due to 4 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters