-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Issue between non_local_definitions
and soroban-sdk
#132427
Comments
@leighmcculloch could you give us a reproduction, ideally a small and self-contained one. And/or if you can, the result of |
The issue is occurring in an area of code that is generated by a proc-macro, and the generated code inserts a I've tried to produce a minimal example, but all the minimal examples I have created have built just fine. So unfortunately all I have to offer is the project the issue was seen in. The following commands demonstrate the issue: Setup:
Build the crate with
Build the crate with
The code that is triggering the warning is here: #[contracttype(crate_path = "crate", export = false)]
pub enum Context {
/// Contract invocation.
Contract(ContractContext),
/// Contract that has a constructor with no arguments is created.
CreateContractHostFn(CreateContractHostFnContext),
/// Contract that has a constructor with 1 or more arguments is created.
CreateContractWithCtorHostFn(CreateContractWithConstructorHostFnContext),
} The const _: () = {
// derive(Arbitrary) expects these two to be in scope
use #path::testutils::arbitrary::std;
use #path::testutils::arbitrary::arbitrary;
#[derive(#path::testutils::arbitrary::arbitrary::Arbitrary)]
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
#vis #arbitrary_type_decl
impl #path::testutils::arbitrary::SorobanArbitrary for #ident {
type Prototype = #arbitrary_type_ident;
}
impl #path::TryFromVal<#path::Env, #arbitrary_type_ident> for #ident {
type Error = #path::ConversionError;
fn try_from_val(env: &#path::Env, v: &#arbitrary_type_ident) -> std::result::Result<Self, Self::Error> {
Ok(#arbitrary_ctor)
}
}
}; The The full expand for the crate is pretty huge, about 33k lines. I've included the whole thing below, because I didn't want to make an assumption on the scope to include. Search for "enum Context" and that's the type the code is being generated for, and then look for the const block that follows soon after it. (GitHub wouldn't let me attach a .rs file, so it's zipped.) |
Thanks for the expanded code. I've managed to minimized it. pub mod auth {
const _: () = {
pub enum ArbitraryContext {}
const _: () = {
impl ArbitraryContext {}
};
};
} |
Ah fantastic. So there's some interaction of the nested |
Yeah, item are considered to be transparent to const-anon and modules, but were |
…sparent, r=jieyouxu Also treat `impl` definition parent as transparent regarding modules This PR changes the `non_local_definitions` lint logic to also consider `impl` definition parent as transparent regarding modules. See tests and explanation in the changes. `@rustbot` label +L-non_local_definitions Fixes *(after beta-backport)* rust-lang#132427 cc `@leighmcculloch` r? `@jieyouxu`
…sparent, r=jieyouxu Also treat `impl` definition parent as transparent regarding modules This PR changes the `non_local_definitions` lint logic to also consider `impl` definition parent as transparent regarding modules. See tests and explanation in the changes. ``@rustbot`` label +L-non_local_definitions Fixes *(after beta-backport)* rust-lang#132427 cc ``@leighmcculloch`` r? ``@jieyouxu``
…sparent, r=jieyouxu Also treat `impl` definition parent as transparent regarding modules This PR changes the `non_local_definitions` lint logic to also consider `impl` definition parent as transparent regarding modules. See tests and explanation in the changes. ```@rustbot``` label +L-non_local_definitions Fixes *(after beta-backport)* rust-lang#132427 cc ```@leighmcculloch``` r? ```@jieyouxu```
…sparent, r=jieyouxu Also treat `impl` definition parent as transparent regarding modules This PR changes the `non_local_definitions` lint logic to also consider `impl` definition parent as transparent regarding modules. See tests and explanation in the changes. ````@rustbot```` label +L-non_local_definitions Fixes *(after beta-backport)* rust-lang#132427 cc ````@leighmcculloch```` r? ````@jieyouxu````
…sparent, r=jieyouxu Also treat `impl` definition parent as transparent regarding modules This PR changes the `non_local_definitions` lint logic to also consider `impl` definition parent as transparent regarding modules. See tests and explanation in the changes. `````@rustbot````` label +L-non_local_definitions Fixes *(after beta-backport)* rust-lang#132427 cc `````@leighmcculloch````` r? `````@jieyouxu`````
…sparent, r=jieyouxu Also treat `impl` definition parent as transparent regarding modules This PR changes the `non_local_definitions` lint logic to also consider `impl` definition parent as transparent regarding modules. See tests and explanation in the changes. ``````@rustbot`````` label +L-non_local_definitions Fixes *(after beta-backport)* rust-lang#132427 cc ``````@leighmcculloch`````` r? ``````@jieyouxu``````
Here is a minimized version of what the 'savefile-derive'-library does (which was also affected by the similar bug #131643): mod some_module {
const _: () = {
const _: () = {
impl Callable for Dummy {}
};
pub trait Callable {}
struct Dummy;
};
} In savefile-derive this pattern occurs if you use the derive-macros for a type that is not a the top level of the crate. Something that's a very reasonable thing to do. I'm guessing this is basically the exact same problem, but it would be nice to ensure this also works! |
Rollup merge of rust-lang#132453 - Urgau:non_local_defs-impl-mod-transparent, r=jieyouxu Also treat `impl` definition parent as transparent regarding modules This PR changes the `non_local_definitions` lint logic to also consider `impl` definition parent as transparent regarding modules. See tests and explanation in the changes. ``````@rustbot`````` label +L-non_local_definitions Fixes *(after beta-backport)* rust-lang#132427 cc ``````@leighmcculloch`````` r? ``````@jieyouxu``````
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-low |
### What Remove pin of nightly version for nightly builds. ### Why The underlying issue for why the version pinning was required has been fixed: - rust-lang/rust#132427
#132453 was beta-backported, closing. |
Originally posted by @leighmcculloch in #131643
The text was updated successfully, but these errors were encountered: