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

resolve how to handle constants and default binding modes #44849

Open
nikomatsakis opened this issue Sep 25, 2017 · 1 comment
Open

resolve how to handle constants and default binding modes #44849

nikomatsakis opened this issue Sep 25, 2017 · 1 comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

Another interesting question that @tschottdorf encountered when implementing default binding modes: What do we do with constants? The RFC specifies that we ought to treat a FOO binding that resolves to a constant as something which can skip through &T types -- however, that runs into trouble if the type of the constant itself is &str or &[T]. The current logic at least skips through all &T or &mut T types when it skips through any, but handling &str correctly would require skipping through "only the right number".

@tschottdorf implemented various rules but we should at minimum update the RFC to match.

@nikomatsakis nikomatsakis added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-compiler-middle labels Sep 25, 2017
@TimNN TimNN added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Sep 27, 2017
@nikomatsakis
Copy link
Contributor Author

An example. Per the language in the RFC, constants of reference type will not "autoderef", but that means that this example does not work, which seems unfortunate:

let s: &'static str = "abc";
match &s {
  "abc" => true,
  _ => panic!(),
};

bors added a commit that referenced this issue Mar 27, 2018
Stabilize match_default_bindings

This includes a submodule update to rustfmt
in order to allow a stable feature declaration.

r? @nikomatsakis

cc #42640

Many of the tests this PR touches are merely testing the current lack of desired future behavior around #44849 and #44848 (cc @tschottdorf). I noticed the bullets for those items were checked on the tracking issue-- I've unchecked them, as they don't appear to have been completed and I don't see any comments indicating that we don't want to pursue them further. Still, I think it's fine to stabilize the current behavior, as I think expanding it in the future should be backwards-compatible.
bors added a commit that referenced this issue Mar 28, 2018
Stabilize match_default_bindings

This includes a submodule update to rustfmt
in order to allow a stable feature declaration.

r? @nikomatsakis

cc #42640

Many of the tests this PR touches are merely testing the current lack of desired future behavior around #44849 and #44848 (cc @tschottdorf). I noticed the bullets for those items were checked on the tracking issue-- I've unchecked them, as they don't appear to have been completed and I don't see any comments indicating that we don't want to pursue them further. Still, I think it's fine to stabilize the current behavior, as I think expanding it in the future should be backwards-compatible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants