Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explanation for E0756 #76489

Merged
merged 1 commit into from
Sep 22, 2020
Merged

Conversation

GuillaumeGomez
Copy link
Member

Copy link
Contributor

@pickfire pickfire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I thought #[ffi_const] was somehow related to const fn but it wasn't.

extern "C" {
#[ffi_const] // ok!
pub fn strlen(s: *const i8) -> i32;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same suggestion here. Show another method (or maybe a better one) with less contrast, no need to remove the current one.

#[ffi_pure]
extern "C" pub fn foo() {}

@jyn514 jyn514 added the A-error-codes Area: Explanation of an error code (--explain) label Sep 9, 2020
@@ -0,0 +1,29 @@
The `ffi_const` attribute was used on something else than a foreign function
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `ffi_const` attribute was used on something else than a foreign function
The `ffi_const` attribute was used on something other than a foreign function

```

The `ffi_const` attribute can only be used on foreign function declarations
which have no effects except for their return value:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not confuse people into thinking about effect type systems ;)

Suggested change
which have no effects except for their return value:
which have no side effects except for their return value:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously I was suggesting

The `ffi_pure` attribute can only be used on foreign functions which do not have
side effects or infinite loops:

which could be used exactly the same here, I wonder if that is better since I combined multiple parts from the book.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C assumes that all functions don't have infinite loops; it's called "forward progress guarantee". The rules around it are somewhat odd and I don't think they belong here, see https://blog.rust-lang.org/inside-rust/2020/03/19/terminating-rust.html for details.

@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. A-FFI Area: Foreign function interface (FFI) labels Sep 9, 2020
@jonas-schievink
Copy link
Contributor

r? @jyn514

@GuillaumeGomez
Copy link
Member Author

@bors: r=jyn514 rollup

@bors
Copy link
Contributor

bors commented Sep 21, 2020

📌 Commit f72fc26cddb9255aa8a7fb12107fc41abe27879f has been approved by jyn514

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 21, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 21, 2020
Rollup of 10 pull requests

Successful merges:

 - rust-lang#76439 (Add error explanation for E0755)
 - rust-lang#76521 (Fix segfault if pthread_getattr_np fails)
 - rust-lang#76835 (make replace_prefix only take &str as arguments )
 - rust-lang#76967 (Revert adding Atomic::from_mut.)
 - rust-lang#76977 (Add a regression test for copy propagation miscompilation)
 - rust-lang#76981 (liballoc bench use imported path Bencher)
 - rust-lang#76983 (BTreeMap: extra testing & fixed comments)
 - rust-lang#76996 (Fix typo in rustc_lexer docs)
 - rust-lang#77009 (Dogfood total_cmp in the test crate)
 - rust-lang#77012 (update Miri for another bugfix)

Failed merges:

 - rust-lang#76489 (Add explanation for E0756)

r? `@ghost`
@bors
Copy link
Contributor

bors commented Sep 21, 2020

☔ The latest upstream changes (presumably #77013) made this pull request unmergeable. Please resolve the merge conflicts.

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 21, 2020
@jyn514
Copy link
Member

jyn514 commented Sep 21, 2020

Merged in #77013, not sure why github didn't notice.

@jyn514 jyn514 closed this Sep 21, 2020
@GuillaumeGomez
Copy link
Member Author

GuillaumeGomez commented Sep 21, 2020

No, it was E0755, not this one. ;)

@GuillaumeGomez
Copy link
Member Author

Let's go again!

@bors: r=jyn514 rollup

@bors
Copy link
Contributor

bors commented Sep 21, 2020

📌 Commit 63195ec has been approved by jyn514

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 21, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 22, 2020
ecstatic-morse added a commit to ecstatic-morse/rust that referenced this pull request Sep 22, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 22, 2020
…atic-morse

Rollup of 13 pull requests

Successful merges:

 - rust-lang#72734 (Reduce duplicate in liballoc reserve error handling)
 - rust-lang#76131 (Don't use `zip` to compare iterators during pretty-print hack)
 - rust-lang#76150 (Don't recommend ManuallyDrop to customize drop order)
 - rust-lang#76275 (Implementation of Write for some immutable ref structs)
 - rust-lang#76489 (Add explanation for E0756)
 - rust-lang#76581 (do not ICE on bound variables, return `TooGeneric` instead)
 - rust-lang#76655 (Make some methods of `Pin` unstable const)
 - rust-lang#76783 (Only get ImplKind::Impl once)
 - rust-lang#76807 (Use const-checking to forbid use of unstable features in const-stable functions)
 - rust-lang#76888 (use if let instead of single match arm expressions)
 - rust-lang#76914 (extend `Ty` and `TyCtxt` lints to self types)
 - rust-lang#77022 (Reduce boilerplate for BytePos and CharPos)
 - rust-lang#77032 (lint missing docs for extern items)

Failed merges:

r? `@ghost`
@bors bors merged commit ef6c3a7 into rust-lang:master Sep 22, 2020
@rustbot rustbot added this to the 1.48.0 milestone Sep 22, 2020
@GuillaumeGomez GuillaumeGomez deleted the add-explanation-e0756 branch September 22, 2020 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-error-codes Area: Explanation of an error code (--explain) A-FFI Area: Foreign function interface (FFI) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants