Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4138702
discard invalid spans in external blocks
bvanjoi Nov 15, 2023
5d3a294
Only check principal trait ref for object safety
compiler-errors Dec 6, 2023
281b65a
Add method to get type of an Rvalue in StableMIR
celinval Dec 6, 2023
e16ebdb
Simplify StaticDef to Instance conversion
celinval Dec 6, 2023
77d7e44
Update compiler/stable_mir/src/mir/body.rs
celinval Dec 7, 2023
aa58ccb
Tell MirUsedCollector that the pointer alignment checks calls its pan…
saethlin Dec 7, 2023
4616b9f
Add sanity check to `BinOp::ty()`
celinval Dec 7, 2023
c0be10c
Ping GuillaumeGomez for changes in rustc_codegen_gcc
GuillaumeGomez Dec 7, 2023
399cd6c
targets: remove not-added {i386,i486}-unknown-linux-gnu
davidtwco Dec 7, 2023
efe8ae7
Fix const drop checking
compiler-errors Dec 6, 2023
f66e1c2
Uplift canonicalizer into new trait solver crate
compiler-errors Nov 22, 2023
606533e
Feedback
compiler-errors Dec 5, 2023
1c1df45
Make it not depend on nightly conditionally
compiler-errors Dec 5, 2023
95aa0b4
Rollup merge of #116420 - bvanjoi:fix-116203, r=Nilstrieb
compiler-errors Dec 7, 2023
d1d761f
Rollup merge of #117586 - compiler-errors:the-canonicalizer, r=lcnr
compiler-errors Dec 7, 2023
371b00a
Rollup merge of #118686 - compiler-errors:object-safety, r=lcnr
compiler-errors Dec 7, 2023
75dc956
Rollup merge of #118688 - celinval:smir-rvalue-ty, r=compiler-errors
compiler-errors Dec 7, 2023
8448c3c
Rollup merge of #118689 - compiler-errors:const-drop, r=fee1-dead
compiler-errors Dec 7, 2023
11f7b4b
Rollup merge of #118693 - saethlin:alignment-check-symbol-reachable, …
compiler-errors Dec 7, 2023
7ee9b5d
Rollup merge of #118707 - GuillaumeGomez:ping-cg_gcc, r=antoyo
compiler-errors Dec 7, 2023
2bea220
Rollup merge of #118712 - davidtwco:targets-remove-i386-i486, r=compi…
compiler-errors Dec 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,7 @@ pub(crate) struct ExternItemCannotBeConst {
#[primary_span]
pub ident_span: Span,
#[suggestion(code = "static ", applicability = "machine-applicable")]
pub const_span: Span,
pub const_span: Option<Span>,
}

#[derive(Diagnostic)]
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,9 +1139,11 @@ impl<'a> Parser<'a> {
Ok(kind) => kind,
Err(kind) => match kind {
ItemKind::Const(box ConstItem { ty, expr, .. }) => {
let const_span = Some(span.with_hi(ident.span.lo()))
.filter(|span| span.can_be_used_for_suggestions());
self.sess.emit_err(errors::ExternItemCannotBeConst {
ident_span: ident.span,
const_span: span.with_hi(ident.span.lo()),
const_span,
});
ForeignItemKind::Static(ty, Mutability::Not, expr)
}
Expand Down
21 changes: 21 additions & 0 deletions tests/ui/extern/issue-116203.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extern "C" {
thread_local! {
static FOO: u32 = 0;
//~^ error: extern items cannot be `const`
//~| error: incorrect `static` inside `extern` block
}
}

macro_rules! hello {
($name:ident) => {
const $name: () = ();
};
}

extern "C" {
hello! { yes }
//~^ error: extern items cannot be `const`
//~| error: incorrect `static` inside `extern` block
}

fn main() {}
46 changes: 46 additions & 0 deletions tests/ui/extern/issue-116203.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
error: extern items cannot be `const`
--> $DIR/issue-116203.rs:3:14
|
LL | static FOO: u32 = 0;
| ^^^
|
= note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html

error: extern items cannot be `const`
--> $DIR/issue-116203.rs:16:14
|
LL | hello! { yes }
| ^^^
|
= note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html

error: incorrect `static` inside `extern` block
--> $DIR/issue-116203.rs:3:14
|
LL | extern "C" {
| ---------- `extern` blocks define existing foreign statics and statics inside of them cannot have a body
LL | / thread_local! {
LL | | static FOO: u32 = 0;
| | ^^^ cannot have a body
LL | |
LL | |
LL | | }
| |_____- the invalid body
|
= note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html

error: incorrect `static` inside `extern` block
--> $DIR/issue-116203.rs:16:14
|
LL | const $name: () = ();
| -- the invalid body
...
LL | extern "C" {
| ---------- `extern` blocks define existing foreign statics and statics inside of them cannot have a body
LL | hello! { yes }
| ^^^ cannot have a body
|
= note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html

error: aborting due to 4 previous errors